Learn C++ Tutorial 10

Assalam o Alikum Beginners today we discuss the following programs.

Write a program that inputs two numbers, Swaps the values, and then displays them.

Swapping

#include<iostream>

using namespace std;

int main(){

int num1,num2,temp;

cout<<"Please Enter first Number:";
cin>>num1;

cout<<"Please Enter Second Number:";
cin>>num2;

temp=num1;

num1=num2;

num2=temp;


cout<<"Num1 swap its value:"<<num1<<endl;

cout<<"Num2 swap its value:"<<num2;

}

in swapping two numbers exchange the values by using the third variable.

the first number assigns its value to temp and the second number assigns its value to the first number and then temp assigns its value to the second number.

Write a program that gets temperature from the user in celsius and converts it into Fahrenheit using the Formula

F= 9/5*C+32

Temperature

#include<iostream>

using namespace std;

int main(){

float cel,f;

cout<<"Please Enter The Temprature :";
cin>>cel;


f=9/5*cel+32;

cout<<"Temprature in Fahrenheit is :"<<f;

}

In the above program take the temperature from the user in celsius and apply the formula f=9/5*c+32 and then convert into Fahrenheit. 

 

Watch the Tutorial For Complete Understanding

Click here to watch the video

Thanks for Visiting here.

Related Posts