Posts

Showing posts from January, 2022

C++ program to interchange the values of two variables without using third variable

Image
Refer the below images for code and outputs and code will be provided just below it fig1. Code fig2. Output of Code  /* Write a C++ program to interchange the values of two variables without using third variable*/ #include <iostream> /* BASIC BUT IMPORTANT HEADER FILE*/ #include <stdio.h> using namespace std; /* FOR STANDARD INPUT OUTPUT */ int main() { int a,b; /* DECLARING VARIABLES AND THEIR DATA TYPES*/     cout << "HELLO EVERYONE, in this program we are interchanging the values of two variables without using third variable with the help of C++ lang. \n\n" ; cout << "\n enter the values for a and b: \n"; cout << "-----------------------------------\n"; cin >>a>>b; cout << "Before interchange: A = " << a << " and B = " << b << "\n"; a = a + b; b = a - b; a = a - b; cout << "After interchange: A = " << a << ...

Printing AREA and PARAMETER of rectangle

Image
 Printing AREA and PARAMETER of rectangle by taking input from the user. fig1.code fig2. output  code of this program can be copied from the below:- /*C++ PROGRAM FOR TAKING INPUT FROM THE USER AND GIVING BACK AREA AND PERIMETER OF RECTANGLE*/ #include <iostream> /* BASIC BUT IMPORTANT HEADER FILE*/ #include <stdio.h> using namespace std; /* FOR STANDARD INPUT OUTPUT */ int main() { float ar,peri,width,height=0; /* DECLARING VARIABLES AND THEIR DATA TYPES*/     cout << "HELLO EVERYONE, in this program we are finding AREA of Rectangle and PERIMETER as well with the help of C++ lang. \n\n" ; cout << "\n print the area of rectangle: \n"; cout << "-----------------------------------\n"; cout << "Input the width of the rectangle: \n"; cin >> width; cout << "Input the height of the rectangle: \n"; cin >> height; ar = height * width; peri = 2 * (width + height); cout ...