C++ Program Takes Input From User, Prints Sum If User Enters 1 - Wisdom Lighter

Sunday, 1 July 2018

C++ Program Takes Input From User, Prints Sum If User Enters 1

Calculates sum of the values entered by the user.
#include <iostream.h>
#include <stdio.h>
#include <conio.h>


void main ()

{
   Clrscr();
   int opCode;
   double a1, a2, sum ;
   cout << "Please Enter 1 to calculate sum of two numbers " << endl;
   cout << "or enter 0 to quit" << endl;
   cin >> opCode ;
   if (opCode == 1){
   cout << "please enter the first number " << endl;
   cin >> a1;
   cout << "please enter the second number " << endl;
   cin >> a2;
   sum = a1 + a2 ;
   cout << "sum of number is : " << sum << endl;
   } else {
   cout << "run the program again " << endl;
   }
   getch();
}

No comments:
Write comments