Hi,
In this post i am going to brief you about calculating addition of two numbers in C++.
Recall the last program which we done in previous post and edit it like this...
---------------
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,sum;
clrscr();
cout<<"Enter First Number :";
cin>>a;
cout<<"Enter Second Number : ";
cin>>b;
sum=a+b;
cout<<"Sum :";
cout<<sum;
getch();
}
---------------
In this program i declared one more variable as int (sum) to store the sum value of the a & b. after reading the input from keyboard I declared a function - sum=a+b; - that generates (a+b) the result and store it to the variable "sum". Then "sum" printed on screen.
hope you understood it well.
Screenshot 1
In this post i am going to brief you about calculating addition of two numbers in C++.
Recall the last program which we done in previous post and edit it like this...
---------------
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,sum;
clrscr();
cout<<"Enter First Number :";
cin>>a;
cout<<"Enter Second Number : ";
cin>>b;
sum=a+b;
cout<<"Sum :";
cout<<sum;
getch();
}
---------------
In this program i declared one more variable as int (sum) to store the sum value of the a & b. after reading the input from keyboard I declared a function - sum=a+b; - that generates (a+b) the result and store it to the variable "sum". Then "sum" printed on screen.
hope you understood it well.
Screenshot 1
Screenshot 2
Exercise
- Subtraction / multiplication / division with three numbers.(read &print) -
Write a program to input a radius and print the Area Of a circle .
- Write a program to input marks of five subjects and print student name and his average.
0 comments:
Post a Comment