/* 11-D Prg2- Write a algorithm and C++ Program
to read the value of two numbers and find their sum. */
/*Algorithm:
Input
1. a
2. b
Output
1. sum
Method:
1. start // int a,b,sum;
2. Read a and b // cout<<"Enter a and b\n"; cin>>a>>b;
3. Write a and b //cout<<"a="<<a; cout<<"b="<<b;
4. //logic for sum
sum=a+b; //sum=a+b;
5. Write sum //cout<<"sum="<<sum;
6. stop
Program: */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,sum;
cout<<"Enter a and b \n";
cin>>a>>b;
cout<<"a="<<a;
cout<<"\tb="<<b;
sum=a+b;
cout<<"\nsum="<<sum;
getch();
}
to read the value of two numbers and find their sum. */
/*Algorithm:
Input
1. a
2. b
Output
1. sum
Method:
1. start // int a,b,sum;
2. Read a and b // cout<<"Enter a and b\n"; cin>>a>>b;
3. Write a and b //cout<<"a="<<a; cout<<"b="<<b;
4. //logic for sum
sum=a+b; //sum=a+b;
5. Write sum //cout<<"sum="<<sum;
6. stop
Program: */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,sum;
cout<<"Enter a and b \n";
cin>>a>>b;
cout<<"a="<<a;
cout<<"\tb="<<b;
sum=a+b;
cout<<"\nsum="<<sum;
getch();
}
No comments:
Post a Comment