0% found this document useful (0 votes)
69 views11 pages

19-EE-154 (Abdullah Khan) PF#6

The document contains 5 programming tasks submitted by Abdullah Khan (Roll No: 19-EE-154) to Sir Shahwar Ali. Each task involves a C++ program that uses switch statements to output results. Task 1 compares two numbers and outputs the maximum. Task 2 checks if a number is even or odd. Task 3 determines a student's grade based on exam percentage. Task 4 performs basic math operations on two numbers. Task 5 outputs the state of water given a temperature in Celsius.

Uploaded by

Yasin Sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views11 pages

19-EE-154 (Abdullah Khan) PF#6

The document contains 5 programming tasks submitted by Abdullah Khan (Roll No: 19-EE-154) to Sir Shahwar Ali. Each task involves a C++ program that uses switch statements to output results. Task 1 compares two numbers and outputs the maximum. Task 2 checks if a number is even or odd. Task 3 determines a student's grade based on exam percentage. Task 4 performs basic math operations on two numbers. Task 5 outputs the state of water given a temperature in Celsius.

Uploaded by

Yasin Sohail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Name: Abdullah Khan

Roll No: 19-EE-154


Section: “B”
Submitted To: Sir Shahwar Ali
Task no 1:
Program:
#include <iostream>
using namespace std;
int main()
{
int p,q;
cout<<"Enter first number : ";
cin>>p;
cout<<"Enter second number : ";
cin>>q;
cout<<"\nRESULT: "<<endl;
switch(p > q)
{
case 0:
cout<<q<<" is Maximum number";
break;
case 1:
cout<<p<<" is Maximum number";
break;
}
return 0;
}

Output:

Task no 2:
Program:
#include <iostream>
using namespace std;
int main()
{
cout<<"Checking Even and Odd Numbers using Switches: \n";
int a;
cout<<"Enter the number : ";
cin>>a;
cout<<"\nRESULT: "<<endl;
switch(a%2==0)
{
case 0:
cout<<a<<" is Odd Number";
break;
case 1:
cout<<a<<" is Even Number";
break;
}
return 0;
}
Output:
Task no 3:
Program:
#include <iostream>
using namespace std;
int main()
{
cout<<"Checking grade of student using Switches:\n";
int marks;
cout<<"Enter the percentage : ";
cin>>marks;
cout<<"\nRESULT: "<<endl;
switch(marks/10)
{
case 10:
cout<<"Your Grade is A."<<endl;
break;
case 9:
cout<<"Your Grade is A."<<endl;
break;
case 8:
cout<<"Your Grade is B."<<endl;
break;
case 7:
cout<<"Your Grade is C."<<endl;
break;
case 6:
cout<<"Your Grade is D."<<endl;
break;
default:
cout<<"You are fail."<<endl;
break;}
return 0;
}

Output:
Task no 4:
Program:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout<<"enter any operator and number to perform
operation:"<<endl;
char a;
int x,y;
cout<<"\nInput the operation tou want to perform : ";
cin>>a;
cout<<"Enter the first number : ";
cin>>x;
cout<<"Enter the second number : ";
cin>>y;
cout<<"\nResult:"<<endl;
switch(a)
{
case '/':
cout <<"The Solution of operation is : "<<x/y;
break;
case '*':
cout << "The Solution of operation is : "<<x*y;
break;
case '+':
cout << "The Solution of operation is : "<<x+y;
break;
case '-':
cout <<"The Solution of operation is : "<<x-y;
break;
case '%':
cout <<"The Solution of operation is : "<<x % y;
break;
default:
cout << "The operator you entered is not correct";
break;
}
return 0;
}
Output:

Task no 5:
Program:
#include<iostream>
using namespace std;
int main()
{
cout<<"Giving the state of water at given temperature"<<endl;
float t;
cout<<"\nEnter the temperature in degree celcius : ";
cin>>t;
cout<<"\nResult:"<<endl;
switch(t<0)
{
case 1:
cout<<"The water is in the state of ice at "<<t<<" degree
celcius."<<endl;
break;
case 0:
switch(t>100)
{
case 1:
cout<<"The water is in the state of stream at "<<t<<" degree
celcius."<<endl;
break;
default:
cout<<"The water is in the state of liquid at "<<t<<" degree
celcius."<<endl;
}
}
return 0;
}
Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy