#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i;
cout << "If Statement in C++ Program!" << endl;
cin>>i;
if(i>0){
cout<< "It is If Statement...";
}
getch();
}
/*Any Number is input through the keyboard. write a program to find out whether It is and Odd Number or Even Number. using if-else
*/
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n=1;
cout << "Enter the Number: " << endl;
cin>>n;
if(n %2 == 0)
{
cout<< "This is Even Number...";
}
else
{
cout << "This is Odd Number...";
}
getch();
}
/*Any Number is input through the keyboard. write a program to find out whether It is and Odd Number or Even Number.*/
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int ram, sham, ajay;
cout << "Nested if in C++: ";
cout << "Enter the Age of Ram: ";
cin>>ram;
cout << "Enter the Age of Sham: ";
cin>>sham;
cout << "Enter the Age of Ajay: ";
cin>>ajay;
if(ram < sham)
{
if(ram < ajay)
{
cout <<"Ram is Youngest";
}
else
{
cout <<"Ajay is Youngest";
}
}
else
{
if(sham < ajay)
{
cout <<"Sham is Youngest";
}
else
{
cout <<"Ajay is Youngest";
}
}
getch();
}
/*Write a program to calculate the division obtained by the student. There are two ways in which we can write a program for this example. These methods are given below: */
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int eng,math,com,sci,ss,total;
float per;
cout <<"Enter the English Marks: ";
cin>>eng;
cout <<"Enter the Math Marks: ";
cin>>math;
cout <<"Enter the Computer Science Marks: ";
cin>>com;
cout <<"Enter the Science Marks: ";
cin>>sci;
cout <<"Enter the Social Study Marks: ";
cin>>ss;
total = eng + math + com + sci + ss;
cout <<"\nTotal Marks : "<<total;
per = total * 100.00 / 500;
cout <<"\nPercentage: "<<per;
if(per >= 60)
{
cout <<"\n1st Division";
}
else if(per >= 50)
{
cout <<"\n2nd Division";
}
else if(per >= 40)
{
cout <<"\n3rd Division";
}
else
{
cout <<"\nSorry! Fail";
}
getch();
}
/*WAP to print the four-days of week from monday to thrusday which works upon the choice as S,M,T,H using switch case*/
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char n;
cout<<"Enter the Choice from Four Days...\n";
cout<<"S = Sunday \n";
cout<<"M = Monday \n";
cout<<"T = Tuesday \n";
cout<<"H = Thursday \n";
cout<<"********************************\n\n";
cin>>n;
switch(n)
{
case 'S':
{
cout<<"Sunday";
break;
}
case 'M':
{
cout<<"Monday";
break;
}
case 'T':
{
cout<<"Tuesday";
break;
}
case 'H':
{
cout<<"Thursday";
break;
}
default:
{
cout<<"Out of Choice";
break;
}
}
getch();
}