Saturday, 10 December 2011

a program to print a triangle given value by user in c

#include
#include
main()
{
int i,j,k,l,n;
clrscr();
printf("Enter any value");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
}
for(l=1;l {
printf("*");
}
printf("\n");
}
getch();
}


OUTPUT


Enter any value: 5


*
***
*****
*******
*********

Write a program to print the square of given numbers in c

#include
#include
main()
{
int i,n;
clrscr();
for(i=1;i<=7;i++)
printf("\n%d",i*i);
getch();
}

OUTPUT
1
4
9
16
25
36
49

Write a program to print square of given value by user in c

#include
#include
main()
{
int num,sqr,i,max;
clrscr();
printf("Enter The Value;");
scanf("%d",&num);
max=num+10;
for(i=num;i {
sqr=num*num;
printf("\n\t%d SQUARE=%d",i,sqr);
num=num+1;
}
getch();
}

OUTPUT
Enter The Value: 5
5 SQUARE = 25
6 SQUARE = 36
7 SQUARE = 49
8 SQUARE = 64
9 SQUARE = 81
10 SQUARE = 100
11 SQUARE = 121
12 SQUARE = 144
13 SQUARE = 169
14 SQUARE = 196

a program to to print a star by define spaces enter b user in c

#include
#include
main()
{
int i,sp;
clrscr();
printf("Enter Number of Spaces:-");
scanf("%d",&sp);
for(i=1;i<=sp;i++)
printf(" ");
printf("*");
getch();
}
Enter Number of spaces:- 10

Write a program to print a triangle in c

#include
#include
main()
{
int num,i,j,k,l;
clrscr();
printf("Enter The Number:");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
for(j=1;j<=num;j++)
{
printf("");
}
for(k=1;k<=i;k++)
{
printf("*");
}
for(l=1;l {
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
Enter The Number: 5
*
***
*****
*******
*********

Write a program to print alphabets in small letter in c

#include
#include
main()
{
int a;
clrscr();
for(a=97;a<=122;a++)
printf("%c",a);
getch();
}

OUTPUT
a b c d e f g h i j k l m n o p q r s t u v w x y z

Write a program to print series 0,3,8,15,24,35,48,63,80,99 in c

#include
#include
main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d,",i*i-1);
}
getch();
}

OUTPUT
0,3,8,15,24,35,48,63,80,99

Write a program to print series 1,4,7,10,…100 in c

#include
#include
void main()
{
int a;
clrscr();
for(a=0;a<100;a=a+2)
{
printf("%d",a=a+1);
printf("\t");
}
getch();
}

OUTPUT
1 4 7 10 13 16 19 ……………. 100

Write a program to print same number series in c

#include
#include
main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

OUTPUT
Enter How Many Lines You Want:5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Write a program to print a trangle in c

#include
#include
main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want In This Figure:");
scanf("%d",&n);
for(i=0;i {
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT
Enter How Many Lines You Want In This Figure:5
*
* *
* * *
* * * *
* * * * *

Write a program to print the reverse number in c

#include
#include
main()
{
long int num,i;
int dig;
clrscr();
printf("\n Enter the number:-");
scanf("%ld",&num);
printf("\n The reverse of number %ld is:-",num);
for(i=num;i>0;i=i/10)
{
dig=i%10;
printf("%d",dig);
}
getch();
}

OUTPUT
Enter the number: 1 2 3 4 5
The reverse of number 1 2 3 4 5 is: 5 4 3 2 1

Write a program to print this Series in c

A C E G I K M O Q S U W Y

#include
#include
main()
{
int i;
clrscr();
for(i=65;i<=90;i=i+2)
printf("%c%c",i,i+33);
getch();
}


OUTPUT
A C E G I K M O Q S U W Y

Write a program to print this Series by user in c

#include
#include
void main()
{
int n,i,j;
clrscr();
printf("Enter How Many Lines You Want IN This Figure:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}


OUTPUT
Enter How Many Lines You Want IN This Figure:4
1
1 2
1 2 3
1 2 3 4

Write a program to print this Series in c

#include
#include
main()
{
int n,i,j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

OUTPUT
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Write a program to print sum of the Digits in c

#include
#include
void main()
{
long int num,i;
int dig,sum=0;
clrscr();
printf("Enter a Number:");
scanf("%ld",&num);
for(i=num;i>0;i=i/10)
{
dig=i%10;
sum=sum+dig;
}
printf("\n The Sum of The Digits %ld is %d",num,sum);
getch();
}

OUTPUT
Enter a Number: 12
The Sum of The Digits 12 is 3

Write a program to print Even numbers in c

#include
#include
void main()
{
int i;
clrscr();
for(i=0;i<100;i=i+2)
{
printf("%d",i+2);
printf("\t");
}
getch();
}

OUTPUT
2 4 6 8 10 ………………… 100

Write a program to print Decrement order in c

#include
#include
main()
{
int a;
clrscr();
for(a=25;a>0;a=a-1)
printf("\n%d",a);
getch();
}

OUTPUT
25 24 23 22 21 …………………… 3 2 1

Write a program to print the ten numbers CUBE in c

#include
#include
main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf("\n%d",i*i*i);
}
getch();
}

OUTPUT
1 8 27 64 125 216 343 512 729 1000

Write a program to print this Series :-12345……….80 in c

#include
#include
#include
main()
{
int i;
clrscr();
for(i=1;i<=80;i++)
printf("%d",i);
getch();
}


OUTPUT
12345……….80

Write a program to print Decimal to Binary number in c

#include
#include
void main()
{
long int num;
long int rem,bn=0,i,x=1,j;
clrscr();
printf("Enter a Decimal Number:");
scanf("%ld",&num);
for(i=num,j=0;i>0;i=i/2,j++)
{
rem=i%2;
bn=bn+rem*x;
x=x*10;
printf("\nIn %d pass the value of\n",j+1);
printf("variable rem is= %ld bn is %ld x is= %ld\n",rem,bn,x);
}
printf("\n\nFinal Output:\n\n\n");
printf("\nDecimal Number is %ld\n\nBinary Number is %ld",num,bn);
getch();
}


OUTPUT
Enter a Decimal Number:15
Decimal Number is 15
Binary Number is 1111

Write a program to print Binary to Decimal numbers in c

#include
#include
main()
{
long int num;
long int rem,dig,sum=0,i,x=1;
clrscr();
printf("Enter a Binary Number:");
scanf("%ld",&num);
for(i=num;i>0;i=i/10)
{
rem=i%10;
dig=rem*x;
sum=sum+dig;
x=x*2;
}
printf("\nBinary Number is %ld\n\nDecimal Number is %ld",num,sum);
getch();
}

OUTPUT
Enter a Binary Number :1111
Binary Number is 1111
Decimal Number is 15

Write a program to print ASCII values in c

#include
#include
main()
{
int a;
clrscr();
for(a=65;a<=90;a++)
printf(" %d",a);
getch();
}

OUTPUT
65 66 67 68 …………. 90

Write a program to print Alphabate in c

#include
#include
main()
{
int a;
clrscr();
for(a=65;a<=90;a++)
printf(" %c",a);
getch();
}

OUTPUT
ABCD……….Z

Write a program to print this Series :-AaBbCcDd……………Zz in c

#include
#include
main()
{
int a,b;
clrscr();
for(a=65;a<=90;a++)
printf("%c%c",a,a+32);
getch();
}

OUTPUT
AaBbCcDd………….Zz

Write a program to print ten numbers by user in c

#include
#include
main()
{
int i,n;
clrscr();
printf("Enter The No.:-");
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("%d",i);
getch();
}

OUTPUT
Enter The No.:10
1 2 3 4 5 6 7 8 9 10

Write a program to print a table or even in c

#include
#include
main()
{
int a;
clrscr();
for(a=2;a<=20;a=a+2)
printf("\n%d",a);
getch();
}

OUTPUT
2 4 6 8 …………………20

a program to print this Series :-1 3 5 7 9………….20 in c

#include
#include
main()
{
int i;
clrscr();
for(i=1;i<=20;i=i+2)
printf("\n %d",i);
getch();
}

OUTPUT
1 3 5 7 9 ………19

Write a program to print this Series :- 1 2 3 4 5 6 7 ………..20 in c

#include
#include
main()
{
int i;
clrscr();
for(i=1;i<=20;i++)
printf("\n %d",i);
getch();
}

OUTPUT
1 2 3 4 5 6 7…….20

Write a program to print Odd Numbers in c

#include
#include
void main()
{
int i;
clrscr();
for(i=0;i<100;i=i+2)
{
printf("%d",i+1);
printf("\t");
}
getch();
}


OUTPUT
1 3 5 7 9 11 13 15 17 19………….99

Write a program to print Ten Numbers and find out its Total in c

#include
#include
main()
{
int i,num;
int sum=0;
clrscr();
printf("\nEnter Ten Numbers:");
for(i=0;i<10;i++)
{
scanf("%d",&num);
sum=sum+num;
}
printf("\n The Sum of Entered Numbers is:%d",sum);
getch();
}


OUTPUT
Enter Ten Numbers:11 21 31 41 51 61 71 81 91 101
The Sum of Entered Number is:560

Write a program to print Ten Numbers and find out the Highest Number in c

#include
#include
main()
{
int i,num,temp=0;
clrscr();
printf("Enter The Ten Numbers:\n");
scanf("%d",&num);
for(i=0;i<=10;i++);
{
scanf("%d",&num);
if(temp temp=num;
printf("\nThe Highest Number is:%d",temp);
}
getch();
}


OUTPUT
Enter The Ten Numbers:
1 54 2 6 8 9 7 12 5 6
The Highest Number is: 54

Write a program to print your name in c

#include
#include
main()
{
int a;
clrscr();
for(a=0;a<10;a++)
{
printf("\n HELLO RAM");
break;
}
getch();
}


OUTPUT

HELLO RAM

Write a program to print this Fibonacci Series :- 0,1,1,2,3,5,8,13,21,34 in c

#include
#include
main()
{
int x=0,y=1,z=0;
int i;
clrscr();
for(i=0;i<10;i++)
{
printf("%d,",z);
x=y;
y=z;
z=x+y;
}
getch();
}


OUTPUT
0,1,1,2,3,5,8,13,21,34

Write a program to find out the Factorial Number in c

#include
#include
void main()
{
long int fact=1,num,i;
clrscr();
printf("ENTER A NUMBER:");
scanf("%ld",&num);
for(i=num;i>0;i--)
{
fact=fact*i;
}
printf("The Factorial Value for %ld is %ld",num,fact);
getch();
}


OUTPUT
ENTER A NUMBER:4
Factorial Value for 4 is 24

Write a program to find out the Greater value in c

#include
#include
main()
{
int a,b;
clrscr();
printf("Enter First Value:");
scanf("%D",&a);
printf("Enter Second Value:");
scanf("%d",&b);
if(a>b)
{
printf("Greater Value is %d",a);
}
else
{
printf("Greater Value is %d",b);
}
getch();
}

a program to find out policy amount or not in c

#include
#include
main()
{
char h,l,s,b=0,m=0;
float pa,p;
int a;
clrscr();
scanf("%c%c%c",&h,&l,&s);
scanf("%f%f",&pa,&p);
scanf("%d",&a);
if(h<=25 && h<=35)
printf("health is excellent");
if(l==b)
printf("lives in bikaner");
else
if(s==m)
printf("sex is the male");
else
printf("sex is female");
pa=pa<=200000;
pa=p*4/1000;
printf("%f",p);
printf("polocey amount");
printf("invalid policy amount");
getch();
}

Write a program to input your Qualification , Experience , Age and find out you are Eleigibal or not in c

#include
#include
main()
{
char q,e,s;
int age;
clrscr();
scanf("Qualification=%c",&q);
scanf("Experiance=%cSex=%c",&e,&s);
scanf("Age=%d",&age);
if(q=='m' && e<=10 && age<=40 && s=='m')
printf("Eleigibal");
else
if(q=='m' && e<=10 && age<=40 && s=='f')
printf("Eleigibal");
else
printf("Not eleigibal");
getch();
}

Write a program to input a Year and find out it is a Leep year or not in c

#include
#include
main()
{
int year;
clrscr();
printf("Enter The Year:");
scanf("%d",&year);
if((year%4==0)&&(year%100!=0)||(year%400==0))
{
printf("\n Year %d is A Leep Year",year);
}
else
{
printf("\n Year %d is Not A Leep Year",year);
}
getch();
}


OUTPUT
Enter The Year: 2004
Year 2004 is A Leep Year

Write a program to input your Basic Salary and find out Allowance, Deduction and Net Salary in c

#include
#include
main()
{
int bs,al,de,ns;
char g;
clrscr();
printf("Enter Your Salary:");
scanf("%d",&bs);
al=(25*bs)/100;
de=(bs+al)/100*10;
ns=(bs+al)-de;
printf("Your Basic Salary is: %d",bs);
printf("\n your Allowance is: %d",al);
printf("\n Your Deduction is: %d",de);
printf("\n Your Net Salary is: %d",ns);
if(ns>=15000)
printf("\n Grade: A");
if(ns<15000&&ns>10000)
printf("\n Grade: B");
if(ns<10000&&ns>5000)
printf("\nGrade: C");
if(ns<5000)
printf("\n Grade: D");
getch();
}



OUTPUT
Enter Your Salary=5000

Your Basic Salary is:5000

Your Allowance is:-60

Your Deduction is:490

Your Net Salary is:4450

Grade :D

Write a program to input a Character and find out it is a Alphabate , Numeric and a Special Symbol in c

#include
#include
void main()
{
char ch;
clrscr();
printf("Enter a charactar");
scanf("%c",&ch);
if(ch>='A'&& ch<='Z' || ch>='a'&& ch<='z') printf("Alphabate"); else if (ch>='0'&&ch<='9')
printf("numeric");
else
printf("special.symbol");
getch();
}

OUTPUT
Enter a character ANAND
Alphabet

a program to input a word and find out it is a Capital letter ,Small letter ,Decimal Number and a Special Character in c

#include
#include
main()
{
char d;
clrscr();
printf("\n Type ");
scanf("%c",&d);

if(d>=65 && d<=90) printf("A word is capital latter"); else if(d>=97 && d<=122) printf("A word is small latter"); else if(d>=48 && d<=59)
printf("A word is decimal number");
else
printf("is a special charactor");
getch();
}

OUTPUT
Type ANAND
A word is capital latter

Write a program to input your three subject marks and find out these in c

Marks>=60 First Division
Marks>=48&&Marks<60 Second Division Marks>=36&&Marks<48 Third Division #include
#include
main()
{
int m1,m2,m3,p;
clrscr();
printf("Enter Msrks 1:");
scanf("%d",&m1);
printf("Enter Marks 2:");
scanf("%d",&m2);
printf("Enter Marks 3:");
scanf("%d",&m3);
p=(m1+m2+m3)*100/300;
{
if(p>=60)
printf("First Division");
else
if(p>=48&&p<60) printf("Second Division"); else if(p>=36&&p<48)
printf("Third Division");
else
printf("Fail");
}
getch();
}



OUTPUT


Enter Marks 1:45
Enter Marks 2:56
Enter Marks 3:79

Second Division

a program to input your three subject marks and find out in c

Marks>=60 First Division
Marks>=48&&Marks<60 Second Division Marks>=36&&Marks<48 Third Division Marks<36 Fail Your Total , Your Percentage ? #include
#include
main()
{
int m1,m2,m3,t;
float p;
clrscr();
printf("Enter Marks 1:");
scanf("%d",&m1);
printf("Enter Marks 2:");
scanf("%d",&m2);
printf("Enter Marks 3:");
scanf("%d",&m3);
t=m1+m2+m3;
p=t*100/300;
printf("\nYour total=%d",t);
printf("\nyour per=%f\n",p);
if(p>=60)
printf("First Division");
if(p>=48&&p<60) printf("Second Division"); if(p>=36&&p<48)
printf("Third Division");
if(p<36)
printf("Fail");
getch();
}


OUTPUT

Enter Marks 1:45
Enter Marks 2:56
Enter Marks 3:78

Your total=179

Your per=59.0000
Second Division

Write a program to division of small value in c

#include
#include
void main()
{
float a,b;
clrscr();
printf("enter the value a");
scanf("%f",&a);
printf("enter the value b");
scanf("%f",&b);
if (a>b)
printf("%f",a/b);
else
printf("%f",b/a);
getch();
}


OUTPUT
Enter the value a:10
Enter the value b:5
2.0000

a program to input two values and find out Greater value in c

#include
#include
main()
{
int a,b;
clrscr();
printf("Enter First Value:");
scanf("%D",&a);
printf("Enter Second Value:");
scanf("%d",&b);
if(a>b)
{
printf("Greater Value is %d",a);
}
else
{
printf("Greater Value is %d",b);
}
getch();
}


OUTPUT
Enter First Value:4
Enter Second Value:7
Greater Value is : 7

Write a program to input character and find out capital and small consonants or vowel in c

#include
#include
main()
{
char ch;
clrscr();
printf("Enter a character");
scanf("%c",&ch);
if(ch>='A' && ch<='Z') if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U') printf("capital Vowel"); else printf("Capital consonants"); else if(ch>='a' && ch<='z')
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
printf("small vowel");
else
printf("small consonants");
getch();
}
OUTPUT
Enter a character: a small vowel

Write a program to input number and find out Even and Odd in c

#include
#include
main()
{
int a;
clrscr();
printf("Enter A Number:");
scanf("%d",&a);
if(a%2==0)
{
printf("This is A Even Number");
}
else
{
printf("This is A Odd Number");
}
getch();
}

OUTPUT
Enter A Number:4
This is A Even Number

Write a program to input marks and find out percentage in c

#include
#include
main()
{
int m1,m2,m3,m4,m5;
long int tot;
float per;
clrscr();
printf("Enter the marks of a student in five subjects:-");
scanf("\n\n %d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);
tot=m1+m2+m3+m4+m5;
per=(tot*100)/500;
printf("\n percentage of the student:-%f",per);
getch();
}


OUTPUT
Enter the marks of a student is subjects:-45 45 45 45 45
Percentage of the student:- 45.00

Write a program to use of main post increment operators in c

#include
#include
main()
{
int x,y;
clrscr();
x=20;
y=x+++x++;
printf("\n THE Value of X is:-%d",x);
printf("\n THE Value of Y is:-%d",y);
getch();
}


OUTPUT
The Value of X is:7
The Value of Y is:10

Write a program to use of main pre increment operators in c

#include
#include
main()
{
int x,y;
clrscr();
x=5;
y=++x + ++x;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
The Value of X is:7
The Value of Y is:14

Write a program to use of post increment operator in c

#include
#include
main()
{
int x,y;
clrscr();
x=5;
y=x++;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
The Value of X is:6
The Value of Y is:5

Write a program to use of pre increment operators in c

#include
#include
main()
{
int x,y;
clrscr();
x=5;
y=++x;
printf("\n The Value of X is:-%d",x);
printf("\n The Value of Y is:-%d",y);
getch();
}



OUTPUT
The Value of X is:13
The Value of Y is:13

Write a program to input three values and find out the Biggest number in c

#include"stdio.h"
#include"conio.h"
main()
{
int x,y,z,a,b;
clrscr();
printf("Enter Three Numbers:\n");
scanf("%d%d%d",&x,&y,&z);
a=x>y?x:y;
b=a>z?a:z;
printf("\n The Biggest Number is:%d",b);
getch();
}


OUTPUT
Enter Three Numbers:
582
256
566
The Biggest Number is:582

Write a program to input the distance in kilometers and convert it in meter in c

#include
#include
main()
{
long int distkm,distmeter=0;
clrscr();
printf("Enter the distance in kilometers:-");
scanf("%ld",&distkm);
distmeter=distkm*1000;
printf("\n The distance in meters is:-%ld",distmeter);
getch();
}

OUTPUT
Enter the distance in kilometers:25
The distance in meters is: 25000

Write a program to input students number and find out average in c

#include
#include
main()
{
int boys,girls;
float avg;
clrscr();
printf("\n Enter The BOYS:-");
scanf("%d",&boys);
printf("\n Enter The GIRLS:-");
scanf("%d",&girls);
avg=(boys+girls)/2;
printf("\n AVERAGE:-%f",avg);
getch();
}


OUTPUT
Enter The BOYS :34
Enter The GIRLS :43
AVERAGE=38
AVERAGE=38.500000

Write a program convert float to int in c

#include
#include
main()
{
float x,y,z;
clrscr();
x=10.898;
y=21.777;
z=x+y;
printf("\n %f",z);
z=(int)x+y;
printf("\n %f",z);
z=(int)(x+y);
printf("\n %f",z);
getch();
}


OUTPUT
32.674999
31.777000
32.000000

the temperature in Fahrenheit and convert into centigrade in c

#include
#include
main()
{
float f,a;
clrscr();
printf("\n ENTER VALUE F:-");
scanf("%f",&f);
a=f-32/1.8;
printf("\n centigrade=%f",a);
getch();
}



OUTPUT
ENTER VALUE F :98.4
Centigrade=80.622223

Write a program to Fahrenheit temperature to convert in degree Celsius in c

#include
#include
main()
{
float ftemp,ctemp;
clrscr();
printf("The Temperature in Fahrenheit :-");
scanf("%f",&ftemp);
ctemp=5*(ftemp-32)/9;
printf("The Temperature in Degree Celsius is:-%f",ctemp);
getch();
}


OUTPUT
The Temperature in Fahrenheit:98.4
The Temperature in Degree Celsius is:36.888889

Write a program to calculate simple interest in c

#include
#include
main()
{
float a,b,c,d;
clrscr();
printf("Enter The Principal:-");
scanf("%f",&a);
printf("\n Enter The Rate:-");
scanf("%f",&b);
printf("\n Enter The Time:-");
scanf("%f",&c);
d=(a*b*c)/100;
printf("\n Interest is:-%f",d);
getch();
}


OUTPUT
Enter The Principal:10000
Enter The Rate:6
Enter The Time:2
Interest is:1200.00

Write a program to find out area and parameter in c

#include
#include
main()
{
int l,w,a,p;
clrscr();
printf("\n ENTER LENTH:-");
scanf("%d",&l);
printf("\n ENTER WEIGHT:-");
scanf("%d",&w);
a=l*w;
printf("\n area=%d",a);
p=2*(l+w);
printf("\n perameter=%d",p);
getch();
}

OUTPUT
ENTER LENTH:10
ENTER WEIGHT:5
Area=50
Parameter =30

Write a program to findout area and circle in c

#include
#include
void main()
{
float r,area,cir;
clrscr();
printf("Enter The Redius Of Circle:-");
scanf("%f",&r);
area=3.14*r*r;
cir=2*3.14*r;
printf("\n The area is:-%.2f");
printf("\n The circumference is:-%.2f",cir);
getch();
}


OUTPUT
Enter The Redius Of Circle:1
The area is:49.92
The circumference is:6.28

Write a program to Exchange two value use third variable in c

#include
#include
main()
{
int a,b,c;
clrscr();
printf("\n ENTER VALUE A:-");
scanf("%d",&a);
printf("\n ENTER VALUE B:-");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("\n a=%d,b=%d",a,b);
getch();
}
OUTPUT
ENTER VALUE A:12
ENTER VALUE B:28
A=28,B=12

a program to Exchange to value without use third variable in c

#include
#include
main()
{
int a,b;
clrscr();
printf("\n ENTER VALUE A:-");
scanf("%d",&a);
printf("\n ENTER VALUE B:-");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("\n a=%d,b=%d",a,b);
getch();
}


OUTPUT
ENTER VALUE A:10
ENTER VALUE B:15
A=15,B=10

Write a program to input a character and find out his ASCII value in c

#include
#include
main()
{
char ch='A';
clrscr();
printf("\n The Character is:%c",ch);
printf("\n The ASCII value of this character is:%d",ch);
getch();
}


OUTPUT
The Character is : A
The ASCII value is this character is:65

Write a program to addition,subtraction,multiplication,divition in c

#include
#include
main()
{
int a,b,add,sub,mult,div;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
add=a+b;
sub=a-b;
mult=a*b;
div=a/b;
printf("Add=%d\nSub=%d\nMult=%d\nDiv=%d",add,sub,mult,div);
getch();
}


OUTPUT
ENTER NO A:20
ENTER NO B:5
ADD=25
SUB=15
MULT=100
DIV=4

Write a program to division in c

#include
#include
main()
{
int a,b,div;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
div=a/b;
printf("\n\t division=%d",div);
getch();
}


OUTPUT
ENTER NO A:20
ENTER NO B:4
DIVISION=5

Write a program to multiplication in c

#include
#include
main()
{
int a,b,mult;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
mult=a*b;
printf("\n\t mult=%d",mult);
getch();
}



OUTPUT
ENTER NO A:15
ENTER NO B:10
MULT=150

Write a program to subtraction in c

#include
#include
main()
{
int a,b,sub;
clrscr();
printf("ENTER NO.A:-");
scanf("%d",&a);
printf("ENTER NO.B:-");
scanf("%d",&b);
sub=a-b;
printf("\n\t sub=%d",sub);
getch();
}


OUTPUT
ENTER NO. A:20
ENTER NO. B:10
SUB=10

Write a program to addition in c

#include
#include
main()
{
int a,b,tot;
clrscr();
printf("ENTER NO.1:- ");
scanf("%d",&a);
printf("ENTER NO.2:- ");
scanf("%d",&b);
tot=a+b;
printf("\n\ttotal=%d",tot);
getch();
}


OUTPUT
ENTER NO.1:10
ENTER NO.2:10
TOTAL=20