#include <iostream> using namespace std ; int main () { int age ; cout << "Tell me your age" << endl ; cin >> age ; // Selection control structure : If else-if else ladder if (( age < 18 ) && ( age > 0 )) { cout << "You can not come to my party" << endl ; } else if ( age == 18 ) { cout << "You are a kid and you will get a kid pass to the party" << endl ; } else if ( age < 1 ) { cout << "You are not yet born" << endl ; } else { cout << "You can come to the party" << endl ; } // Selection control structure : Switch case statements ...
#include <iostream> using namespace std ; int main () { int num1 , num2 ; cout << "Enter the value of num1 : \n " ; cin >> num1 ; cout << "Enter the value of num2 : \n " ; cin >> num2 ; cout << "The sum is : " << num1 + num2 ; // '<<' is called Insertion operator // '>>' is called Extraction operator return 0 ; } OUTPUT: PS D:\C++> > cd "d:\C++\" ; if ($?) { g++ tut5.cpp -o tut5 } ; if ($?) { .\tut5 } Enter the value of num1 : 3 Enter the value of num2 : 8 The sum is : 11 PS D:\C++>
Comments
Post a Comment