1. Write a program to print a welcome msg ": welcome in c++"?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"\t\t\t\t\tgaurav agarwal"<<endl;
cout<<"welcome in c++";
getch();
}
2. Write a program to enter three numbers to print the sum, multiplication, division?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,sum,div,pdt;
cout<<"\t\t\t\t\tgaurav agarwal"<<endl;
cout<<"enter two no.";
cin>>a>>b;
cout<<"sum"<<a+b;
cout<<"\ndiv"<<a/b;
cout<<"\nmul
"<<a*b;
getch();
}
3. Write a program to swap two numbers using third variable?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"\t\t\t\t\tgaurav agarwal"<<endl;
cout<<"enter a &b";
cin>>a>>b;
c=a;
a=b;
b=c;
cout<<a<<"\n"<<b;
getch();
}
4. Write a program to swap two numbers without using third variable?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"\t\t\t\t\tgaurav agarwal"<<endl;
cout<<"enter a &b";
cin>>a>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<a<<"\n"<<b;
getch();
}
No comments:
Post a Comment