Posts
Here a and b are two no. and we are swapping them.It means we are interchanging the values of a and b. // #include<iostream.h> #include<conio.h> void main() {clrscr(); int *a,*b,*c,p,q; cout<<"enter 2 nos.="; cin>>p>>q; a=&p; b=&q; *c=*a; *a=*b; *b=*c; cout<<"swapping nos.="<<*a<<'\n'<<*c<<'\n'; getch(); } OUTPUT enter 2 nos.=7 5 swapping nos.=5 7
#include<iostream.h> #include<conio.h> void main() { clrscr(); intm,n,i,j,k; cout<<"enter the integer\n"; cin>>n; for(i=0;i<=n;i++) { for(j=0;j<=n-i;j++) cout<<" "; for(k=i;k>=0;k--) cout<<"*"; for(m=1;m<=i;m++) cout<<"*"; cout<<"\n"; } getch(); } OUTPUT enter the integer 5 * *** ***** ******* ********* ***********