Home » » The cin Object in C++ - Example program

The cin Object in C++ - Example program

The cin Object in C++ - Example program 
Write a program in C++ to get two numbers from the keyboard during program execution. Calculate the sum and product of the numbers and then print the result on the computer screen. 

Output Sample: 
Enter First Number :27
Enter Second Number :
----------------------------------------
Sum of Numbers : 35
Product of Numbers :  216
---------------------------------------- 
In this program we are directed that our program get two numbers from the keyboard during program execution. We are going to use "cin" (stands for Console Input). 

See program output:
Program CODE:
#include<iostream.h>
#include<conio.h>
main(){
int num1, num2, sum, product;
clrscr();
sum=0;

cout<<"Enter First Number : ";
cin>>num1;

cout<<"Enter Second Number : ";
cin>>num2;

sum=num1+num2;
product=num1*num2;
cout<<"---------------------------"<<endl;
cout<<"Sum of Numbers : "<<sum<<endl;
cout<<"Product of Numbers : "<<product<<endl;
cout<<"---------------------------"<<endl;
 }
Thanks for visiting The cin Object in C++ - Example program     
more from: CS Adventures

0 comments:

Post a Comment

LIKE US

Popular Posts

My FANS around the WORLD

Flag Counter