Sie sind auf Seite 1von 51

C Language Notes

dprogram to add two values and store in another variable


main()
{
int a,b,c;
a=10;
b=20;
c=a+b;
printf(!al of c is "d,c);
#
program to add two values
main()
{
int a,b;
a=10;
b=20;
printf(val is "d,a+b);
#
$rogram to add two values using scanf function and store in another variable
main()
{
int a,b,c;
clrscr();
printf(%nter val for a &n);
scanf("d,'a);
printf(%nter val for b&n);
scanf("d,'b);
c=a+b;
printf(val of c is "d,c);
#
$rogram to add two values using scanf function
main()
{
int a,b;
clrscr();
printf(%nter val for a &n);
scanf("d,'a);
printf(%nter val for b&n);
scanf("d,'b);
printf(value of a+b is "d,a+b);
#
program to calculate circumfrence of a circle
main()
{
int r,cir;
clrscr();
printf(%nter radius of a circle &n);
scanf("d,'r);
cir=()1*+(r+r);
printf(circumfrence is "d,cir);
,usicalroc-s)t- $age 1
C Language Notes
#
program to calculate area of a triangle
main()
{
int area,b,h;
clrscr();
printf(%nter base &n);
scanf("d,'b);
printf(%nter height &n);
scanf("d,'h);
area=0).+b+h;
printf(area is "d,area);
#
program to calculate area of rectangle
main()
{
int area,l,b;
clrscr();
printf(%nter length &n);
scanf("d,'l);
printf(%nter breath &n);
scanf("d,'b);
area=l+b;
printf(area is "d,area);
#
$rogram to area of s/uare
main()
{
int area,s;
clrscr();
printf(%nter side &n);
scanf("d,'s);
area=s+s;
printf(area is "d,area);
#
program to convert faheren heat to centigrade
main()
{
int f,c;
clrscr();
printf(%nter f &n);
scanf("d,'f);
c=f0(2;
printf(centigrade is "d,c);
#
program to calculate student details
main()
{
int rno,m,p,c,tot;
,usicalroc-s)t- $age 2
C Language Notes
char snm1102;
float avg;
clrscr();
printf(%nter roll number &n);
scanf("d,'rno);
printf(%nter name of the student &n);
scanf("s,snm);
printf(%nter mar-s &n);
scanf("d"d"d,'m,'p,'c);
tot=m+p+c;
avg=tot3(;
printf(4oll number is "d&n,rno);
printf(5ame id "sn,snm);
printf(6otal is "d&n,tot);
printf(7verage is "f&n,avg);
#
program to calculate emplo8ee details
main()
{
int eno;
char enm1102;
float bs,hra,da,ta,net;
clrscr();
printf(%nter emplo8ee number &n);
scanf("d,'eno);
printf(%nter name of the emplo8ee &n);
scanf("s,enm);
printf(%nter basic pa8&n);
scanf("f,'bs);
hra=bs+*03100;
ta=bs+203100;
da=bs+103100;
net=bs+hra+ta+da;
printf(emplo8ee number is "d&n,eno);
printf(5ame id "d&n,enm);
printf(nett amount is "f&n,net);
#
program to calculate current bill
main()
{
int mno;
char holdnm1102;
float cr,pr,gu,net,amt;
clrscr();
printf(%nter metre number &n);
scanf("d,'mno);
printf(%nter name of the holder &n);
scanf("s,holdnm);
printf(%nter current units&n);
scanf("f,'cu);
printf(%nter prev units&n);
scanf("f,'pu);
,usicalroc-s)t- $age 3
C Language Notes
net=cu0pu;
amt=1)2.+net;
printf(metre number is "d&n,mno);
printf(5ame id "d&n,holdnm);
printf(nett amount to pa8 is "f&n,net);
#

program on greatest of 2 numbers
main()
{
int a=10,b=20;
if(a9b)
printf(7 is big);
else
printf(: is :ig);
#
$rogram to displa8 the greatest of two numbers
main()
{
int a=10,b=20,c=(0,big=0;
big=a;
if(b9big)big=a;
if(c9big)big=c;
printf(;:iggest is "d<,big);
#
program to accept and displa8 the greatest of 2 numbers
main()
{
int a,b;
printf(%nter val for a and b&n);
scanf("d"d,'a,'b);
if(a9b)
printf(7 is big);
else
printf(: is :ig);
#
program to find even or odd of a given number
main()
{
int n;
printf(%nter val for n&n);
scanf("d,'n);
if(n"2==0)
printf(%ven number);
else
printf(=dd number);
#
program to find the given number is positive or negtive number
,usicalroc-s)t- $age 4
C Language Notes
main()
{
int n;
printf(%nter val for n&n);
scanf("d,'n);
if(n9=0)
printf($ositive number);
else
printf(negtive number);
#
program to find the area of a circle
>define pi ()1*
main()
{
float a,r;
clrscr();
printf(+++++++++++++++++++++i5$?6+++++++++++++++++++++++++++++&n);
printf( %56%4 6@% 47Ai?B =C 6@% Di4DE% 4F);
scanf("f,'r);
a=(pi+r+r);
printf(++++++++++++++++++++++=?6$?6+++++++++++++++++++++++++++++&n);
printf(6@% 74%7 =C 7 Di4DE% iBF"f,a);
getch();
#
program to find the given number is 74,B64=5G number
>includeHstdio)h9
main()
{
int a,b,c,d,s,n;
clrscr();
printf(++++++++++++++++++++++++++i5$?6++++++++++++++++++++);
printf(%56%4 6@% 5?,:%4&n);
scanf("d,'n);
a=n3100;
b=n"100;
c=b"10;
d=b310;
s=a+a+a+c+c+c+d+d+d;
printf(+++++++++++++++++++++++++=?6$?6+++++++++++++++++++++++++++++);
printf(6@% !7E?% =C B iBF);
printf("d,s);
if(s==n)
printf(6@% %56%4%A 5= iB 74,B64=5G 5?,:%4&n);
else
printf(6@% %56%4%A 5= iB 5=6 75 74,B64=5G 5?,:%4&n);
getch();
#
program to go for a choice as follows
1 for add, 2 for sub, ( for mul, * for div, using if condition
>includeHstdio)h9
,usicalroc-s)t- $age 5
C Language Notes
>includeHmath)h9
main()
{
int a,b,p,ch;
float m;
clrscr();
printf(&n 1add);
printf(&n 2sub);
printf(&n (mul);
printf(&n *div);
printf(&n .mod div);
printf(&n enter two noIs);
scanf("d"d,'a,'b);
printf(&nenter choice);
scanf("d,'ch);
if(ch==1)
{
p=a+b;
printf("d,p);
#
if(ch==2)
{
p=a0b;
printf("d,p);
#
if(ch==()
{
p=a+b;
printf("d,p);
#
if(ch==*)
{
m=(float)a3b;
printf("f,m);
#
if(ch==.)
{
p=a"b;
printf("d,p);
#
getch();
#
program on magic numbers )after running the program show the number to an8 of
8our friend and the as- him to imagin an8 one of the number from 1 to 20 and as-
him to sa8 wheather the given number is in the list of stages )if he sa8 that the
number is in the first stage Just press enter a counter will count the magic number if
he sa8 the number is not in the stage 1 press onother -e8 in the -e8board )li-e this
repeat all the stages finall8 the imagined number is going to displa8 on the screen)
main()
{
int c=0;
char ch;
,usicalroc-s)t- $age 6
C Language Notes
clrscr();
printf(Btage 1F&n);
printf(1 ( . K L 11 1( 1. 1K 1L);
ch=getch();
if(ch==*L)
c=c+1;
clrscr();
printf(Btage 2F&n);
printf(2 ( M 10 1* 1. 1K);
ch=getch();
if(ch==*L)
c=c+2;
clrscr();
printf(Btage (F &n);
printf(* . M 11 1M 1N 1L);
ch=getch();
if(ch==*L)
c=c+*;
clrscr();
printf(Btage *F&n);
printf(K 11 1K 1N 1L 20);
ch=getch();
if(ch==*L)
c=c+M;
clrscr();
printf(Btage .F&n);
printf(N L 10 1K 1N 1L 20);
ch=getch();
if(ch==*L)
c=c+N;
clrscr();
printf(Btage MF&n);
printf(12 1( 1* 1. 1M 20);
ch=getch();
if(ch==*L)
c=c+12;
gotoO8(1*,1*);
printf( ?r number is "d,c);
getch();
#
u=total units
ah=above hundred ath=above three hundred
bh=below hundred at=above two hundred
00100units 0009.30
1000200units009.).30
2000(00units009M).30
(000*00units009K30
10030 will be charged for maintenance)
Cind the %lectricit8 bill for 2K.,2.0,(.0,(LLunits+3
main()
{
int u,ah,bh,ath,at;
,usicalroc-s)t- $age 7
C Language Notes
float a;
clrscr();
printf(%nter $rev units);
sanf("d,'pv);
printf(%nter current units);
scanf("d,cv);
u=cu=pv;
scanf("d,'u);
if(uH=100)
a=u+.+100;
if((u9100)''(uH=200))
{
ah=u0100;
bh=u0ah;
a=(ah+.).)+(bh+.)+100;
#
if((u9200)''(uH=(00))
{
at=u0200;
ah=100;
bh=u0(at+ah);
a=((at+M).)+(ah+.).)+(bh+.))+100;
#
if((u9(00)''(uH=*00))
{
ath=u0(00;
at=100;
ah=100;
bh=u0(ath+at+ah);
a=((ath+K)+(at+M).)+(ah+.).)+(bh+.))+100;
#
if(u9=*00)
a=(000;
printf( 6he total amout is ="f,a);
getch();
#
program using ternar8 operator
main()
{
int a,b,c;
printf(;%nter val for a and b &n<);
scanf(;"d"d<,','b);
c=(a9b)PaFb;
printf(;!al of c is "d<,c);
#
program on greatest of three numbers using ternar8 operator
main()
{
int a,b,c;
clrscr();
printf(;%nter val for a b and c&n<);
scanf(;"d"d"d<,'a,'b,'c);
,usicalroc-s)t- $age 8
C Language Notes
(a9b '' a9c) P printf(;7 is :ig<)F (b9a '' b9c)Pprintf(;: is :ig<)F (c9a '' c9b) P
printf(;D is :ig<)F (printf(;invalid input<);
#
program on greatest of three numbers using ternar8 operator
main()
{
int a,b,c,O;
clrscr();
printf(;%nter val for a b and c&n<);
scanf(;"d"d"d<,'a,'b,'c);
O=(a9b '' a9c)PaF(b9a '' b9c)PbF (c9'' c9b)PcFo;
printf(;!al of O is :iggest ;,O);
#
program to find even or odd of a given number
main()
{
int n;
printf(;%nter val for n &n<);
scanf(;"d<,'n);
(n"2==0)Pprintf(;%ven<)Fprintf(;=dd<);
#
program to find even or odd of a given number
main()
{
int n,O;
printf(;%nter val for n &n<);
scanf(;"d<,'n);
O=(n"2==0)P0F1;
(O==0)Pprintf(;%ven<)Fprintf(;=dd<);
#
$4=G47,B =5 BQi6D@ D7B%
$rogram to find the result of the following operations using the two values 1 for add 2
for sub ( for mul * for div
main()
{
int a,b,c,ch;
clrscr();
printf(;%nter val for a and b &n<);
scanf(;"d"d<,'a,'b);
printf(;7ccept 8our choice as &n<);
printf(;1 for addition 2 for substration ( for multiplication * for division &n<);
scanf(;"d<,'ch);
switch(ch)
{
case 1F
c=a+b;
brea-;
case 2F
,usicalroc-s)t- $age 9
C Language Notes
c=a0b;
brea-;
case (F
c=a+b;
brea-;
case *F
c=a3b;
brea-;
defaultF
printf(;invalid choice ;);
#
printf(<!al of c is "d<,c);
#
program to purchase soap in a super mar-et according to the following 1 for luO 2 for
liril ( for santoor * for fa
main()
{
int /t8,ch;
float rate,amt;
clrscr();
printf(;%nter 8our choice as 1 for luO 2 for liril
( for santoor * for fa&n<);
printf(;%nter 8our choice &n<);
scanf(;"d<,'ch);
printf(;@ow man8 soap 8ou need &n<);
scanf(;"d<,'/t8);
switch(ch)
{
case 1F
amt=1*).0+/t8;
brea-;
case 2F
amt=12)2.+/t8;
brea-;
case (F
amt=N)2.+/t8;
brea-;
case *F
amt=1K)..+/t8;
brea-;
defaultF
printf(;invalid choice ;);
#
printf(;7mount is "f<,amt);
#
$rogram to find the result of the following operations using the two values a for add s
for sub m for mul d for div
main()
{
char ch;
int a,b,c;
clrscr();
,usicalroc-s)t- $age 10
C Language Notes
printf(;%nter val for a and b &n<);
scanf(;"d"d<,'a,'b);
printf(;7ccept 8our choice as &n<);
printf(;1 for addition 2 for substration ( for multiplication * for division &n<);
scanf(;"c<,'ch);
switch(ch)
{
case RaSF
c=a+b;
brea-;
case RsSF
c=a0b;
brea-;
case RmSF
c=a+b;
brea-;
case RdSF
c=a3b;
brea-;
defaultF
printf(;invalid choice ;);
#
printf(<!al of c is "d<,c);
#
program to purchase soap in a super mar-et according to the following l for luO r for
reOona s for santoor f for fa
main()
{
char ch;
int /t8;
float rate,amt;
clrscr();
printf(;%nter 8our choice as l for luO r for reOona
s for santoor f for fa&n<);
printf(;%nter 8our choice &n<);
scanf(;"c<,'ch);
printf(;@ow man8 soap 8ou need &n<);
scanf(;"d<,'/t8);
switch(ch)
{
case RlSF
amt=1*).0+/t8;
brea-;
case RrSF
amt=12)2.+/t8;
brea-;
case RsSF
amt=N)2.+/t8;
brea-;
case RfSF
amt=1K)..+/t8;
brea-;
,usicalroc-s)t- $age 11
C Language Notes
defaultF
printf(;invalid choice ;);
#
printf(;7mount is "f<,amt);
#
program on piano using switch case %nter esc to eOit from this program
main()
{
int ch;
llF
ch=getch();
switch(ch)
{
case *LF
sound(100); brea-;
case 11(F
sound(200); brea-;
case .0F
sound((00); brea-;
case 11LF
sound(*00); brea-;
case .1F
sound(.00); brea-;
case 101F
sound(M00); brea-;
case .2F
sound(K00); brea-;
case 11*F
sound(N00); brea-;
case .(F
sound(L00); brea-;
case 11MF
sound(1000); brea-;
case .*F
sound(1100); brea-;
case 121F
sound(1200); brea-;
case ..F
sound(1(00); brea-;
case 11KF
sound(1*00); brea-;
case .MF
sound(1.00); brea-;
case 10.F
sound(1M00); brea-;
case .KF
sound(1K00); brea-;
case 111F
sound(1N00); brea-;
case *NF
sound(1L00); brea-;
case 112F
sound(2000); brea-;
,usicalroc-s)t- $age 12
C Language Notes
case *.F
sound(2100); brea-;
case L1F
sound(2200); brea-;
case M1F
sound(2(00); brea-;
case L(F
sound(2*00); brea-;
case 2KF
nosound();
eOit();
#
goto ll;
#
program to select the menu of a hotal in the following choice
main()
{
int ch,/t8;
float amt;
clrscr();
printf(;%nter 8our choice as &n<);
printf(;1 for idl8 2 for dosa &n<);
printf(;( for wada * for puri &n<);
scanf(;"d<,'ch);
printf(;%nter number of plates &n<);
scanf(;"d<,'/t8);
switch(ch)
{
case 1F
amt=M).0+/t8;
brea-;
case 2F
amt=12)(.+/t8;
brea-;
case (F
amt=K)K.+/t8;
brea-;
case *F
amt=L)M.+/t8;
brea-;
defaultF
printf(;invalid choice &n<);
#
printf(;7mout is "f<,amt);
#
program to find the length of a stirng using string function strlen
main()
{
char nm12=<anand<;
clrscr();
printf(;length of the string is "d<,strlen(nm));
#
,usicalroc-s)t- $age 13
C Language Notes
program to print a string in reverse format
main()
{
char nm12=<anand<;
clrscr();
printf(;4everse of the string is "s<,strrev(nm));
#
program to print a string in upper case
>includeHstring)h9
main()
{
char nm12=<anand<;
clrcsr();
printf(;"s<,strupr(nm));
#
program to print a string inlower case
>includeHstring)h9
main()
{
char nm12=<7575A<;
clrscr();
printf(;"s<,strlwr(nm));
#
program to cop8 a string from one variable to other
main()
{
char nm12=<anand<;
char nm11102;
clrscr();
strcp8(nm1,nm);
printf(;5eOt variable holds "s string <,nm1);
#
program to compare two strings
main()
{
char nm112=<anand<;
char mn1102;
printf(;%nter 8our string ;);
scanf(;"s<,nm);
if(strcmp(nm,nm1)==0)
printf(;:oth are same ;);
else
printf(;:oth are not e/ual<);
#
program to concatinate two strings
main()
{
char nm12=<anand<;
char nm112=<ambati<;
,usicalroc-s)t- $age 14
C Language Notes
printf(;"s<,strcat(nm,nm1));
#
program on puts and gets function
main()
{
char nm1202;
puts(;enter 8our name ;);
gets(nm);
puts(;8ou have entered<);
puts(nm);
#
program for difference between two funcations scanf and gets
main()
{
char nm1202;
printf(;%nter name ;);
scanf(;"s<,nm);
printf(;Tour name is "s&n<,nm);
puts(;%nter 8our complite name with intial<);
gets(nm);
printf(;Tour name is "s<,nm);
#
program on window funcation of conio)h
main()
{
clrscr();
teOtbac-ground(L);
window(2,*,22,22);
clreol();
printf(;@i and welcome to world of computers<);
#
program to get teOt in colour
main()
{
char nm12=<anand<;
clrscr();
teOtcolor(L);
cprintf(;the name is &n<);
cprintf(;"s<,nm);
#
program to get teOt bac-ground and fore ground in colors
main()
{
char nm12=<anand<;
clrscr();
teOtattr(*2();
cprintf(;@i and welcome to the world of comters<);
#
,usicalroc-s)t- $age 15
C Language Notes
program using goto label to print 1 to 10 numbers
main()
{
int i=1;
llF
printf(;"d&n<,i);
i++;
if(i9=10)
%Oit();
%lse
Goto ll;
#
program to print odd numbers using goto label
main()
{
int i=1;
llF
printf(;"d&n<,i);
i=i+2;
if(i9=10)
%Oit();
%lse
goto ll;
#
program to print even numbers using goto label
main()
{
int i=0;
llF
printf(;"d&n<,i);
i=i+2;
if(i9=10)
%Oit();
%lse
goto ll;
#
program to print sum of 1 to 10 numbers
main()
{
int i=1,sum;
llF
sum=sum+i;
i++;
if(i9=10)
{
printf(;Bum is "d<,sum);
%Oit();
#
%lse
Goto ll;
,usicalroc-s)t- $age 16
C Language Notes
#
program to add sumof even numbers
main()
{
int i=0,sum;
llF
sum=sum+i;
i=i+2;
if(i9=10)
{
printf(;Bum is "d<,sum);
eOit();
#
else
goto ll;
#
program to print sum of odd numbers
main()
{
int i=1,sum=0;
anandF
sum=sum+i;
i=i+2;
if(i9=10)
{
$rintf(;Bum of odd numbers is "d<,sum);
%Oit();
#
%lse
Goto anand;
#
program to print . 10 1. 20 UU).0
main()
{
int i=.;
OOF
printf(;"d&n<,i);
i=i+.;
if(i9=.0)
%Oit();
%lse
Goto OO;
#
program to print sum of . 10 1. 20 2. (0 (. *0 *. .0
main()
{
int i=.,sum=0;
abcF
sum=sum+il
,usicalroc-s)t- $age 17
C Language Notes
i=i+.;
if(i9=.0)
{
$rintf(;sumis "d<,sum);
%Oit();
#
%lse
Goto abc;
#
program to print 1 to 10 numbers using while loop
main()
{
int i=1;
clrscr();
while(iH=10)
{
printf(;"d&n<,i);
i++;
#
#
program to print 1 to 10 odd number using while loop
main()
{
int i=1;
clrscr();
whie(iH=10)
{
printf(;"d&n<,i);
i=i+2;
#
#
program to print 1 to 10 even numbers using while loop
main()
{
int i=0;
while(iH=10)
{
printf(;"d&n<,i);
i=i+2;
#
#
program to print sum of 1 to 10 odd numbers using while loop
main()
{
int i=1,sum=0;
clrscr();
while(iH=10)
{
sum=sum=i;
,usicalroc-s)t- $age 18
C Language Notes
i++;
#
printf(;Bum is "d<,sum);
#
program to print sum of 1 to 10 even numbers usin whle loop
main()
{
int i=1,sum=0;
clrscr();
while(iH=10)
{
sum=sum=i;
i++;
#
printf(;Bum is "d<,sum);
#
program to print 1 to 10 numbers using doU))while loop
main()
main()
{
int i=1;
clrscr();
do
{
printf(;"d&n<,i);
i++;
# while(iH=10);
#
program to print 1 to 10 odd number using do while loop
main()
{
int i=1;
clrscr();
do
{
printf(;"d&n<,i);
i=i+2;
# whie(iH=10);
#
program to print 1 to 10 even numbers using do while loop
main()
{
int i=0;
do
{
printf(;"d&n<,i);
i=i+2;
# while(iH=10);
,usicalroc-s)t- $age 19
C Language Notes
#
program to print sum of 1 to 10 odd numbers using do while loop
main()
{
int i=1,sum=0;
clrscr();
do
{
sum=sum=i;
i++;
# while(iH=10);
printf(;Bum is "d<,sum);
#
program to print sum of 1 to 10 even numbers using do while loop
main()
{
int i=0,sum=0;
clrscr();
do
{
sum=sum=i;
i++;
# while(iH=10);
printf(;Bum is "d<,sum);
#
program to print 1 to 10 numbers using for loop
main()
{
int i;
for(i=1;iH=10;i++)
{
printf(;"d&n<,i);
#
#
program to print 1 to 10 even numbers using for loop
main()
{
int i;
for(i=0;iH=10;i=i+2)
{
printf(;"d&n<,i);
#
#
program to print 1 to 10 odd numbers using for loop
main()
{
int i;
,usicalroc-s)t- $age 20
C Language Notes
for(i=1;iH=10;i=i+2)
{
printf(;"d&n<,i);
#
#
program to print sum of 1 to 10 odd numbers using for loop
main()
{
int i;
for(i=1;iH=10;i=i+2)
{
sum=sum+i;
#
printf(;Bum is "d<,sum);
#
program to print sum of 1 to 10 even numbers using for loop
main()
{
int i;
for(i=0;iH=10;i=i+2)
{
sum=sum+i;
#
printf(;Bum is "d<,sum);
#
program to find the factorial of a given number using while loop
main()
{
int fact=1,i=1;
clrscr();
printf(;%nter the number for which u need the factorail &n<);
scanf(;"d<,'n);
while(iH=n)
{
fact=fact+i;
i++;
#
printf(Rfactorail val of "d is "d<,n,fact);
#
program to find the factorial of a given number using do while loop
main()
{
int fact=1,i=1;
clrscr();
printf(;%nter the number for which u need the factorail &n<);
scanf(;"d<,'n);
do
{
,usicalroc-s)t- $age 21
C Language Notes
fact=fact+i;
i++;
# while(iH=n);
printf(Rfactorail val of "d is "d<,n,fact);
#
program to find the factorial of a given number using do while loop
main()
{
int fact=1,i=1;
clrscr();
printf(;%nter the number for which u need the factorail &n<);
scanf(;"d<,'n);
for(i=1;iH=n;i++)
{
fact=fact+i;
#
printf(Rfactorail val of "d is "d<,n,fact);
#
program to print mathamatical table of a given number using while loop
main()
{
int i=1,res,n;
printf(;%nter which table u need &n<);s
scanf(;"d<,'n);
while(iH=10)
{
res=n+i;
printf(;"d+"d="d<,n,i,res);
i++;
#
#
program to print mathamatical table of a given number using do while loop
main()
{
int i=1,res,n;
printf(;%nter which table u need &n<);s
scanf(;"d<,'n);
do
{
res=n+i;
printf(;"d+"d="d<,n,i,res);
i++;
# while(iH=10);
#
program to print mathamatical table of given number using for loop
main()
{
int i=1,res,n;
printf(;%nter which table u need &n<);s
,usicalroc-s)t- $age 22
C Language Notes
scanf(;"d<,'n);
for(i=1;iH=10;i++)
{
res=n+i;
printf(;"d+"d="d<,n,i,res);
#
#
program to print fibonicci series of given range using while loop
main()
{
int i=1,f1=0,f2=1,f(=0,n;
clrscr();
prntf(;%nter the range of the series&n<);
scanf(;"d<,'n);
while(iH=n)
{
printf(;"d&n<,f();
f1=f2;
f2=f(;
f(=f1+f2;
i++;
#
#
program to print fibonicci series of given range using do while loop
main()
{
int i=1,f1=0,f2=1,f(=0,n;
clrscr();
prntf(;%nter the range of the series&n<);
scanf(;"d<,'n);
do
{
printf(;"d&n<,f();
f1=f2;
f2=f(;
f(=f1+f2;
i++;
# while(iH=n);
#
program to print fibonicci series of given range using for loop
main()
{
int i=1,f1=0,f2=1,f(=0,n;
clrscr();
prntf(;%nter the range of the series&n<);
scanf(;"d<,'n);
for(i=1;iH=n;i++)
{
printf(;"d&n<,f();
,usicalroc-s)t- $age 23
C Language Notes
f1=f2;
f2=f(;
f(=f1+f2;
#
#
program to convert binar8 to decimal of a given number
main()
{
int i,n,bin1N2,r,bina1N2;
clrscr();
printf(%nter val for n&n);
scanf("d,'n);
for(i=0;iHn;i++)
{
r=n32;
bin1i2=n"2;
n=r;
printf("d,bin1i2);
#
for(i=0;iHn;i++)
{
bina1i2=bin1n010i2;
#
for(i=0;iHn;i++)
{
printf("d,bina1i2);
#
#
program to create a window using window funcation from conio)h
>includeHstdlib)h9
main()
{
char nm12=<anand<;
int i,J,-;
clrscr();
window(.,.,*(,2();
gotoO8(*0,12);
for(-=0;-H12;-++)
{
for(J=0;JH12;J++)
{
for(i=0;iHstrlen(nm);i++)
{
teOtcolor(i);
cprintf(;"s<,nm1i2);
dela8(LL);
teOtbac-ground(random(20));
#
#
#
#
,usicalroc-s)t- $age 24
C Language Notes
program to chec- the given number is plaendrome or not
main()
{
int n,m,r,s=0;
clrscr();
printf(%nter val for n&n);
scanf("d,'n);
m=n;
while(mV=0)
{
r=m"10;
s=s+10+r;
m=m310;
#
printf(reverse number is "d&n,s);
if(s==n)
printf(number is palendrome);
else
printf(5ot palendrome);
#
program tp find the sum of digits of number
main()
{
int n,sum=0,/;
printf(;%nter val for n&n<);
scanf(;"d<,'n);
while(n90)
{
/=n"10;
sum=sum+/;
n=n310;
#
printf(;sum is "d<,sum);
#
proram to find wheather the given number is plendrome or not
main()
{
int /,sum=0,n,t;
printf(%nter val for n&n);
scanf("d,'n);
t=n;
while(n90)
{
/=n"10;
sum=sum+10+/;
n=n310;
#
if(sum==t)
printf($alandrome);
else
,usicalroc-s)t- $age 25
C Language Notes
printf(not a palandrome);
#
program on pascal trianlge
main()
{
int binom,p,/,r,O;
binom=1;
/=0;
printf(%nter how man8 row u need &n);
scanf("d,'p);
while(/Hp)
{
for(r=*00(+/;r90;r00)
printf( );
for(O=0;OH=/;++O)
{
if((O==0)WW(/==0))
binom=1;
else
binom=(binom+(/0O+1))3O;
printf("Md,binom);
#
printf(&n);
++/;
# #
program to verif8 the given number is prime or not
main()
{
int n,i,cnt=0;
printf(%nter val for n &n);
scanf("d,'n);
for(i=2;iH=n01;i++)
{
if(n"i==0)
cnt=cnt+1;
#
if(cnt==0)
printf(prime);
else
printf(5ot prime);
#
progrm to find the ED,
main()
{
int a,b,c=2, -=1,d;
printf(%nter three number s&n);
scanf("d"d"d,'a,'b,'d);
do
,usicalroc-s)t- $age 26
C Language Notes
{
if((a"c==0)WW(b"c==0)WW(d"c==0))
{
-=c+-;
if(a"c==0)a=a3c;
if(b"c==0)b=b3c;
if(d"c==0)d=d3c;
#
else
c++;
#
while((cH=a)WW(cH=b)WW(cH=d));
printf(ED, is "d,-);
#
program to displa8 prime number series
main()
{
int n1,n2,i,J;
printf(;%nter values for n1 and n2<);
scanf(;"d"d<,'n1,'n2);
for(i=n1;iH=n2;i++)
{
for(J=2;JH=i1;J++)
{
if(i"J==0)
brea-;
else
if(J==i01)
printf(;"d&n<,i);
#
#
#
program to print the format chec- the program
main()
{
char nm1102;
int i,J,len,-=0;
clrscr();
printf(%nter name &n);
scanf("s,nm);
len=strlen(nm);
for(i=0;iH=len;i++)
{
printf(&n);
for(J=0;JHlen0-;J++)
printf("c,nm1J2);
for(J=0;JH2+-;J++)
printf( );
for(J=len010-;J9=0;J00)
printf("c,nm1J2);
-++;
#
,usicalroc-s)t- $age 27
C Language Notes
#
program to sum the digits of a number
main()
{
n,sum=0,/;
printf(%nter val for n&n);
scanf("d,'n);
while(n90)
{
/=n"10;
sum=sum+/;
n=n310;
#
printf(Bum is "d,sum);
#
program to print range of mathamitical table using for loop
main()
{
int i,J,res,st,end;
clrscr();
printf(;%nter val for st &n<);
scanf(;"d<,'st);
printf(;%nter val for end &n<);
scanf(;"d<,'end);
for(i=st;iH=end;i++)
{
for(J=1;JH=10;J++)
{
res=st+i;
printf(;"d+"d="d&n<,st,i,res);
#
st++;
getch();
#
#
program to print range of mathamitical table using while loop
main()
{
int ,res,st,end,J=1;
clrscr();
printf(;%nter val for st &n<);
scanf(;"d<,'st);
printf(;%nter val for end &n<);
scanf(;"d<,'end);
while(stH=end)
{
i=1;
while(iH=10)
{
res=st+i;
,usicalroc-s)t- $age 28
C Language Notes
printf(;"d+"d="d<,st,i,res);
i++;
#
st++;
#
#
program to add all the elements in arra8 a1.2
main()
{
int a1.2,i,sum=0;
clrscr();
printf(;%nter arra8 elements &n<);
for(i=0;iH.;i++)
{
scanf(;"d<,'a1i2);
#
for(i=0;iH.;i++)
{
sum=sum+a1i2;
#
printf(;Bum is "d<,sum);
#
program on addition of two arra8 and storing the result in the third arra8
main()
{
int a1.2={*,(,.,M,2#;
int b1.2={M,N,K,L,1#;
int c1.2,i;
clrscr();
for(i=0;iH.;i++)
{
c1i2=a1i2+b1i2;
printf(;"d&t<,c1i2);
#
#
program to find biggest element in arra8
main()
{
int a1.2,i,big=0;
clrscr();
printf(;%nter element in arra8 &n<);
for(i=0;iH.;i++)
{
scanf(;"d<,'a1i2);
#
for(i=0;iH.;i++)
{
if(a1i29big)
big=a1i2;
#
printf(;:iggest element is "d<,big);
#
,usicalroc-s)t- $age 29
C Language Notes
program to find smallest element in arra8
main()
{
int a1.2,i,small;
clrscr();
printf(;%nter element in arra8 &n<);
for(i=0;iH.;i++)
{
scanf(;"d<,'a1i2);
#
for(i=0;iH.;i++)
{
if(a1i2Hsmall)
small=a1i2;
#
printf(;smallest element is "d<,small);
#
program to sort the elements in decending order
main()
{
int a1.2={*,.,K,M,2,N#;
int i,J,temp;
clrscr();
for(i=0;iH.;i++)
{
for(J=0;JH.;J++)
{
if(a1i29a1J2)
{
temp=a1i2;
a1i2=a1J2;
a1J2=temp;
#
#
#
printf(;%lements after sorting &n<);
for(i=0;iH.;i++)
{
printf(;"d&t<,a1i2);
#
program to sort the elements in ascending order
main()
{
int a1.2={*,.,K,M,2,N#;
int i,J,temp;
clrscr();
for(i=0;iH.;i++)
{
for(J=0;JH.;J++)
{
,usicalroc-s)t- $age 30
C Language Notes
if(a1i2Ha1J2)
{
temp=a1i2;
a1i2=a1J2;
a1J2=temp;
#
#
#
printf(;%lements after sorting &n<);
for(i=0;iH.;i++)
{
printf(;"d&t<,a1i2);
#
program to replace a selected element from the list of arra8
main()
{
int rep,fnd,i,J;
int a1.2={N,K,.,L,(#;
clrscr();
printf(;%nter element to find&n<);
scanf(;"d<,'fnd);
printf(R%nter element to replace &n<);
scanf(;"d<,'rep);
for(i=0;iH.;i++)
{
if(a1i2==fnd)
a1i2=rep;
#
printf(;7fter replacing the elements are &n<);
for(i=0;iH.;i++)
{
printf(R<"d&t<,a1i2);
#
#
program to delete a element in the arra8 list
main()
{
int fnd,i;
int a1.2={N,.,*,L,K#;
clrscr();
printf(;%nter element to find &n<);
scanf(;"d<,'fnd);
for(i=0;iH.;i++)
{
if(a1i2==fnd)
a1i2==0;
#
printf(;7fter deleting the element the arra8 list &n<);
for(i=0;iH.;i++)
{
printf(;"d&t<,a1i2);
#
,usicalroc-s)t- $age 31
C Language Notes
#
program to accept double dimension arra8 and displa8 the sum of all the elements
main()
{
int a1(21(2,i,J,sum=0;
clrscr();
printf(;%nter arra8 element &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'a1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
sum=sum+a1i21J2;
#
#
printf(;Bum of all the elements in the arra8 is "d<,sum);
#
program to add the elements of the two double dimension arrra8 and displa8 the
result in the third arra8
main()
{
int a1(21(2={{2,*,(#,{*,.,K#,{K,M,N##;
int b1(21(2={{*,M,(#,{M,N,.#,{*,M,N##;
int c1(21(2;
int i,J,sum=0;
clrscr();
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
c1i21J2=a1i21J2+b1i21J2;
#
#
printf(;6he resultant arra8 is &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,c1i21J2);
#
printf(;&n<);
#
#
program to find the biggest elenemt in a double dimension arra8
main()
,usicalroc-s)t- $age 32
C Language Notes
{
int a1(21(2;
int i,J,big=0;
clrscr();
printf(;%nter elements in arra8 &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'a1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(a1i29big)
big=a1i21J2;
#
#
printf(;6he biggest element is "d<,big);
#
program to find the smallest elenemt in a double dimension arra8
main()
{
int a1(21(2;
int i,J,small;
clrscr();
printf(;%nter elements in arra8 &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'a1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(a1i29small)
small=a1i21J2;
#
#
printf(;6he smallest element is "d<,small);
#
program to sort in decending order
main()
{
int a1(21(2={{*,M,.#,{2,(,*#,{M,N,K##;
int i,J,temp;
clrscr();
for(i=0;iH(;i++)
,usicalroc-s)t- $age 33
C Language Notes
{
for(J=0;JH(;J++)
{
for(-=0;-H(;-++)
{
for(l=0;lH(;l++)
{
if(a1i21J29a1-21l2)
{
tempa=1i21J2;
a1i21J2=a1-21l2;
a1-21l2=temp;
#
#
#
#
#
printf(;7fter sorting &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,a1i21J2);
#
printf(;&n<);
#
#
program to sort in ascending order
main()
{
int a1(21(2={{*,M,.#,{2,(,*#,{M,N,K##;
int i,J,temp;
clrscr();
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
for(-=0;-H(;-++)
{
for(l=0;lH(;l++)
{
if(a1i21J2Ha1-21l2)
{
tempa=1i21J2;
a1i21J2=a1-21l2;
a1-21l2=temp;
#
#
#
#
#
printf(;7fter sorting &n<);
for(i=0;iH(;i++)
,usicalroc-s)t- $age 34
C Language Notes
{
for(J=0;JH(;J++)
{
printf(;"d&t<,a1i21J2);
#
printf(;&n<);
#
#
program to displa8 the lower triangle of arra8
main()
{
int a1(21(2={{,K,.,*#,{*,.,M#,{K,.,N##;
int i,J;
clrscr();
printf(;Eower triangle is &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(i9=J)
printf(;"d&t<,a1i21J2);
#
#
printf(;&n<);
#
program to displa8 the upper triangle of arra8
main()
{
int a1(21(2={{,K,.,*#,{*,.,M#,{K,.,N##;
int i,J;
clrscr();
printf(;upper triangle is &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(iH=J)
printf(;"d&t<,a1i21J2);
#
#
printf(;&n<);
#
program to find element in arra8 and relpace it with other element
main()
{
int a1(21(2={{,K,.,*#,{*,.,M#,{K,.,N##;
int i,J,fnd,rep;
printf(;%nter element to find &n<);
scanf(;"d<,'fnd);
printf(;%nter element to replace &n<);
,usicalroc-s)t- $age 35
C Language Notes
scanf(;"d<,'rep);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(a1i21J2==fnd)
a1i21J2=rep;
#
#
printf(;7fter replacing the elements are &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,a1i21J2);
#
printf(;&n<);
#
#
program to delete an element in arra8
main()
{
int a1(21(2={{.,(,M#,{2,*,(#,{M,L,*##;
int i,J,fnd;
clrscr();
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(a1i21J2==fnd)
a1i21J2=o;
#
#
printf(;7fter deleting element&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,a1i1J2);
#
printf(;&n<);
#
#
program multipl8 two arra8s and store the result in third arra8
main()
{
int a1(21(2 , b1(21(2;
int c1(21(2,i,J,-;
clrscr();
printf(;%nter elements in arra8 7&n<);
for(i=0;iH(;i++){
for(J=0;JH(;J++)
,usicalroc-s)t- $age 36
C Language Notes
{
scanf(;"d<,'a1i21J2);
#
#
printf(;%nter arra8 :&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'b1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
c1i21J2=0;
for(-=0;-H(;-++)
{
c1i21J2=c1i21J2+(a1i21-2+b1-21J2);
#
#
#
printf(;%lement after calculating &n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,c1i21J2);
#
printf(&n<);
#
#
program to tronspose a matriO
>includeHstdio)h9
main()
{
int i,J,a1(21(2,b1(21(2;
clrscr();
printf(;%mter arra8 elements&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf("d,'a1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
b1i21J2=a1J21i2;
#
,usicalroc-s)t- $age 37
C Language Notes
#
printf(transpose of a matriO);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf("d&t,b1i21J2);
#
printf(&n);
#
getch();
#
program on arra8 to displa8 weather the given matriO is s8mmetric or not
main()
{
int i,J,flag;
int b1(21(2;
int a1(21(2={{2,(,*#,{*,.,M#,{2,*,M##;
clrscr();
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
if(a1i21J2V=b1i21J2)
flag=1;
#
#
if(flag)
printf(5ot s8mmetric );
else
printf(B8mmetric );
#
program to norm the martiO
main()
{
int a1(21(2,i,J,sum=0;
float norm;
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'a1i21J2);
sum=sum+a1i21J2+a1i21J2;
#
#
norm=(float)s/rt(sum);
printf(;5orm of a matriO is "d<,norm);
#
,usicalroc-s)t- $age 38
C Language Notes
program to demonstrate the t8pes of functions
1++
main()
{
add();
#
add()
{
int a=10,b=20,c;
c=a+b;
printf(;!al of c is "d<,c);
#
method 2++
main()
{
int a=10,b=20;
void add(int,int);
add(a,b);
#
add(int O,int 8)
{
int X;
X=O+8;
printf(;val of X is "d<,X);
#
method (++
main()
{
int c;
int add();
c=add();
printf(;!al of c is "d<,c);
#
int add()
{
int a=10,b=20,c;
c=a+b;
return( c );
#
method *++
main()
{
int a=10,b=20,c;
int add(int,int);
c=add(a,b);
printf(;val of c is "d<,c);
#
int add(int O,int 8)
{
,usicalroc-s)t- $age 39
C Language Notes
int X;
X=O+8;
return( X );
#
different sample
main()
{
int a=10,b=20,c;
int add(int,int)
c=add(a,b);
printf(;val of c is "d<,c);
#
int add(int O,int 8)
{
return( O+8 );
#
program to swap two numbers
main()
{
swap();
#
swap()
{
int a=10,b=20,temp;
temp=a;
a=b;
b=temp;
printf(;values after swaping are "d and "d<,a,b);
#
proram on swap
main()
{
int a=10,b=20;
void swap(int,int);
swap(a,b);
printf(;after swaping the values are "d and "d<,a,b);
#
swap(int O,int 8)
{
int temp;
temp=O;
O=8;
8=temp;
#
program on function to displa8 factorial val ue
main()
{
facto();
#
facto()
{
,usicalroc-s)t- $age 40
C Language Notes
int n,i=1,fact=1;
printf(;%nter val for n&n<);
scanf(;"d<,'n);
while(iH=n)
{
fact=fact+i;
i++;
#
printf(;factorial val is "d<,fact);
#
program on function to displa8 the factorial value
main()
{
int n;
void facto(int);
clrscr();
printf(;%nter val for n&n<);
scanf(;"d<,'n);
facto(n);
#
facto(int O)
{
int fact=1,i=1;
do
{
fact=fact+i;
i++;
#while(iH=O);
printf(;factorial val is "d<,fact);
#
program on function to displa8 the fatorial value
main()
{
long f;
long facto();
f=facto();
printf(;factoiral is "ld<,fact);
#
long facto()
{
long n,fact=1;
int i;
printf(;%nter val for n&n<);
scanf(;"ld<,'n);
for(i=1;iH=n;i++)
{
fact=fact+i;
#
return(fact);
#
,usicalroc-s)t- $age 41
C Language Notes
program on function displa8 the factorial value
main()
{
long f,n;
long facto(long);
clrscr();
printf(;%nter val for n &n<);
scanf(;"ld<,'n);
f=facto(n);
printf(;Cactorial val is "ld<,fact);
#
long facto(long O)
{
long fact=1;
int i;
for(i=1;iH=O;i++)
{
fact=fact+i;
#
return(fact);
#
program on function displa8 the fibonicci series
main()
{
fibo();
#
fibo()
{
int n,i,f1=0,f2=1,f(=0;
clrscr();
for(i=1;iH=n;i++)
{
printf(;"d&n<,f();
f1=f2;
f2=f(;
f(=f1+f2;
#
#
program on functions displa8 the fibonicci series
main()
{
int n;
void fibo(int);
printf(;%nter val for n&n<0;
scanf(;"d<,'n);
fibo(n);
#
fibo(int O)
{
,usicalroc-s)t- $age 42
C Language Notes
int i,f1=0,f2=1,f(=0;
clrscr();
for(i=0;iHO;i++)
{
printf(;"d&n<,f();
f1=f2;
f2=f(;
f(=f1+f2;
#
#
program on functions mathamatical table
main()
{
void matYtable();
matYtable();
#
void matYtable()
{
int n,i,res;
clrscr();
printf(;%nter val for n &n<);
scanf(;"d<,'n);
for(i=1;iH=10;i++)
{
res=n+i;
printf(;"d+"d="d<,n,i,res);
#
#
proram on functions displa8 the mathamatical table
main()
{
int n;
void matYtable(int);
printf(;%nter val for n &n<);
scanf(;"d<,'n);
matYtable(n);
#
void matYtable(int O)
{
int res,i;
for(i=1;iH=10;i++)
{
res=O+i;
printf(;"d+"d="d&n<,O,i,res);
#
#
program on function to dipla8 the factoiral value using recursion mathod
main()
{
,usicalroc-s)t- $age 43
C Language Notes
int O,8;
int facto(int);
printf(;%nter val for O &n<);
scanf(;"d<,'O);
8=facto(O);
printf(;!al is "d<,8);
#
int facto(int n)
{
int fact;
if((n==1)WW(n==0))
return(1);
else
{
fact=n+facto(n01);
#
return(fact);
#
program to disp what is pointer and displa8 the value of a variable anf value of a
variable using pointer
main()
{
int a=10,+b;
printf(;val of a is "d&n<,a);
printf(;7ddress of a is "d&n<,'a);
b='a;
printf(;!al of b is "d&n<,b);
printf(;7ddress of b is "d&n<,'b);
printf(;!al of b becomes "d when we place a pointer<,+b);
#
porgram on pointer to add two numbers
main()
{
int a=10,b=20,+aa,+bb,c;
aa='a;
bb='b;
c=+aa++bb;
printf(;!al of c is "d<,c);
#
program on pointer using arra8 and displa8 the sum of arra8 elements
main()
{
int a1.2={2,*,.,M,(#;
int i,J,sum=0,+p;
clrscr();
p='a;
for(i=0;iH.;i++)
{
sum=sum++p++;
#
printf(Bum is "d,sum);
,usicalroc-s)t- $age 44
C Language Notes
#
program on pointer to swap two numbers
main()
{
int a=10,b=20;
swap('a,'b);
#
swap(int +a,int +b)
{
int temp;
temp=a;
a=b;
b=temp;
printf(;!al of a and b are "d and "d<,a,b);
#
prorgam on pointer to add two arrra8 and store the result in the third arra8
main()
{
int a1.2={2,*,.,M,(#;
int b1.2={*,(,.,M,K#;
int c1.2,i,+pp,+//;
clrscr();
pp='a;
//='b;
for(i=0;iH.;i++)
{
c1i2=+pp++ + +//++
printf("d&t,c1i2);
#
#
program on pointer to displa8 the biggest of arra8 elements
main()
{
int a1.2={2,*,.,M,(#;
int i,+pp,big=0;
clrscr();
pp='a;
for(i=0;iH.;i++)
{
if(+pp++9big)
big= +pp++;
#
printf(:iggest element is "d,big);
#
program on pointer to add two double dim arra8 and store the result in the third
arra8
main()
{
int a1(21(2={{1N,10,1L#,{1N,K1,1M#,{1.,1*,(1##;
,usicalroc-s)t- $age 45
C Language Notes
int i,J,+pp,sum=0;
pp='a;
clrscr();
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
sum=sum++pp++;
#
#
printf(Bum is "d,sum);
#
program to displa8 the fatorial of a given number using using functions and pointers
with (call b8 refernce)
main()
{
int fact=1,n,i;
clrscr();
printf(;%nter val for n &n<);
scanf(;"d<,'n);
facto('n);
#
facto(int +p)
{
int fact=1,i=1;
while(iH=+p)
{
fact=fact+i;
i++;
#
printf(;Cactorial val is "d<,fact);
#
program on structure to displa8 the sum of two globel variables
struct 7:D
{
int a,b;
#;
main()
{
struct 7:D O8X;
int c;
O8X)a=10;
O8X)b=20;
c=O8X)a+O8X)b;
printf(;!al of c is "d<,c);
#
program on structure to add two numbers
struct ZT[
{
,usicalroc-s)t- $age 46
C Language Notes
int a,b;
#;
main()
{
struct ZT[ OO;
int c;
printf(;%nter val for a&n<);
scanf(;"d<,'OO)a);
printf(;%nter val for b &n<);
scanf(;"d<,'OO)b);
c=OO)a+OO)b;
printf(;!al of c is "d<,c);
#
program on structure to displa8 the sumof two numbers
struct 7575A
{
int a,b;
#;
main()
{
struct 7575A aaa;
aaa)a=10;
aaa)b=20;
if(aaa)a9aaa)b)
printf(;!7E of a is :ig<);
else
printf(;!al of b is big<);
#
program on structure to calculate the student details and displa8 the result
struct B6A
{
int rno,m,p,c,tot;
float avg;
char nm1102;
#;
main()
{
struct B6A ss;
clrscr();
printf(;%nter roll number &n<);
scanf(;"d<,'ss)rno);
printf(;%nter 5ame &n<);
scanf(;"s<,ss)nm);
printf(;%nter mar-s &n<);
scanf(;"d"d"d<,'ss)m,'ss)p,'ss)c);
ss)tot=ss)m+ss)p+ss)c;
ss)avg=ss)tot3(;
printf(;Btudent name is "s&n<,ssnm);
printf(;6otal is "d&n<,ss)tot);
printf(;7verage is "f&n<,ss)avg);
#
,usicalroc-s)t- $age 47
C Language Notes
program on structure to displa8 the eplo8ee details
struct %,$
{
int eno;
char nm1102;
float bs,hra,da,ta,net;
#ee;
main()
{
printf(;%nter emplo8ee number &n<);
scanf(;"d<,'ee)eno);
printf(;%nter name of the emplo8ee &n<);
scanf(;"s<,ssnm);
printf(;%nter basic pa8 &n<);
scanf(;"f<,'ee)bs);
ee)hra=ee)bs+(03100;
ee)da=ee)bs+203100;
ee)ta=ee)bs+103100;
ee)net=ee)bs+ee)hra+ee)da+ee)ta;
printf(;5et amount is "f&n<,ee)net);
#
program on structure to add two arra8 and displa8 the result
struct 744
{
int a1.2,b1.2,c1.2;
#;
main()
{
struct 744 ar;
int i;
clrscr();
printf(;%nter arra8 7&n<);
for(i=0;iH.;i++)
{
scanf(;"d<,'ar)a1i2);
#
printf(;%nter arra8 : &n<);
for(i=0;iH.;i++)
{
scanf(;"d<,'ar)b1i2);
#
for(i=0;iH.;i++)
{
ar)c1i2=ar)a1i2+ar)b1i2;
#
printf(;%nter vals for resultant arra8 are &n<);
for(i=0;iH.;i++)
{
printf(;"d&t<,ar)c1i2);
#
#
,usicalroc-s)t- $age 48
C Language Notes
proram on structure to add two double dim arra8s
struct 744
{
int a1(21(2,b1(21(2,c1(21(2;
#;
main()
{
struct 744 ar;
int i,J,-;
clrscr();
printf(;%nter arra8 7&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'ar)a1i21J2);
#
#
printf(;%nter arra8 :&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
scanf(;"d<,'ar)b1i21J2);
#
#
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
ar)c1i21J2=0;
for(-=0;-H(;-++)
{
ar)c1i21J2=ar)c1i21J2+(ar)a1i21-2+ar)b1-21J2);
#
#
#
printf(;6he resultant arra8 is&n<);
for(i=0;iH(;i++)
{
for(J=0;JH(;J++)
{
printf(;"d&t<,ar)c1i21J2);
#
printf(;&n<);
#
#
program on structure using pointers
struct B6A
{
int rno,m,p,c,tot;
float avg;
#;
,usicalroc-s)t- $age 49
C Language Notes
main()
{
struct B6A pp;
struct B6A +ss;
ss='pp;
printf(;%nter mar-s &n<);
scanf(;"d"d"d<,'ss09m,'ss09p,'ss09c);
ss09tot=ss09m+ss09p+ss09c;
ss09avg=ss09tot3(;
printf(;6otal is "d&n<,ss09tot);
printf(;7verage is "f&n<,ss09avg);
#
program on structure to calculate emplo8ee details using pointers
struct %,$
{
int eno;
float bs,hra,da,ta,net;
#;
main()
{
struct %,$ ee;
struct %,$ +pp;
pp='ee;
printf(;%nter emplo8ee number &n<);
scanf(;"d<,'pp09eno);
printf(;%nter emplo8ee basic pa8 &n<);
scanf(;"f<,'pp09bs);
ee09hra=ee09bs+(03100;
ee09da=ee09bs+203100;
ee09ta=ee09bs+103100;
ee09net=ee09hra+ee09da+ee09ta+ee09bs;
printf(;%mplo8ee net amount is "f&n<,ee09net);
#
SMS:-
ON JNTU_O!L"
To
9870807070
,usicalroc-s)t- $age 50
C Language Notes
#$s$t:-%%%&'ntu()*&t+
,usicalroc-s)t- $age 51

Das könnte Ihnen auch gefallen