Professional Documents
Culture Documents
cout << "The greater number is: " << num1 << endl;
cout << "The greater number is: " << num2 << endl;
cout << "The greater number is: " << num3 << endl;
cout << "All numbers are equal and the number is: " << num1 << endl;
else {
}
else {
Output:
Task 2: Write a program which ask the user to enter a positive
integer and then calculate its factorial.
Code:
int num;
int factorial = 1;
cin>>num;
if(num>=0){
int i = 1;
factorial = factorial * i;
i++;
}else{
}
Output:
Code:
cin>>amount;
return 1;
}else{
note5000 = amount/5000;
amount%=5000;
note1000 = amount/1000;
amount%=1000;
note500 = amount/500;
amount%=500;
note100 = amount/100;
amount%=100;
note50 = amount/50;
amount%=50;
note20 = amount/20;
amount%=20;
note10 = amount/10;
amount%=10;
Code:
cin>>unitsConsumed;
Bill = unitsConsumed*5;
Bill = unitsConsumed*10;
Bill = unitsConsumed*20;
}else{
}
Output:
Task 5: Write a program to design ATM interface to perform the
following transactions. You may initialize the balance with zero.
After each transaction, the program should ask the user to perform
another transaction. Based on the input (y/n) the program either
redirects to the main interface or exit.
Press B to check account Balance
Press D to cash Deposit
Press W to cash Withdraw
Code:
cout<<"Program started!!!!!!!"<<endl;
char options;
balance = 0;
char tranAgain;
do{
cin>>options;
switch(options){
case 'B':
case 'b':
break;
case 'D':
case 'd':
cout<<"Enter amount to deposit ";
cin>>deposit;
balance+=deposit;
}else{
break;
case 'W':
case 'w':
cin>>withdraw;
balance-=withdraw;
}else{
}else{
break;
default:
cin>>tranAgain;
cout<<"Program exited!!!!!!!"<<endl;
}else{
cin>>tranAgain;