prowessapps.in Conditional Programming in C++

#include<iostream>
using namespace std;
int main() {
 int a,b;
 cout<<"Enter value for A: ";
 cin>>a;
 cout<<"Enter value for B: ";
 cin>>b;
 if(a>b) {
 cout<<"A is Greater";
 }
 else {
 cout<<"B is Greater";
 }
return 0;
}
OUTPUT
Enter value for A: 12
Enter value for B: 14
B is Greater

#include<iostream>
using namespace std;
int main() {
 int a,b,c;
 cout<<"Enter Values for A,B & C ";
 cin>>a>>b>>c;
 if(a>b && a>c) {
  cout<<"A is greatest ";
 }
 else if(b>c) {
  cout<<"B is greatest ";
 }
 else {
  cout<<"C is greatest ";
 }
 return 0;
}
OUTPUT
Enter Values for A,B & C 10 29 20
B is greatest

#include<iostream>
using namespace std;
int main() {
 int a,b,c;
 cout<<"Enter Values for A,B & C ";
 cin>>a>>b>>c;
 if(a>b) {
  if(a>c)
   cout<<"A is greatest";
  else
   cout<<"C is greatest";
 }
 else{
  if(b>c)
   cout<<"B is greatest";
  else
   cout<<"C is greatest";
 }
return 0;
}
OUTPUT
Enter Values for A,B & C 10 50 30
B is greatest

#include<iostream>
using namespace std;
int main() {
 int a;
 cout<<"Enter Value for A: ";
 cin>>a;
 if(a%2==0)
  cout<< a<<" IS EVEN NO.\n";
 else
  cout<< a<<" IS ODD NO.\n";
return 0;
}
OUTPUT
Enter Value for A: 12
12 IS EVEN NO.

#include<iostream>
using namespace std;
int main() {
 char a;
 cout<<"Enter a Character: ";
 cin>>a;
 if(a=='a' ||a=='e' ||a=='i' ||a=='o' ||a=='u') {
  cout<<"Character is vowel \n";
 }
 else if(a=='A' ||a=='E' ||a=='I'||a=='O' ||a=='U') {
  cout<<"Character is vowel \n";
 }
 else {
  cout<<"Character is NOT vowel \n";
 }
return 0;
}
OUTPUT
Enter a Character: E
Character is vowel

#include<iostream>
using namespace std;
int main() {
 int m1,m2,m3,m4,m5;
 float per;
 cout<<"Enter Marks Subject 1: ";
 cin>>m1;
 cout<<"Enter Marks Subject 2: ";
 cin>>m2;
 cout<<"Enter Marks Subject 3: ";
 cin>>m3;
 cout<<"Enter Marks Subject 4: ";
 cin>>m4;
 cout<<"Enter Marks Subject 5: ";
 cin>>m5;
 per = (m1+m2+m3+m4+m5)/5.0;
 cout<<"Your Marks % is "<< per<< endl;
 if(per>=80)
  cout<<"Your Grade is A \n";
 else if(per>= 70)
  cout<<"Your Grade is B \n";
 else if(per>= 60)
  cout<<"Your Grade is C \n";
 else if(per>= 50)
  cout<<"Your Grade is D \n";
 else
  cout<<"Your Grade is E \n";
return 0;
}
OUTPUT
Enter Marks Subject 1: 90
Enter Marks Subject 2: 91
Enter Marks Subject 3: 92
Enter Marks Subject 4: 92
Enter Marks Subject 5: 90
Your Marks % is 91
Your Grade is A

#include<iostream>
using namespace std;
int main() {
 int a;
 cout<<"Enter Day Number: ";
 cin>>a;
 switch(a) {
  case 1:
   cout<<"Day is Monday\n";
   break;
  case 2:
   cout<<"Day is Tuesday\n";
   break;
  case 3:
   cout<<"Day is Wednesday\n";
   break;
  case 4:
   cout<<"Day is Thursday\n";
   break;
  case 5:
   cout<<"Day is Friday\n";
   break;
  case 6:
   cout<<"Day is Saturday\n";
   break;
  case 7:
   cout<<"Day is Sunday\n";
   break;
  default:
   cout<<"Wrong Choice\n";
  }
 return 0;
}

OUTPUT
Enter Day Number: 4
Day is Thursday





CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-9026070669 , +91-9451396824

© 2016, prowessapps.in, All rights reserved