You are on page 1of 2

#include <iostream>

#include <conio.h>
using namespace std;
int main(){
cout<<"Question no 1 \n";
//example of if statement
int rate;
cout<<"enter rate of car ";
cin>>rate; //get rate of car from user
if(rate==45000){
cout<<"confirm this car "; //if condition is equal to user rate then this statement
will display on screen
}
cout<<"\n\n\n\n"; //use this for extra vertical spaces

//example of if-else statement


int marks;
cout<<"enter marks of student ";
cin>>marks; //get marks of student from user
if(marks>=40){
cout<<"pass"; //if condition meet then this statement will display on screen
}
else{
cout<<"fail"; //if condition does not meet then this statement will display on
screen
}
cout<<"\n\n\n\n"; //use this for extra vertical spaces

//example of else-if statement


int testscore,total;
total=200;
cout<<"Enter your testscore ";
cin>>testscore; //get testscore from user
if(testscore>=140&&testscore<=200){
cout<<"your percentage is "<<testscore*100/total<<endl; //if condition is true then
these statement will display on the screen
cout<<"you are eligible for admission "<<endl;
cout<<"you have more chances to get admission ";
}
else if(testscore>=100&&testscore<=139){
cout<<"your percentage is "<<testscore*100/total<<endl; //if first condition is
false and this condition is true then these....
cout<<"your are eligible for admission "<<endl; //statement
will display on the screen
cout<<"But there is not much chance for you to get admission ";
}
else {
cout<<"your percentage is "<<testscore*100/total<<endl; //if all above condition is
false then these statement display on the screen
cout<<"you are not eligible for admission "<<endl;
cout<<"try again ";
}
cout<<"\n\n\n\n"; //use this for extra vertical spaces

cout<<"Question no 2 \n";
int mark;
cout<<"Enter student mark \n";
cin>>mark;
if(mark>=90&&mark<=100){
cout<<"A+";
}
else if(mark>=80&&mark<=89){
cout<<"A";
}
else if(mark>=70&&mark<=79){
cout<<"B";
}
else if(mark>=60&&mark<=69){
cout<<"C";
}
else if(mark>=50&&mark<=59){
cout<<"D";
}
else if(mark>=0&&mark<=49){
cout<<"F";
}
cout<<"\n\n\n\n"; //use this for extra vertical spaces

cout<<"Question no 3 \n";
int item1,item2,item3,total_cost;
cout<<"Enter the price of item1 \n";
cin>>item1;
cout<<"Enter the price of item2 \n";
cin>>item2;
cout<<"Enter the price of item3 \n";
cin>>item3;
total_cost=item1+item2+item3;
if(total_cost>100){
int discount_amount,discount;
discount=0.1*total_cost; //apply this for calculate discount
cout<<"Here is a discount for you which is 10% \n";
discount_amount=total_cost-discount; //apply this for discount amount provided to
customer
cout<<"Hence "<<endl;
cout<<"Total cost before discount is "<<total_cost<<endl;
cout<<"and "<<endl;
cout<<"Total cost after discount is "<<discount_amount;
}

getch();
return 0;
}

You might also like