Professional Documents
Culture Documents
Solution 1 28122022 011819am
Solution 1 28122022 011819am
FUNCTIONS
CODE:
#include<iostream>
#include<conio.h>
using namespace std;
double ToCelsius(double F){
double C;
C = (F - 32) * 5 / 9;
cout << "Temeperature in Celsius : " << C;
return C;
}
int main()
{
char choice;
do{
double Fahrenheit;
cout << "Enter the Temperature in Fahrenheit : ";
cin >> Fahrenheit;
cout << endl;
ToCelsius(Fahrenheit);
cout << endl << "Do you want to convert more(Y/N) : ";
cin >> choice;
} while (choice == 'y' || choice == 'Y');
_getch();
return 0;
}
OUTPUT:
1|Page
Question:02
1- Write a C++ function to swap (interchange) two numbers. Write a function which
takes two variable values and then swaps them. Program sequence: Enter the
value of variable a:5 Enter the value of variable b:10 ///After swapping the output
would be The value of variable a is=10 The value of variable b is=5
CODE:
#include<iostream>
#include<conio.h>
using namespace std;
void Swap(int *a,int *b){
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int x, y;
cout << "Enter the value of x : ";
cin >> x;
cout << "Enter the value of y : ";
2|Page
cin >> y;
cout << endl << "The value of x=" << x << " and y=" << y;
Swap(&x, &y);
cout << endl << "After swap value of x=" << x << "and y=" << y;
_getch();
return 0;
}
OUTPUT:
+++++++THE END+++++++++
3|Page