Swap
Numbers
#include
#include
void main ()
{
int b,r,n,r1,r2;
clrscr ();
printf ("Enter the Value: ");
scanf ("%d",&n);
r=n%10;
n=n/10;
r1=n%10;
n=n/10;
r2=n%10;
n=n/10;
b=(r*100)*(r2*10)+(r2);
printf ("%d%d%d",r,r1,r2);
getch ();
}
Sum of array
#include
#include
void main ()
{
int no[5],i,sum;
clrscr ();
for (i=0;i<=4;i++)
{
printf ("Enter Element: ");
scanf ("%d",&no[i]);
}
sum=no[0]+no[1]+no[2]+no[3]+no[4];
printf ("\nSum of five Elements: %d",sum);
getch ();
}
Sum, Sub, Product, Division
#include
#include
void main ()
{
int a,b,c,d,e,f;
clrscr();
printf ("Enter A: ");
scanf ("%d",&a);
printf ("Enter B: ");
scanf ("%d",&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
printf ("\nSum is : %d",c);
printf ("\nSubtraction is : %d",d);
printf ("\nMultiplication is : %d",e);
printf ("\nDivision is : %d",f);
getch ();
}
No comments:
Post a Comment