Pages

Thursday, July 04, 2013

Write a program that calculate Addition Question with 2 variable (cin) in C++

Write a program that take two variable from the user and print the addition


Input:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    #include <iostream.h>
    #include <conio.h> 
    int main()
    {
    cout << "Addition Question with 2 variable\n\n" ;
    int a, b, Sum;
    cout << " Enter a integer value?\n";
    cin  >> a; 
    cout << " Enter a integer value?\n";
    cin  >> b;
    Sum  = a + b;
    cout << "\t" << a << " + " << b <<" = " << Sum << endl;
    getch();
    return 0;
             }// end main 

Output:


1
2
3
4
5
6
Addition Question with 2 variable
 Enter a integer value?
789
 Enter a integer value?
567
 789 + 567 = 1356


No comments:

Post a Comment