Tuesday, 31 May 2016

Write a program to add two numbers:

1. value given at run time:

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
a=10;
b=12;
Cout<<"Addition is="<<a+b;
getch();
}

Out put: Addition is=22


2.value given at compile time

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cout<<"enter value of a=";
cin>>a;
cout<<"enter value of b=";
cin>>b;
cout<<"Addition is="<<a+b;
getch();
}

Out put: enter value of a=12
               enter value of b=10

press enter

                  Addition is=22

No comments:

Post a Comment