0% found this document useful (0 votes)
5 views

1st Task Assignment No 2 Two Pages....

Uploaded by

riazshareekanala
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

1st Task Assignment No 2 Two Pages....

Uploaded by

riazshareekanala
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: M Ikram Ullah

Roll No: 2001


Task: Programing Fundamentals

Task#1:

#include<iostream>
using namespace std;

int main()
{
float fahr, cel;
char option;

cout << "Choose from following option:" << endl;


cout << "1. Celsius to Fahrenheit." << endl;
cout << "2. Fahrenheit to Celsius." << endl;
cin >> option;

//option for converting celsius into fahernheit


if (option == '1')
{
cout << "Enter the temperature in Celsius: "<<'\n';
cin >> cel;

fahr = (1.8 * cel) + 32.0; //temperature conversion formula


cout << "\nTemperature in degree Fahrenheit: " << fahr << " F" << endl;
}
//option for converting Fahrenheit into Celsius
else if (option == '2')
{
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahr;

cel = (fahr - 32) / 1.8; //temperature conversion formula


cout << "\nTemperature in degree Celsius: " << cel << " C" << endl;
}
else
cout << "Error Wrong Input." << endl;

return 0;
}
Output :
Choose from following option :
1 . Celsius to Fahrenheit .
2 . Fahrenheit to Celsius .
1
Enter the temperature in Celsius :
10
Temperature in degree Fahrenheit : 50F

Choose from following option :


1 . Celsius to Fahrenheit .
2 . Fahrenheit to Celsius .
2
Enter the temperature in Fahrenheit : 10
Temperature in degree Celsius : -12.2222 C

Task#2:

#include<iostream>
using namespace std;
int main ()
{
int a , b;
char opt;
cout<<"Enter first Second number : " <<endl;
cin >> a;
cout <<"Enter Second numbe : " << endl;
cin >> b;
cout << "Enter operation + or - or * or / : " <<endl;
cin >> opt ;
if (opt == '+')
cout << "Sum = "<< a + b << endl;

else if (opt == '-')


cout << "Subtraction = "<< a - b << endl;

else if (opt == '*')


cout << "Product = "<< a * b << endl;

else if (opt == '/')


cout << "Divistion = "<< a / b << endl;
else

cout <<"YOU CHOOSE WRONG : "<< endl;

return 0;
}
Output:

Enter first Second number :


500
Enter Second number :
600
Enter operation + or – or * or / :
+
Sum = 1100

Task#3:

#include<iostream>
using namespace std;
// Driver Code

main()
{
//variables
float aside, bside, cside;
//enter side a
cout<<"enter the length of side a "<<endl;
cin>>aside;
//enter side b
cout<<"enter the length of side b "<<endl;
cin>>bside;
//enter side c
cout<<"enter the length of side c "<<endl;
cin>>cside;

// all sides equal


if(aside==bside && bside==cside)
cout << "Equilateral triangle\n";

// at least 2 sides equal


else if(aside==bside || aside==cside || bside==cside)

cout << "Isosceles triangle\n";


// no sides equal
else
cout << "Scalene triangle\n";
return 0;
}
Output:

Enter the length of side a


50
Enter the length of side b
50
Enter the length of side c
50
Equilateral triangle

You might also like