Sie sind auf Seite 1von 80

Write a c program to evaluate the following series .

Assume suitable values


for x.
Y=1+x2/2!+x/!+x!/!!+""upto 1# terms
$inclu%e&st%io.h'
$inclu%e&conio.h'
$inclu%e&math.h'
voi% main()
*
int i+n+x,
float t+s,
clrscr(),
printf(-enter the value of .+n /n-),
scanf(-0%0%-+1x+1n),
t=1,
s=1,
for (i=1,i&=n21,i++)
*
t=((pow(x+2)3(t3i))/((23i)3((23i21)3i)),
s=s+t,
printf(-s=0!.f 1 t=0!.2f/n-+s+t),
4
printf(-/n sum of the series=05.f/n-+s),
getch(),
4
67897A: ;8 <=>? ;@A BC: 8< ;@A B=>A BA7=AB
D2DE/E!+D5/5!2DF/F!+""
$inclu%e&st%io.h'
$inclu%e&math.h'
voi% main()
*
int i = 2+ n+ s = 1+ x+ pwr = 1+ %r=1,
float nr = 1+ x1+ sum,
clrscr(),
printf(-/n/n/t A>;A7 ;@A A>9GA...H -),
scanf(-0%-+ 1x),
x1 = E.12 3 (x / 1I#.#),
sum = x1,
printf(-/n/t A>;A7 ;@A >C:JA7 8< ;A7:B...H -),
scanf(-0%-+ 1n),
while(i &= n)
*
pwr = pwr + 2,
%r = %r 3 pwr 3 (pwr 2 1),
sum = sum + (nr / %r) 3 s,
s = s 3 (21),
nr = nr 3 x1 3 x1,
i+= 2,
4
printf(-/n/t ;@A BC: 8< ;@A B=>A BA7=AB =B..H 0#.Ef-+sum),
getch(),
4
/3 Write a K program to accept two matrices an% 3 3 fin% the sum an%
%ifference of the matrices 3/
$inclu%e &st%io.h'
$inclu%e &st%lib.h'
int AL1#ML1#M+ JL1#ML1#M+ sumatL1#ML1#M+ %iffmatL1#ML1#M,
int i+ N+ 71+ K1+ 72+ K2,
voi% main()
*
/3 <unction %eclarations 3/
voi% rea%matA(),
voi% printmatA(),
voi% rea%matJ(),
voi% printmatJ(),
voi% sum(),
voi% %iff(),
printf(-Anter the or%er of the matrix A/n-),
scanf(-0% 0%-+ 171+ 1K1),
printf(-Anter the or%er of the matrix J/n-),
scanf(-0% 0%-+ 172+1K2),
if( 71 != 72 11 K1 != K2)
*
printf(-A%%ition an% subtraction are not possible/n-),
exit(1),
4
else
*
printf(-Anter the elements of matrix A/n-),
rea%matA(),
printf(-:A;7=D A is/n-),
printmatA(),
printf(-Anter the elements of matrix J/n-),
rea%matJ(),
printf(-:A;7=D J is/n-),
printmatJ(),
sum(),
%iff(),
4
4 /3 main() 3/
/3 <unction to rea% a matrix A 3/
voi% rea%matA()
*
for(i=#, i&71, i++)
*
for(N=#, N&K1, N++)
*
scanf(-0%-+1ALiMLNM),
4
4
return,
4
/3 <unction to rea% a matrix J 3/
voi% rea%matJ()
*
for(i=#, i&72, i++)
*
for(N=#, N&K2, N++)
*
scanf(-0%-+1JLiMLNM),
4
4
4
/3 <unction to print a matrix A 3/
voi% printmatA()
*
for(i=#, i&71, i++)
*
for(N=#, N&K1, N++)
*
printf(-0E%-+ALiMLNM),
4
printf(-/n-),
4
4
/3 <unction to print a matrix J 3/
voi% printmatJ()
*
for(i=#, i&72, i++)
*
for(N=#, N&K2, N++)
*
printf(-0E%-+JLiMLNM),
4
printf(-/n-),
4
4
/3<unction to fin% the sum of elements of matrix A an% :atrix J3/
voi% sum()
*
for(i=#, i&71, i++)
*
for(N=#, N&K2, N++)
*
sumatLiMLNM = ALiMLNM + JLiMLNM,
4
4
printf(-Bum matrix is/n-),
for(i=#, i&71, i++)
*
for(N=#, N&K2, N++)
*
printf(-0E%-+sumatLiMLNM) ,
4
printf(-/n-),
4
return,
4 // sum
/3<unction to fin% the %ifference of elements of matrix A an% :atrix J3/
voi% %iff()
*
for(i=#, i&71, i++)
*
for(N=#, N&K2, N++)
*
%iffmatLiMLNM = ALiMLNM 2 JLiMLNM,
4
4
printf(-?ifference matrix is/n-),
for(i=#, i&71, i++)
*
for(N=#, N&K2, N++)
*
printf(-0E%-+%iffmatLiMLNM),
4
printf(-/n-),
4
return,
4
/322222222222222222222222228utput
Anter the or%er of the matrix A 2 2
Anter the or%er of the matrix J 2 2
Anter the elements of matrix A 1 2 E
:A;7=D A is 1 2 E
Anter the elements of matrix J 2 ! I
:A;7=D J is 2 ! I
Bum matrix is E ! O 12
?ifference matrix is 21 22 2E 2
222222222222222222222222222222222222222222222222222223/
Write a program in K to multiplP two matricesQ
$inclu%e&st%io.h'
$inclu%e&conio.h'
voi% main()
* // main
int aL1#ML1#M+bL1#ML1#M+cL1#ML1#M+m+n+p+R+i+N+x,
clrscr(),
printf(-Anter row an% column of 1st matrix/n-),
scanf(-%-+1m+1n),
printf(-enter row an% column of 2n% matrix/n-),
scanf(-%-+1p+1R),
if(m==R) //K@AKS=>9 8< :CG;=6G=K=;Y
*
printf(-matrices can be multiplie%/n-),
printf(-resultant matrix is 0% 0%/n-+m+p),
printf(-Anter elements of 1st matrix/n-),
for(i=#,i&m,i++)
*
for(N=#,N&n,N++)
*
scanf(-0%-+1aLiMLNM),
4
4
printf(-Anter elements of 2n% matrix/n-),
for(i=#,i&p,i++)
*
for(N=#,N&R,N++)
*
scanf(-0%-+1bLiMLNM),
4
4
// :CG;=6G=KA;=8> 8< :A;7=KAB
for(i=#,i&m,i++)
*
for(N=#,N&p,N++)
*
cLiMLNM=#,
for(x=#,x&p,x++)
*
cLiMLNM=cLiMLNM+(aLiMLxM3bLxMLNM),
4
4
4
printf(-the resultant matrixH/n-), H67=>;=>9 7ABCG;
for(i=#,i&m,i++)
*
for(N=#,N&R,N++)
*
printf(- 05% -+cLiMLNM),
printf(-/n-),
4
4
4 //if
else
*
printf(-matrices cannot be a%%e%/ncolumn of 1st matrix shoul% be eRual to
row of 2n% matrix-),
4
getch(),
4 //main
/3Kprogram to a%%+ subtract an% multiplP two complex numbers
int main (voi%)
*
int aTreal+aTimaginarP+N,
int bTreal+bTimaginarP,
int complexTnumber,
char enterToperator,
printf (-a real = -),
scanf (-0%-+1aTreal),
printf (-a imaginarP = -),
scanf (-0%-+1aTimaginarP),
printf (-b real = -),
scanf (-0%-+1bTreal),
printf (-b imaginarP = -),
scanf (-0%-+1bTimaginarP),
printf (-Anter operator = -),
scanf (-0c-+1enterToperator),
if (enterToperator == U+U)
complexTnumber = (aTreal+bTreal)+N(aTimaginarP+bTimaginarP),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U2U),
complexTnumber = (aTreal2bTreal)+N(aTimaginarP2bTimaginarP),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U/U),
complexTnumber = ((aTreal3bTreal+aTimaginarP3bTimaginarP)/
(bTreal3bTreal)+(bTimaginarP3bTimaginarP))+N((aTimaginarP3bTreal2
aTreal3bTimaginarP)/(bTreal3bTreal+bTimaginarP3bTimaginarP)),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U3U),
complexTnumber = ((aTreal3bTreal)2(aTimaginarP3bTimaginarP))
+N((aTreal3bTimaginarP)+(aTreal3bTreal)),
printf (-/ncomplex number is 0%/n-+complexTnumber),
return #,
4
@ow to write a K program to perform matrix multiplication using pointerQ
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p,q;
printf("Enter The o!" #nd $%o&mn" #nd 'f The (ir"t )atri*+");
"canf(",d ,d",-m,-n);
printf(".nEnter The o!" #nd $%o&mn" #nd 'f The /econd )atri*+");
"canf(",d ,d",-p,-q);
printf(".nEnter E%ement" 'f The (ir"t )atri*+.n");
for(i00;i1 m;i22)
{
for(j00;j1 n;j22)
{
"canf(",d",-a[i][j]);
3
3
printf(".nEnter E%ement" 'f The /econd )atri*+.n");
for(i00;i1 p;i22) {
for(j00;j1 q;j22)
"canf(",d",-b[i][j]);
3
printf("The (ir"t )atri* 4"+.n"); 56 7rint the fir"t matri* 65
for(i00;i1 m;i22) {
for(j00;j1 n;j22)
printf(" ,d ",a[i][j]);
printf(".n");
3
printf("The /econd )atri* 4"+.n"); 56 7rint the "econd matri* 65
for(i00;i1 p;i22) {
for(j00;j1 q;j22)
printf(" ,d ",b[i][j]);
printf(".n");
3
if(n80p) {
printf("#bortin9:5n)&%tip%ication 'f The #bove )atrice" ;ot 7o""ib%e:");
e*it(0);
3
e%"e {
for(i00;i1 m;i22) {
for(j00;j1 q;j22) {
c[i][j] 0 0;
for(k00;k1 n;k22) {
c[i][j] 0 c[i][j] 2 a[i][k] 6 b[k][j];
3
3
3
printf(".nThe 7rod&ct 'f The T!o )atrice" 4"+.n.n");
for(i00;i1 m;i22) {
for(j00;j1 q;j22) {
printf(" ,d ",c[i][j]);
3
printf(".n");
3
3
ret&rn 0;
3
Write a program in K to multiplP two matricesQ
$inclu%e&st%io.h'
$inclu%e&conio.h'
voi% main()
* // main
int aL1#ML1#M+bL1#ML1#M+cL1#ML1#M+m+n+p+R+i+N+x,
clrscr(),
printf(-Anter row an% column of 1st matrix/n-),
scanf(-%-+1m+1n),
printf(-enter row an% column of 2n% matrix/n-),
scanf(-%-+1p+1R),
if(m==R) //K@AKS=>9 8< :CG;=6G=K=;Y
*
printf(-matrices can be multiplie%/n-),
printf(-resultant matrix is 0% 0%/n-+m+p),
printf(-enter elements of 1st matrix/n-),
for(i=#,i&m,i++)
for(N=#,N&n,N++)
scanf(-0%-+1aLiMLNM),
printf(-Anter elements of 2n% matrix/n-),
for(i=#,i&p,i++)
for(N=#,N&R,N++)
scanf(-0%-+1bLiMLNM),
// :CG;=6G=KA;=8> 8< :A;7=KAB
for(i=#,i&m,i++)
for(N=#,N&p,N++)
*
cLiMLNM=#,
for(x=#,x&p,x++)
cLiMLNM=cLiMLNM+(aLiMLxM3bLxMLNM),
4
printf(-the resultant matrixH/n-), H67=>;=>9 7ABCG;
for(i=#,i&m,i++)
*
for(N=#,N&R,N++)
printf(- 05% -+cLiMLNM),
printf(-/n-),
4
4 //if
else
printf(-matrices cannot be a%%e%/ncolumn of 1st matrix shoul% be eRual to
row of 2n% matrix-),
getch(),
4 //main
8r
$inclu%e&st%io.h'
main()
*
int aLEMLEM+bLEMLEM+cLEMLEM+%LEMLEM+i+N+.+m=2+n=2,
printf(-enter the values of matrix a/n-),
for(i=#,i&2,i++)
for(N=#,N&2,N++)
scanf(-0%-+1aLiMLNM),
printf(-enter the values of matrix b/n-),
for(i=#,i&2,i++)
for(N=#,N&2,N++)
scanf(-0%-+1bLiMLNM),
printf(-a%%ition of a an% b matrix is/n-),
for(i=#,i&2,i++)
for(N=#,N&2,N++)
cLiMLNM=aLiMLNM+bLiMLNM,
for(i=#,i&2,i++)
for(N=#,N&2,N++)
printf(-0%/n-+cLiMLNM),
printf(-:A;7=K :CG;=6=KA;=8> of a an% b matrix is/n-),
for(i=#,i&2,i++)
*
for(N=#,N&2,N++)
*
cLiMLNM=#,
for(.=#,.&2,.++)
*
cLiMLNM+=aLiML.M3bL.MLNM,
4
printf(-0%/t-+cLiMLNM),
4
4
4
Write a K program to fin% the 9K? of two numbers.
@ere is a K program ....
$inclu%e & st%io.h '
int gc%(int a+ int b),
int gc%Trecurse(int a+ int b),
int main()
*
printf(-/n9K?(02%+02%) = L0%M-+ !++ gc%(!+)),
printf(-/n9K?(02%+02%) = L0%M-+ +!+ gc%(+!)),
printf(-/n9K?(02%+02%) = L0%M-+ E+1F+ gc%(E+1F)),
printf(-/n9K?(02%+02%) = L0%M-+ 1F+E+ gc%(1F+E)),
printf(-/n9K?(02%+02%) = L0%M-+ 1+!+ gc%(1+!)),
printf(-/n9K?(02%+02%) = L0%M-+ 1#+1+ gc%(1#+1)),
printf(-/n9K?(02%+02%) = L0%M-+ 1#+!+ gc%(1#+!)),
printf(-/n9K?(02%+02%) = L0%M-+ !++ gc%Trecurse(!+)),
printf(-/n9K?(02%+02%) = L0%M-+ +!+ gc%Trecurse(+!)),
printf(-/n9K?(02%+02%) = L0%M-+ E+1F+ gc%Trecurse(E+1F)),
printf(-/n9K?(02%+02%) = L0%M-+ 1F+E+ gc%Trecurse(1F+E)),
printf(-/n9K?(02%+02%) = L0%M-+ 1+!+ gc%Trecurse(1+!)),
printf(-/n9K?(02%+02%) = L0%M-+ 1#+1+ gc%Trecurse(1#+1)),
printf(-/n9K?(02%+02%) = L0%M-+ 1#+!+ gc%Trecurse(1#+!)),
getch(),
getch(),
return(#),
4
// =terative algorithm
int gc%(int a+ int b)
*
int temp,
while(b)
*
temp = a 0 b,
a = b,
b = temp,
4
return(a),
4
// 7ecursive algorithm
int gc%Trecurse(int a+ int b)
*
int temp,
temp = a 0 b,
if (temp == #)
*
return(b),
4
else
*
return(gc%Trecurse(b+ temp)),
4
4
An% here is the output ...
=terative
2222222222222222
9K?( !+ ) = L2M
9K?( + !) = L2M
9K?( E+1F) = L1M
9K?(1F+ E) = L1M
9K?( 1+ !) = L1M
9K?(1#+ 1) = L1M
9K?(1#+ !) = L2M
7ecursive
2222222222222222
9K?( !+ ) = L2M
9K?( + !) = L2M
9K?( E+1F) = L1M
9K?(1F+ E) = L1M
9K?( 1+ !) = L1M
9K?(1#+ 1) = L1M
9K?(1#+ !) = L2M
>ote that Pou shoul% a%% error han%ling to chec. if someone has passe%
negative numbers an% Vero.
/3Kprogram to a%%+ subtract an% multiplP two complex numbers
<inc%&de
<inc%&de
void arithmetic(int opern);
"tr&ct comp
{
do&b%e rea%part;
do&b%e im9part;
3;
void main()
{
int opern;
c%r"cr();
printf(".n.n .t.t.t66666 )#4; )E;= 66666");
printf(".n.n /e%ect >o&r option+ .n 1 + #??.n @ + )=AT47AB.n 0 + EC4T .n.n.t.t
Enter >o&r 'ption [ ].b.b");
"canf(",d",-opern);
"!itch(opern)
{
ca"e 0+
e*it(0);
ca"e 1+
ca"e @+
arithmetic(opern);
defa&%t+
main();
3
3
void arithmetic(int opern)
{
"tr&ct comp !1, !@, !;
printf(".n Enter t!o $omp%e* ;&mber" (*2i>)+.n ea% 7art of (ir"t ;&mber+");
"canf(",%f",-!1:rea%part);
printf(".n 4ma9inar> 7art of (ir"t ;&mber+");
"canf(",%f",-!1:im9part);
printf(".n ea% 7art of /econd ;&mber+");
"canf(",%f",-!@:rea%part);
printf(".n 4ma9inar> 7art of /econd ;&mber+");
"canf(",%f",-!@:im9part);
"!itch(opern)
{
56addition of comp%e* n&mber65
ca"e 1+
!:rea%part 0 !1:rea%part2!@:rea%part;
!:im9part 0 !1:im9part2!@:im9part;
break;
56m&%tip%ication of comp%e* n&mber65
ca"e @+
!:rea%part0(!1:rea%part6!@:rea%part)D(!1:im9part6!@:im9part);
!:im9part0(!1:rea%part6!@:im9part)2(!1:im9part6!@:rea%part);
break;
3
if (!:im9partE0)
printf(".n #n"!er 0 ,%f2,%fi",!:rea%part,!:im9part);
e%"e
printf(".n #n"!er 0 ,%f,%fi",!:rea%part,!:im9part);
9etch();
main();
3
Komplex >umbers
int main (voi%)
*
int aTreal+aTimaginarP+N,
int bTreal+bTimaginarP,
int complexTnumber,
char enterToperator,
printf (-a real = -),
scanf (-0%-+1aTreal),
printf (-a imaginarP = -),
scanf (-0%-+1aTimaginarP),
printf (-b real = -),
scanf (-0%-+1bTreal),
printf (-b imaginarP = -),
scanf (-0%-+1bTimaginarP),
printf (-Anter operator = -),
scanf (-0c-+1enterToperator),
if (enterToperator == U+U)
complexTnumber = (aTreal+bTreal)+N(aTimaginarP+bTimaginarP),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U2U),
complexTnumber = (aTreal2bTreal)+N(aTimaginarP2bTimaginarP),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U/U),
complexTnumber = ((aTreal3bTreal+aTimaginarP3bTimaginarP)/
(bTreal3bTreal)+(bTimaginarP3bTimaginarP))+N((aTimaginarP3bTreal2
aTreal3bTimaginarP)/(bTreal3bTreal+bTimaginarP3bTimaginarP)),
printf (-/ncomplex number is 0%/n-+complexTnumber),
else if (enterToperator == U3U),
complexTnumber = ((aTreal3bTreal)2(aTimaginarP3bTimaginarP))
+N((aTreal3bTimaginarP)+(aTreal3bTreal)),
printf (-/ncomplex number is 0%/n-+complexTnumber),
return #,
4
int main (void)
{
int aFrea%,aFima9inar>,j;
int bFrea%,bFima9inar>;
int comp%e*Fn&mber;
char enterFoperator;
printf ("a rea% 0 ");
"canf (",d",-aFrea%);
printf ("a ima9inar> 0 ");
"canf (",d",-aFima9inar>);
printf ("b rea% 0 ");
"canf (",d",-bFrea%);
printf ("b ima9inar> 0 ");
"canf (",d",-bFima9inar>);
printf ("Enter operator 0 ");
"canf (",c",-enterFoperator);
if (enterFoperator 00 G2G)
{
comp%e*Fn&mber 0 (aFrea%2bFrea%)2j(aFima9inar>2bFima9inar>);
printf (".ncomp%e* n&mber i" ,d.n",comp%e*Fn&mber);
3
e%"e if (enterFoperator 00 GDG)
{
comp%e*Fn&mber 0 (aFrea%DbFrea%)2j(aFima9inar>DbFima9inar>);
printf (".ncomp%e* n&mber i" ,d.n",comp%e*Fn&mber);
3
e%"e if (enterFoperator 00 G5G)
{
comp%e*Fn&mber 0 ((aFrea%6bFrea%2aFima9inar>6bFima9inar>)5
(bFrea%6bFrea%)2(bFima9inar>6bFima9inar>))2j((aFima9inar>6bFrea%D
aFrea%6bFima9inar>)5(bFrea%6bFrea%2bFima9inar>6bFima9inar>));
printf (".ncomp%e* n&mber i" ,d.n",comp%e*Fn&mber);
3
e%"e if (enterFoperator 00 G6G)
{
comp%e*Fn&mber 0 ((aFrea%6bFrea%)D(aFima9inar>6bFima9inar>))
2j((aFrea%6bFima9inar>)2(aFrea%6bFrea%));
printf (".ncomp%e* n&mber i" ,d.n",comp%e*Fn&mber);
3
ret&rn 0;
3
(ir"t, if in an if "tatement >o& have more than one "in9%e in"tr&ction, >o& have to
p&t the"e in"tr&ction" bet!een { and 3
/econd, else if (expr) doe" not ever end !ith a ,
A??=;=8> 1 BCJ;7AK;=8> 8< ;W8 K8:6GAD >C:JA7B CB=>9 K
67897A:
voi% main()
*
int a+b+c+%+x+P,
clrscr(),
printf(-/nAnter the first complex numberH-),
scanf(-0%0%-+1a+1b),
printf(-/nAnter the secon% complex numberH-),
scanf(-0%0%-+1c+1%),
if(b&#) x=-a+c,- P=-b+%,-'#)
printf(-0%2i0%-+x+2P),
else
printf(-0%+i0%-+x++P),
printf(-/n/nBCJ;7AK;=8> -),
x=a2c,
P=b2%,
if(P&#)
printf(-0%2i0%-+x+2P),
else
printf(-0%+i0%-+x++P),
getch(),
4
c22 pro9ram to add @ comp%e* n&mber &"in9 operator over%oadin9 techniq&e
<inc%&de1io"treamE
&"in9 name"pace "td;
c%a"" comp%e*Fn&mber
{
int rea%Fpart;
int ima9inar>Fpart;
p&b%ic+
void "et?ata(int va%,int f%a9)
{
rea%Fpart 0 0;
ima9inar>Fpart 0 0;
if(f%a9 00 0)
{
rea%Fpart 0 va%;
ima9inar>Fpart 0 0;
3
e%"e if(f%a9 00 1)
{
rea%Fpart 0 0;
ima9inar>Fpart 0 va%;
3
3
void "et?ata(int rp, int ip, int f%a9)
{ rea%Fpart 0 0;
ima9inar>Fpart 0 0;
if(f%a9 00 D1)
{
rea%Fpart 0 rp;
ima9inar>Fpart 0 ip;
3
3
void "ho!()
{ if(ima9inar>FpartE00)
co&t11"$omp%e* ;&mber
i"+ "11rea%Fpart11"2"11ima9inar>Fpart11"i"11end%;
e%"e
co&t11"$omp%e* ;&mber
i"+ "11rea%Fpart11ima9inar>Fpart11"i"11end%;
3
comp%e*Fn&mber operator2 (comp%e*Fn&mber op@);
comp%e*Fn&mber operatorD (comp%e*Fn&mber op@);
comp%e*Fn&mber operator22();
comp%e*Fn&mber operator22(int *);
3;
comp%e*Fn&mber comp%e*Fn&mber++ operator2(comp%e*Fn&mber
op@)
{
comp%e*Fn&mber temp;
temp:rea%Fpart 0 op@:rea%Fpart 2 rea%Fpart;
temp:ima9inar>Fpart 0 op@:ima9inar>Fpart 2
ima9inar>Fpart;
ret&rn temp;
3
comp%e*Fn&mber comp%e*Fn&mber++ operatorD(comp%e*Fn&mber
op@)
{
comp%e*Fn&mber temp;
temp:rea%Fpart 0 rea%Fpart D op@:rea%Fpart;
temp:ima9inar>Fpart 0 ima9inar>Fpart D
op@:ima9inar>Fpart;
ret&rn temp;
3
comp%e*Fn&mber comp%e*Fn&mber++ operator22()
{
rea%Fpart22;
ima9inar>Fpart22;
ret&rn 6thi";
3
comp%e*Fn&mber comp%e*Fn&mber++ operator22(int *)
{
22rea%Fpart;
22ima9inar>Fpart;
ret&rn 6thi";
3
int main()
{
comp%e*Fn&mber ob1;
ob1:"et?ata(H,0);

comp%e*Fn&mber ob@;
ob@:"et?ata(10,1);
55co&t11"Iefore addition"11ob@:"ho!();
comp%e*Fn&mber obJ;
obJ:"et?ata(@,J,D1);
comp%e*Fn&mber obK;
obK:"et?ata(K,H,D1);
comp%e*Fn&mber obH;
co&t11"Iefore addition, comp%e* n&mber" are +"11end%;
obK:"ho!();
obJ:"ho!();
obH 0 obK2obJ;
co&t11"#fter #ddition";
obH:"ho!();
co&t11"Iefore addition, comp%e* n&mber" are +"11end%;
ob1:"ho!();
obK:"ho!();
obH 0 ob1 2 obK;
co&t11"#fter #ddition";
obH:"ho!();
co&t11"Iefore addition, comp%e* n&mber" are +"11end%;
ob@:"ho!();
obK:"ho!();
obH 0 ob@2 obK;
co&t11"#fter #ddition";
obH:"ho!();
co&t11"Iefore preincrement"11end%;
obH:"ho!();
22obH;
co&t11"#fter preincrement"11end%;
obH:"ho!();
co&t11"Iefore po"tincrement"11end%;
obH:"ho!();
obH22;
co&t11"#fter po"tincrement"11end%;
obH:"ho!();
co&t11"Iefore /&btraction, comp%e* n&mber" are +"11end%;
obK:"ho!();
obJ:"ho!();
obH 0 obKDobJ;
co&t11"#fter /&btraction";
obH:"ho!();
co&t11"Iefore /&btraction, comp%e* n&mber" are +"11end%;
ob1:"ho!();
obK:"ho!();
obH 0 ob1 D obK;
co&t11"#fter /&btraction";
obH:"ho!();
co&t11"Iefore /&btraction, comp%e* n&mber" are +"11end%;
ob@:"ho!();
obK:"ho!();
obH 0 ob@D obK;
co&t11"#fter "&btraction";
obH:"ho!();


int i;
cinEEi;
ret&rn 0;
3
print sum of two complex numbers
56 The fo%%o!in9 code e*amp%e i" taken from the book
6 "The $22 /tandard Aibrar> D # T&toria% and eference"
6 b> ;ico%ai ): Lo"&tti", #ddi"onDMe"%e>, 1NNN
6
6 ($) $op>ri9ht ;ico%ai ): Lo"&tti" 1NNN:
6 7ermi""ion to cop>, &"e, modif>, "e%% and di"trib&te thi" "oft!ar
e
6 i" 9ranted provided thi" cop>ri9ht notice appear" in a%% copie":
6 Thi" "oft!are i" provided "a" i"" !itho&t e*pre"" or imp%ied
6 !arrant>, and !ith no c%aim a" to it" "&itabi%it> for an> p&rpo"e:
65
<inc%&de 1io"treamE
<inc%&de 1comp%e*E
using name"pace "td;
int main()
{
56 comp%e* n&mber !ith rea% and ima9inar> part"
6 D rea% part+ K:0
6 D ima9inar> part+ J:0
65
comp%e*1%oubleE c1(K:0,J:0);
co&t 11 "c1+ " 11 c1 11 end%;
56 create comp%e* n&mber from po%ar coordinate"
6 D ma9nit&de+ H:0
6 D pha"e an9%e+ 0:OH
65
comp%e*1floatE c@(po%ar(H:0,0:OH));
56 print "&m of c1 and c@+
6 D note+ different t>pe"
65
co&t 11 "c1 2 c@+ "
11 c1 2 comp%e*1%oubleE(c@:rea%(),c@:ima9()) 11 end%;
3
c1+ (K,J)
c1 2 c@+ (O:PHQKK,P:K0Q1N)
Write a program in c++ that %ivi%es two complex numbersQ
class Komplex
*
privateH
%ouble real+ imag,
publicH
Komplex () *
real = #.#, imag = #.#,
4
Komplex (%ouble r+ %ouble i) *
real = r, imag = i,
4
Komplex A%% (Komplex1 a+ Komplex1 b) *
return Komplex (a.real + b.real+ a.imag + b.imag),
4
%ouble abs () *
return sRrt (this2'real 3 this2'real + this2'imag 3 this2'imag),
4
Komplex ?ivision( Komplex1 a+ Komplex 1b)
*
write the fowrmula here
4
voi% show()
*
cout && real && - + - && imag && -i- &&en%l,
4
4,
voi% main()
*
Komplex >um1(2+E),
Komplex >um2(E+),
Komplex 7esult,
>um1.show(),
>um2.show(),
7esult.A%%(>um1+>um2),
7esult.show(),
4
Write a K program to reverse the string without using strrev() functionQ
<inc%&de 1"tdio:hE
<inc%&de 1conio:hE
<inc%&de 1"trin9:hE
void main()
{
char "tr[10],temp;
int i,%en;
printf("Enter /trin9 + ");
"canf(","","tr);
%en0"tr%en("tr)D1;
for(i00;i1"tr%en("tr)5@;i22)
{
temp0"tr[i];
"tr[i]0"tr[%en];
"tr[%enDD]0temp;
3
printf(","","tr);
9etch();
3
K co%e programming to reverse a stringQ
Bo& have to read a "trin9 ">mbo% b> ">mbo% in an arra> and &"in9 the arra> and
on of the %oop operator" (for, !hi%e, do:::!hi%e and "o on) p&t the arra> in o&tp&t
in rever"e order:
<inc%&de 1"tdio:hE
int main ()
{
int i,j;
char a[10];
char temp;
55c%r"cr (); 55 on%> !ork" on !indo!"
9et"(a);
for (i00;a[i]80G.0G;i22);
iDD;
for (j00;j 10 i5@ ;j22)
{
temp 0 a[j];
a[j] 0 a[iDj];
a[iDj] 0 temp;
3
printf(","",a);
ret&rn(0);
3
56$22 pro9ram to divide t!o comp%e* n&mber" &"in9 operator over%oadin965
<inc%&de1io"tream:hE
<inc%&de1conio:hE
c%a"" comp%e*
{
f%oat *,>;
p&b%ic+
comp%e*() {3
comp%e*(f%oat rea%,f%oat im9)
{
*0rea%; >0im9;
3
void di"p%a>()
{
co&t11*11" 2 "11>11"i"11end%;
3
void operator5(comp%e*);
3;
void comp%e*++operator5(comp%e* c)
{
comp%e* temp; 55;&merator
temp:*0*6c:*2>6(Dc:>)6(D1); 55ea% n&mber of the n&merator
temp:>0*6(Dc:>)2>6c:*; 554ma9inar> n&mber of the n&merator
f%oat deno; 55?enominator
deno0c:*6c:*Dc:>6c:>6(D1); 55/imi%ar to (a2b)(aDb)0a
@
Db
@
co&t11temp:*11" 2 "11temp:>11"i 5 "11deno;
3
void main()
{
c%r"cr();
comp%e* c1(H,K),c@(J,@);
c1:di"p%a>();
c@:di"p%a>();
co&t11"?ividin9 the comp%e* n&mber""11end%;
c15c@;
9etch();
3
'=T7=T+
H 2 Ki
J 2 @i
?ividin9 the comp%e* n&mber"
@J 2 @i 5 1J
write program for palin%rome
<inc%&de1"tdio:hE
<inc%&de1conio:hE
void main()
{
int n,"00,m;
c%r"cr();
printf("enter an> no");
"canf(",d",-n);
m0n;
!hi%e(nE0)
{
r0n,10;
"0"6102r;
n0n510;
3
if(m00n)
printf("the no i" pa%indrome");
e%"e
printf("no i" not pa%indrome");
9etch();
3
K program to chec. whether a Btring is 6alin%rome or notQ
<inc%&de1"tdio:hE
<inc%&de1"trin9:hE
<define "iRe @P
void main()
{
char "tr"rc["iRe];
char "trtmp["iRe];
c%r"cr();
printf(".n Enter /trin9+0 "); 9et"("tr"rc);
"trcp>("trtmp,"tr"rc);
"trrev("trtmp);
if("trcmp("tr"rc,"trtmp)000)
printf(".n Entered "trin9 .","." i"pa%indrome","tr"rc);
e%"e
printf(".n Entered "trin9 .","." i" not
pa%indrome","tr"rc);
9etch();
3
Write a K program to chec. whether the string is palin%rome or notQ
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int strLen=,ind!"
i#(argv[$]==%&LL){
return()"
'
(hile((argv[$][strLen]))= *+*)
{
strLen,,"
'
#or(ind! = "ind! < strLen-."ind!,,)
{
i#(argv[$][ind!] )= argv[$][strLen/$/ind!])
{
0rint#(12s %ot 0alindrome+n1,argv[$])"
return()"
'
'
0rint#(12s 3alindrome1,argv[$])"
return "
'
4r
#include<stdio.h>
#include<string.h>
#de#ine si5e .6
void main()
{
char strsrc[si5e]"
char strtm0[si5e]"
clrscr()"
0rint#(1+n 7nter 8tring9= 1)"
gets(strsrc)"
strc0:(strtm0,stru0r(strsrc))"
strrev(strtm0)"
i#(strcm0(strsrc,strtm0)==)
0rint#(1+n 7ntered string 12s1 is 0alindrome1,strsrc)"
else
0rint#(1+n 7ntered string 12s1 is not 0alindrome1,strsrc)"
getch()"
'
6rogram to Kalculate the 6ascal triangle
$inclu%e&st%io.h'
$inclu%e&conio.h'
voi% main()
*
int aL1#ML1#M,
int i+N+c+n,
clrscr(),
printf(-Anter how manP lines %o Pou want-),
scanf(-0%-+1n),
aL1ML1M=1,
printf(-05%-+aL1ML1M),
aL2ML1M=1,aL2ML2M=2,aL2MLEM=1,
printf(-0% 0% 0%-+aL2ML1M+aL2ML2M+aL2MLEM),
for(i=E,i&=n,i++)
*
aLiML1M=1,
printf(-0%-+aLiML1M),
N=2,c=E,
while(N&=i)
*
aLiMLNM=aLi21MLc21M+aLi21MLc22M,
printf(-05%-+aLiMLNM),
c=c+1,
N=N+1,
4
aLiMLNM=1,
printf(-0%-+aLiMLNM),
4
4
K program to print the 6ascalWs triangle
$inclu%e
voi% main()
*
int aL1#ML1#M,
int i+N+c+n,
printf(-Anter how manP lines %o Pou want-),
scanf(-0%-+1n),
aL1ML1M=1,
printf(-05%-+aL1ML1M),
aL2ML1M=1,aL2ML2M=2,aL2MLEM=1,
printf(-0% 0% 0%-+aL2ML1M+aL2ML2M+aL2MLEM),
for(i=E,i&=n,i++)
*
aLiML1M=1,
printf(-0%-+aLiML1M),
N=2,c=E,
while(N&=i)
*
aLiMLNM=aLi21MLc21M+aLi21MLc22M,
printf(-05%-+aLiMLNM),
c=c+1,
N=N+1,
4
aLiMLNM=1,
printf(-0%-+aLiMLNM),
4
4
@ow to write c co%e to generate pascal triangleQ
@i the waP u explaine% the logic an% the program You have %one is+
perfect.Jut Nus two things You nee% to concentrate for printing the pPrami%
in a right shape.= have inclu%e% changes ..@ope it helps You.
$inclu%e&st%io.h'
$inclu%e&conio.h'
/3program to generate pascal triangle+ no. of lines r to be entere% bP the
user3/
voi% main()
*
int a+b+c+i+N+n+r+s+ncr+factr+factn+factnr+line,
printf(-please enter the number of lines of the pascal triangle/n-),
scanf(-0%-+1line), //inputs the no. of lines we want
clrscr(),
for(i=#,i&=line21,i++)//outer loop for the value of n
*
factn=1,// reinitialiVing the factorial values to avoi% garbage values...
factr=1,
factnr=1,
for(s=line21,s'=i,s22) 55 L&"t 4nc%&ded a (or %oop T' have %eadin9 /pace"
*
printf(- -),
4
for(N=#,N&=i,N++) //outer loop for the values of r
*
n=i, //here we have assigne% i to n an% N to r for our nKr calculation an%
convinience
r=N,
factn=1, // again we have re initialise% factorial values to avoi% garbage
values
factr=1,
factnr=1,
if(n==#) //we .now factorial of # =1
factn=1,
else
*
for(a=n,a'=1,a22) //factorial calculation of n is n!=#
factn=factn3a,
4
if(r==#)
factr=1,
else
*
for(b=r,b'=1,b22) //factorial calculation of r if r!=#
factr=factr3b,
4
if((n2r)==#)
factnr=1,
else
*
for(c=(n2r),c'=1,c22) //factorial calculation of n2r if (n2r)!=#
factnr=factnr3c,
4
ncr=factn/(factr3factnr), //ncr calculation
printf(-02%-+ncr), 55emove that tab and S4ven @d to have "pace" bet!een
each character" and print" the va%&e of ncr
4
printf(-/n-), //cursor get to the next line when the control exits the inner
loop
4
4
K language program to print 6ascal ;riangleQ
<inc%&de 1io"tream:hE
do&b%e fact(do&b%e n)
{
ret&rn (n E 1) T n 6 fact(n D 1) + 1;
3
do&b%e ncr(int n, int r)
{
ret&rn fact(n) 5 (fact(r) 6 fact(n D r));
3
void main()
{
for (int i 0 0; i 1 1H; i22)
{
for (int j 0 0; j 10 i; j22)
co&t 11ncr(i, j) 11 G G; co&t 11 end%;
3
3
K program of matrix a%%ition+substraction+an% multiplication
/3 6rogram of a%%ition+substraction+an% multiplication of matrix 3/
$inclu%e
$inclu%e
voi% rea%Tmat(int m+int n+int aL5ML5M)
*
int i+N,
for(i=#,i
*
for(N=#,N
*
printf(-/n Anter element H-),
scanf(-0%-+1aLiMLNM),
4
4
voi% printTmat(int m+int n+int aL5ML5M)
*
int i+N,
for(i=#,i
*
for(N=#,N
printf(- 0%-+aLiMLNM),
printf(-/n-),
4
4
voi% a%%Tmat(int m+int n+int aL5ML5M+int bL5ML5M+int sL5ML5M)
*
int i+N,
for(i=#,i
*
for(N=#,N
*
sLiMLNM=aLiMLNM+bLiMLNM,
4
4
4
voi% subTmat(int m+int n+int aL5ML5M+int bL5ML5M+int s%L5ML5M)
*
int i+N,
for(i=#,i
*
for(N=#,N
*
s%LiMLNM=aLiMLNM2bLiMLNM,
4
4
4
voi% mulTmat(int m+int n+int R+int aL5ML5M+int bL5ML5M+int mtL5ML5M)
*
int i+N+.,
for(i=#,i
*
for(N=#,N
*
mtLiMLNM=#,
for(.=#,.
*
mtLiMLNM=mtLiMLNM+aLiML.M3bL.MLNM,
4
4
4
4
voi% main()
*
int m+n+p+R+i+N+aL5ML5M+bL5ML5M+sL5ML5M+s%L5ML5M+mtL5ML5M,
printf(-/n Anter or%er of first matrix H-),
scanf(-0%0%-+1m+1n),
printf(-/n 8r%er of secon% matrix H-),
scanf(-0%0%-+1p+1R),
if((m!=p)11(n!=R))
printf(-/n :atrices are imcompatable for a%%otion an% substraction-),
else
*
printf(-/n 7ea% the element of first matrix -),
rea%Tmat(m+n+a),
printf(-/n 7ea% the element of secon% matrix -),
rea%Tmat(p+R+b),
printf(-/n <=7B; :A;7=D =B ....../n-),
printTmat(m+n+a),
printf(-/n BAK8>? :A;7=D =B ..../n-),
printTmat(p+R+b),
a%%Tmat(m+n+a+b+s),
printf(-/n A<;A7 A??=;=8> :A;7=D =B ..../n-),
printTmat(m+n+s),
subTmat(m+n+a+b+s%),
printf(-/n A<;A7 BCJB;7AK;=8> :A;7=D =B ..../n-),
printTmat(m+n+s%),
4
if(p==R)
*
mulTmat(m+n+R+a+b+mt),
printf(-/n A<;A7 :CG;=6G=KA;=8> :A;7=D =B ..../n-),
printTmat(m+R+mt),
4
else
printf(-/n :atrices are incompatible for multiplication -),
getch(),
4
8r
a11 a1@ a1J #11 #1@ #1J a11*#112a1@*#@12a1J*#J1
a11*#1@2a1@*#@@2a1J*#J@
a@1 a@@ a@J * #@1 #@@ #@J 0 a@1*#112a@@*#@12a@J*#J1
a@1*#1@2a@@*#@@2a@J*#J@
aJ1 aJ@ aJJ #J1 #J@ #JJ aJ1*#112aJ@*#@12aJJ*#J1
:ore specific %etails are bePon% the scope of this article but Pou can refer
:atrix multiplication in wi.ipe%ia.
The $ode
Ko%eH K
void main()
{
int m1[10][10],i,j,k,m@[10][10],add[10][10],m&%t[10][10],r1,c1,r@,c@;
printf("Enter n&mber of ro!" and co%&mn" of fir"t matri* )#C 10/n");
"canf(",d,d",-r1,-c1);
printf("Enter n&mber of ro!" and co%&mn" of "econd matri* )#C 10/n");
"canf(",d,d",-r@,-c@);
if(r@00c1)
{
printf("Enter ro!" and co%&mn" of (ir"t matri* /n");
printf("o! !i"e/n");
for(i00;i1r1;i22)
{
for(j00;j1c1;j22)
"canf(",d",-m1[i][j]);
3
printf("Bo& have entered the fir"t matri* a" fo%%o!"+/n");
for(i00;i1r1;i22)
{
for(j00;j1c1;j22)
printf(",d/t",m1[i][j]);
printf("/n");
3
printf("Enter ro!" and co%&mn" of /econd matri* /n");
printf("#9ain ro! !i"e/n");
for(i00;i1r@;i22)
{
for(j00;j1c@;j22)
"canf(",d",-m@[i][j]);
3
printf("Bo& have entered the "econd matri* a" fo%%o!"+/n");
for(i00;i1r@;i22)
{
for(j00;j1c@;j22)
printf(",d/t",m@[i][j]);
printf("/n");
3
if(r100r@--c100c@)
{
printf(";o! !e add both the above matri* /n");
printf("The re"&%t of the addition i" a" fo%%o!";/n");
for(i00;i1r1;i22)
{
for(j00;j1c1;j22)
{
add[i][j]0m1[i][j]2m@[i][j];
printf(",d/t",add[i][j]);
3
printf("/n");
3
3
e%"e
{
printf("#ddition cannot be done a" ro!" or co%&mn" are not eq&a%/n");
3
printf(";o! !e m&%tip%> both the above matri* /n");
printf("The re"&%t of the m&%tip%ication i" a" fo%%o!"+/n");
-*a$$!;$$,a$.!;.$,a$<!;<$ a$$!;$.,a$.!;..,a$<!;<.
a$$!;$<,a$.!;.<,a$<!;<<*-
for(i00;i1r1;i22)
{
for(j00;j1c@;j22)
{
m&%t[i][j]00;
for(k00;k1r1;k22)
{
m&%t[i][j]20m1[i][k]6m@[k][j];
-*mult[][]=m$[][]*m.[][],m$[][$]*m.[$][],m$[][.]*m.[.]
[]"*-
3
printf(",d/t",m&%t[i][j]);
3
printf("/n");
3
9etch();
3
e%"e
{
printf(")atri* m&%tip%ication cannot be done");
3
3
K program for an Armstrong number
voi% main()
*
int n+b=#+t,
clrscr(),
printf(XAnter the noY),
scanf(X0%Y+1n),
t=n,
while(n'#)
*
a=n01#,
b=b+a3a3a,
n=n/1#,
4
if(b==t)
*
printf(XArmstrong noY),
4
else
*
printf(X>ot an armstrong noY),
4
getch(),
4
write a program to fin% a given number is arms...
main()
{
int amm 0 temp 0 n *;
printf( enter thea%&e of n );
"canf( d -n);
* n;
for(;nE0;)
{
temp n 10;
amm amm2(temp6temp6temp);
n n510;
3
if(* n)
{
printf( TUE S4VE; ;=)IE 4/ #)/T';S ;=)IE );
3
e%"e
printf( ;'T #)/T';S ;=)IE );
3
Write a program to print all Armstrong number between 1 an% 5## =f sum of
cubes of each %igit of the number it self then the number is calle% an
Armstrong numberQ
567ro9ram to find arm"tron9 n&mber bet!een 1 to H0065
int main() {
int i,a,b,c,*,>;
c%r"cr();
for (i00;i10H00;i22)
{
c0i,10;
*0i510;
b0*,10;
*0*510;
a0*,10;
d0(a6a6a)2(b6b6b)2(c6c6c);
if (i00d)
printf(",d.n",i);
3
9etch();
3
Armstrong number program in c languageQ
<inc%&de1"tdio:hE
<inc%&de1conio:hE
void main()
{
int n,m,"&00,b;
c%r"cr();
printf("enter the n&mber to find am"tron9+");
"canf(",d",-n);
b0n;
!hi%e(nE0)
{
m0n,10;
"&0"&2(m6m6m);
n0n510;
55printf(",d",");
3
if(b00"&)
printf(" am"tron9 no i" ,d",b);
e%"e
printf("not am"tron9");
9etch();
3
Write a program in c to sort an unsorte% arraP using bubble sort metho%Q
<inc%&de1"tdio:hE
<inc%&de1conio:hE
main()
{
int arr[H],temp,i,j;
c%r"cr();
printf(".n.tEnter The Va%&e" into ##B ");
for(i00;i1H;i22)
{
printf(".n.n Enter E%ement no ,d+ ",i21);
"canf(",d",-arr[i]);
3
for(i00;i1H;i22)
{
for(j01;j10K;j22)
{
if(arr[j] Ea[j21])
{
temp0arr[j];
arr[j]0arr[j21];
arr[j21]0temp;
3
3
3
printf(".n.nDD /orted /erie" DD");
for(i00;i10K;i22)
{
printf(".n .n .t ,d",arr[i]);
3
9etch();
3
6rogram to =mplement Jubble Bort ;echniRue.
$inclu%e&st%io.h'
$inclu%e&conio.h'
voi% bubble(int aLM+int n)
*
int i+N+t,
for(i=n22,i'=#,i22)
*
for(N=#,N&=i,N++)
*
if(aLNM'aLN+1M)
*
t=aLNM,
aLNM=aLN+1M,
aLN+1M=t,
4
4

4//en% for 1.
4//en% function.
voi% main()
*
int aL1##M+n+i,
clrscr(),
printf(-/n/n Anter integer value for total no.s of elements to be sorte%H
-),
scanf(-0%-+1n),
for( i=#,i&=n21,i++)
* printf(-/n/n Anter integer value for element no.0% H -+i+1),
scanf(-0%-+1aLiM),
4
bubble(a+n),
printf(-/n/n <inallP sorte% arraP isH -),
for( i=#,i&=n21,i++)
printf(-0E%-+aLiM),
4 //en% program.
/3
22222222BA:6GA 8C;6C;2222222222222222222222
Anter integer value for total no.s of elements to be sorte%H !
Anter integer value for element no.1 H IO
Anter integer value for element no.2 H 2
Anter integer value for element no.E H 2!F
Anter integer value for element no. H 5
Anter integer value for element no.5 H FI
Anter integer value for element no.! H 11
<inallP sorte% arraP isH 2!F 2 5 11 FI IO
222222222222222222222222222222222222222222
3/
;he simplest sorting algorithm is bubble sort. ;he bubble sort wor.s bP
iterating %own an arraP to be sorte% from the first element to the last+
comparing each pair of elements an% switching their positions if
necessarP. ;his process is repeate% as manP times as necessarP+ until the
arraP is sorte%. Bince the worst case scenario is that the arraP is in reverse
or%er+ an% that the first element in sorte% arraP is the last element in the
starting arraP+ the most exchanges that will be necessarP is eRual to the
length of the arraP. @ere is a simple exampleH
9iven an arraP 2E15 a bubble sort woul% lea% to the following seRuence of
partiallP sorte% arraPsH 21E5+ 21E5+ 12E5. <irst the 1 an% E woul% be
compare% an% switche%+ then the an% 5. 8n the next pass+ the 1 an% 2
woul% switch+ an% the arraP woul% be in or%er.
binarP search program in c language
$inclu%e
$inclu%e
voi% main()
*
int arraPL1#M,
int i+ N+ >+ temp+ .ePnum,
int low+mi%+high,
clrscr(),
printf(-Anter the value of >/n-),
scanf(-0%-+1>),
printf(-Anter the elements one bP one/n-),
for(i=#, i
*
scanf(-0%-+1arraPLiM),
4
printf(-=nput arraP elements/n-),
for(i=#, i
*
printf(-0%/n-+arraPLiM),
4
/3 Jubble sorting begins 3/
for(i=#, i& > , i++)
*
for(N=#, N& (>2i21) , N++)
*
if(arraPLNM ' arraPLN+1M)
*
temp = arraPLNM,
arraPLNM = arraPLN+1M,
arraPLN+1M = temp,
4
4
4
printf(-Borte% arraP is.../n-),
for(i=#, i
*
printf(-0%/n-+arraPLiM),
4
printf(-Anter the element to be searche%/n-),
scanf(-0%-+ 1.ePnum),
/3 JinarP searching begins 3/
low=1,
high=>,
%o
*
mi%= (low + high) / 2,
if ( .ePnum & arraPLmi%M )
high = mi% 2 1,
else if ( .ePnum ' arraPLmi%M)
low = mi% + 1,
4 while( .ePnum!=arraPLmi%M 11 low &= high), /3 An% of %o2 while 3/
if( .ePnum == arraPLmi%M )
*
printf(-BCKKABB<CG BAA7K@/n-),
4
else
*
printf(-Bearch is <A=GA?/n-),
4
4 /3 An% of main3/
J=>A7Y BAA7K@ CB=>9 K 67897A:
voi% main()
*
int aL1#M+i+n+m+c+l+u,
clrscr(),
printf(-Anter the siVe of an arraP2'-),
scanf(-0%-+1n),
printf(-/nAnter the elements of the arraP2'-),
for(i=#,i-),
for(i=#,i-),
scanf(-0%-+1m),
l=#+u=n21,
c=binarP(a+n+m+l+u),
if(c==#)
printf(-/n;he number is not in the list-),
else
printf(-/n;he number is foun%-),
getch(),
4
int binarP(int aLM+int n+int m+int l+int u)
*
int mi%+c=#,
if(l&=u)
*
mi%=(l+u)/2,
if(m==aLmi%M)
*
c=1,
4
else
if(m
*
return binarP(a+n+m+l+mi%21),
4
else
return binarP(a+n+m+mi%+1+u),
4
else
return c,
4
C PROGRAM FOR BINARY SEARCH
void main()
{
int a[10],i,n,m,c,%,&;
c%r"cr();
printf("Enter the "iRe of an arra>DE");
"canf(",d",-n);
printf(".nEnter the e%ement" of the arra>DE");
for(i00;i
{
"canf(",d",-a[i]);
3
printf(".nThe e%ement" of an arra> areDE");
for(i00;i
{
printf(" ,d",a[i]);
3
printf(".nEnter the n&mber to be "earchDE");
"canf(",d",-m);
%00,&0nD1;
c0binar>(a,n,m,%,&);
if(c000)
printf(".nThe n&mber i" not in the %i"t");
e%"e
printf(".nThe n&mber i" fo&nd");
9etch();
3
int binar>(int a[],int n,int m,int %,int &)
{
int mid,c00;
if(%10&)
{
mid0(%2&)5@;
if(m00a[mid])
{
c01;
3
e%"e
if(m
{
ret&rn binar>(a,n,m,%,midD1);
3
e%"e
ret&rn binar>(a,n,m,mid21,&);
3
e%"e
ret&rn c;
3
Iinar> /earch $ 7ro9ram
$inclu%e &st%io.h'
$%efine ;7CA #
$%efine <AGBA 1
int main(voi%) *
int arraPL1#M = *1+ 2+ E+ + 5+ !+ F+ I+ O+ 1#4,
int left = #,
int right = 1#,
int mi%%le = #,
int number = #,
int bsearch = <AGBA,
int i = #,
printf(-A77AYH -),
for(i = 1, i &= 1#, i++)
printf(-L0%M -+ i),
printf(-/nBearch for >umberH -),
scanf(-0%-+ 1number),
while(bsearch == <AGBA 11 left &= right) *
mi%%le = (left + right) / 2,
if(number == arraPLmi%%leM) *
bsearch = ;7CA,
printf(-33 >umber <oun% 33/n-),
4 else *
if(number & arraPLmi%%leM) right = mi%%le 2 1,
if(number ' arraPLmi%%leM) left = mi%%le + 1,
4
4
if(bsearch == <AGBA)
printf(-22 >umber >ot foun% 22/n-),
return #,
4
K program that implement :erge sort to sort a given list of integers in
ascen%ing or%erH
$inclu%e
$inclu%e
$%efine :ADTA7Y 1#
voi% mergeTsort(int xLM+ int en%+ int start),
int main(voi%) *
int arPL:ADTA7YM,
int N = #,
printf(-/n/nAnter the elements to be sorte%H /n-),
for(N=#,N&:ADTA7Y,Z++)
scanf(-0%-+1arPLNM),
/3 arraP before mergesort 3/
printf(-Jefore H-),
for(N = #, N & :ADTA7Y, N++)
printf(- 0%-+ arPLNM),
printf(-/n-),
mergeTsort(arP+ #+ :ADTA7Y 2 1),
/3 arraP after mergesort 3/
printf(-After :erge Bort H-),
for(N = #, N & :ADTA7Y, N++)
printf(- 0%-+ arPLNM),
printf(-/n-),
getch(),
4
/3 :etho% to implement :erge Bort3/
voi% mergeTsort(int xLM+ int en%+ int start) *
int N = #,
const int siVe = start 2 en% + 1,
int mi% = #,
int mrg1 = #,
int mrg2 = #,
int executingL:ADTA7YM,
if(en% == start)
return,
mi% = (en% + start) / 2,
mergeTsort(x+ en%+ mi%),
mergeTsort(x+ mi% + 1+ start),
for(N = #, N & siVe, N++)
executingLNM = xLen% + NM,
mrg1 = #,
mrg2 = mi% 2 en% + 1,
for(N = #, N & siVe, N++) *
if(mrg2 &= start 2 en%)
if(mrg1 &= mi% 2 en%)
if(executingLmrg1M ' executingLmrg2M)
xLN + en%M = executingLmrg2++M,
else
xLN + en%M = executingLmrg1++M,
else
xLN + en%M = executingLmrg2++M,
else
xLN + en%M = executingLmrg1++M,
4
4
)er9e /ort $ 7ro9ram
$inclu%e &st%io.h'
$inclu%e &st%lib.h'
struct no%e *
int number,
struct no%e 3next,
4,
/3 a%% a no%e to the lin.e% list 3/
struct no%e 3a%%no%e(int number+ struct no%e 3next),
/3 preform merge sort on the lin.e% list 3/
struct no%e 3mergesort(struct no%e 3hea%),
/3 merge the lists.. 3/
struct no%e 3merge(struct no%e 3hea%Tone+ struct no%e 3hea%Ttwo),
int main(voi%) *
struct no%e 3hea%,
struct no%e 3current,
struct no%e 3next,
int testLM = *I+ E+ 2+ !+ 1+ 5+ + F+ O+ #4,
int i,
hea% = >CGG,
/3 insert some numbers into the lin.e% list 3/
for(i = #, i & 1#, i++)
hea% = a%%no%e(testLiM+ hea%),
/3 sort the list 3/
hea% = mergesort(hea%),
/3 print the list 3/
printf(- before after/n-)+ i = #,
for(current = hea%, current != >CGG, current = current2'next)
printf(-0%/t0%/n-+ testLi++M+ current2'number),
/3 free the list 3/
for(current = hea%, current != >CGG, current = next)
next = current2'next+ free(current),
/3 %one... 3/
return #,
4
/3 a%% a no%e to the lin.e% list 3/
struct no%e 3a%%no%e(int number+ struct no%e 3next) *
struct no%e 3tno%e,
tno%e = (struct no%e3)malloc(siVeof(3tno%e)),
if(tno%e != >CGG) *
tno%e2'number = number,
tno%e2'next = next,
4
return tno%e,
4
/3 preform merge sort on the lin.e% list 3/
struct no%e 3mergesort(struct no%e 3hea%) *
struct no%e 3hea%Tone,
struct no%e 3hea%Ttwo,
if((hea% == >CGG) [[ (hea%2'next == >CGG))
return hea%,
hea%Tone = hea%,
hea%Ttwo = hea%2'next,
while((hea%Ttwo != >CGG) 11 (hea%Ttwo2'next != >CGG)) *
hea% = hea%2'next,
hea%Ttwo = hea%2'next2'next,
4
hea%Ttwo = hea%2'next,
hea%2'next = >CGG,
return merge(mergesort(hea%Tone)+ mergesort(hea%Ttwo)),
4
/3 merge the lists.. 3/
struct no%e 3merge(struct no%e 3hea%Tone+ struct no%e 3hea%Ttwo) *
struct no%e 3hea%Tthree,
if(hea%Tone == >CGG)
return hea%Ttwo,
if(hea%Ttwo == >CGG)
return hea%Tone,
if(hea%Tone2'number & hea%Ttwo2'number) *
hea%Tthree = hea%Tone,
hea%Tthree2'next = merge(hea%Tone2'next+ hea%Ttwo),
4 else *
hea%Tthree = hea%Ttwo,
hea%Tthree2'next = merge(hea%Tone+ hea%Ttwo2'next),
4
return hea%Tthree,
4
Write a K program to convert %ecimal number into binarP numberQ
have here co%e to convert %ecimal to binarP number+ octal an% hexa in
K..he
re is the co%eH
$inclu%e &st%io.h'
voi% main()
*
voi% welcome(),
voi% co%e(),
int %,
int i=#+n+N+bL1##M,
printf(-/n/n/t/tKhooseH/n-),
printf(-/n/n/t/tL1M ?ecimal to JinarP/n-),
printf(-/t/tL2M ?ecimal to 8ctal/n-),
printf(-/t/tLEM ?ecimal to @exa%ecimal/n-),
printf(-/t/tLM Axit/n-),
printf(-/n/n/t/tAnter Pour choiceH -),
scanf(-0%-+ 1%),
switch(%)
*
case 1H
printf(-/n/t/tAnter %ecimal numberH -),
scanf(-0%-+ 1n),
while (n'#)
*
bLiM=n02,
n=n/2,
i++,
4
printf(-/n/t/tJinarP isH -),
N=i21,
for (i=N,N'=#,N22)
*
printf(-0%-+ bLNM),
4
brea.,
case 2H
printf(-/n/t/tAnter %ecimal numberH -),
scanf(-0%-+ 1n),
while (n'#)
*
bLiM=n0I,
n=n/I,
i++,
4
printf(-/n/t/t8ctal isH-),
N=i21,
for (i=N,N'=#,N22)
*
printf(-0%-+ bLNM),
4
brea.,
case EH
printf(-/n/t/tAnter %ecimal numberH -),
scanf(-0%-+ 1n),
while (n'#)
*
bLiM=n01!,
n=n/1!,
i++,
4
printf(-/n/t/t@exa%ecimal isH-),
N=i21,
for (i=N,N'=#,N22)
*
printf(-0%-+ bLNM),
if(bLNM&1#)
*
printf(-0%-+ bLNM),
4
else
*
switch(bLNM)
*
case 1#H
printf(-A-),
brea.,
case 11H
printf(-J-),
brea.,
case 12H
printf(-K-),
brea.,
case 1EH
printf(-?-),
brea.,
case 1H
printf(-A-),
brea.,
case 15H
printf(-<-),
brea.,
4
4
4
4
4
1: 55 $onvert a decima% inte9er do a binar> "trin9
@: 55 added a te"t printf() >o& can remove %ater
J: 55 T&rbo $ modified for 7e%%e" $ ve9a"eat 1Nnov@00K
K:
H: <inc%&de 1"tdio:hE
P:
F. voi% dec@bin(long decima%, char 6binar>);
Q:
O. int main()
1#. *
11. long decima%;
12. char binar>LQ0M;
1J:
1. printf("/n/n Enter an inte9er va%&e + ");
15. "canf(",%d",-decima%);
1!. dec@bin(decima%,binar>);
1F. printf("/n The binar> va%&e of ,%d i" ," /n",decima%,binar>);
1Q:
1O. 9etchar(); 55 trap enter
2#. 9etchar(); 55 !ait
21. return 0;
22. 4
@J:
@K: 55
@H: 55 accept" a decima% inte9er and ret&rn" a binar> coded "trin9
@P: 55
2F. voi% dec@bin(long decima%, char 6binar>)
2I. *
2O. int k 0 0, n 0 0;
E#. int ne9Ff%a9 0 0;
E1. int remain;
E2. int o%dFdecima%; 55 for te"t
EE. char tempLQ0M;
JK:
JH: 55 take care of ne9ative inp&t
E!. if (decima% 1 0)
EF. *
JQ: decima% 0 Ddecima%;
JN: ne9Ff%a9 0 1;
#. 4
1. %o
2. *
KJ: o%dFdecima% 0 decima%; 55 for te"t
KK: remain 0 decima% , @;
KH: 55 !hitt%e do!n the decima% n&mber
KP: decima% 0 decima% 5 @;
KO: 55 thi" i" a te"t to "ho! the action
I. printf(",d5@ 0 ,d remainder 0 ,d/n", o%dFdecima%, decima%, remain);
KN: 55 convert" di9it 0 or 1 to character G0G or G1G
5#. tempLk22M 0 remain 2 G0G;
51. 4 while (decima% E 0);
H@:
5E. if (ne9Ff%a9)
5. tempLk22M 0 GDG; 55 add D "i9n
55. else
5!. tempLk22M 0 G G; 55 "pace
HO:
HQ: 55 rever"e the "pe%%in9
5O. while (k E0 0)
!#. binar>Ln22M 0 tempLDDkM;
P1:
!2. binar>LnD1M 0 0; 55 end !ith ;=AA
!E. 4
Write a program to convert the binarP to %ecimal conversion bP using while
statementQ
$inclu%e&st%io.h'
$inclu%e&conio.h'
$inclu%e&math.h'
voi% main()
*
long int aL2#M+i+n+count=#+bL2#M+cL2#M+sum=#,
printf(-A>ter the number in binarP form=/t-),
scanf(-0l%-+1n), // 9et a binarP number from the user
for (i=#,n'=1,i++)
*
aLiM=n01#,
n=n/1#, // Goop ;o reverse the number An% put all reverse% numbers in arrP
aLiM
count=count + 1, // count to count the number of times this loop runs
4
for (i=#,i&=count21,i++) // count 21 con%ition is use% to run the loop till the
previous loop run
*
bLiM=pow(2+i), // ;his is to raise the power of 2 to no of times previous loop
runne%.
4
for (i=#,i&=count21,i++)
*
cLiM=aLiM 3 bLiM, // :ultiplP aLiM or reverese% binarP no with bLiM or increasing
pow of 2 to count21
sum=sum +cLiM, // it is to a%% the cLiM elements with each other n put into
sum variable.
4
printf(-?ecimal form =0l%-+sum), // printing the sum to get the %ecimal
form
getch(),
4
K programming co%e for newton raphson metho% to solve Rua%ratic
eRuationQ
>e"
Thi" i" the code" for ;e!tonDaph"on method for "o%vin9 W&adratic eq&ation"
<inc%&de1"tdio:hE
<inc%&de1conio:hE
<inc%&de1math:hE
<define ((*)(*6*6*)D(K6*)N
<define (?(*)(J6*6*)DK
<define )#C4T @0
void main()
{
int co&nt;
f%oat *0,*1,f*,fd*;
c%r"cr();
printf(";EMT';D#7U/'; )ETU'?.n");
printf("DDDDDDDDDDDDDDDDDDDDD.n");
printf("initia% va%&e+");
"canf(",f",*0);
co&nt01;
be9in+
f*0((*0);
fd*0(?(*0);
*10(*0D(f*5fd*));
if(fab"((*1D*0)5*1)10:00001)
{
printf("The root i"+,f.n",*1);
printf("4teration i"+,d.n",co&nt);
3
e%"e
{
*00*1;
co&nt0co&nt21;
if((co&nt1)#C4T));
9oto be9in;
3
9etch();
3
3 6rogram to fin% the roots of an ARuation f(x)=# using >ewton 2 7aphson
:etho% 3/
$inclu%e
$inclu%e
$inclu%e
float f(float),
float %f(float),
voi% main()
*
float x#+x1+%+eps,
int i+n,
clrscr(),
printf(-/n=nput the intial values H -),
scanf(-0f-+1x#),
printf(-/nAnter the number of =terations -),
scanf(-0%-+1n),
printf(-/n=nput the error of tolerance/n-),
scanf(-0f-+1eps),
printf(-=teration/t x#/t/t x1-),
for(i=#,i&>,=++)
*
x1=x#2f(x#)/%f(x#),
printf(-/n/t 0%/t0f/t0f/n-+i+x#+x1),
%=x12x#,
x#=x1,
if(%==eps)
*
brea.,
4
4
printf(-/n7oots of given eRuation = 0f-+x#),
getch(),
4
float f(float x)
*
float f,
f=cos(x)2x3exp(x),
return(f),
4
float %f(float x)
*
float %f,
%f=sin(x)2x3exp(x)2exp(x),
return(%f),
4
What is the c programming co%e for newton raphson eRuationQ
56pro9ramm for modified ne!ton raph"on method65
#include<stdio.h>
#include<math.h>
#define epsilon 1e-6
main()
{
/*This is a programm ased on modified
ne!ton raphson method to
find out root of the e"uation #$%-&*#$'()*#-%*+*/
doule g,g1,-,-1,-',#,d#.
int con-erged*+,i.
printf(/pl0 enter the guess -alue1n/).
scanf(/2f/,3g1).
i*1.
!hile (con-erged**+)
{
printf(/1n iteration no*2d1n/,i).
-*g1*g1*g1-&*g1*g1()*g1-%.
printf(/-*2lf1n/,-).
-1*%*g1*g1-1+*g1().
printf(/-1*2lf1n/,-1).
-'*6*g1-1+.
printf(/-'*2lf1n/,-').
#*(-*-1)/(-1*-1--*-').
printf(/-alue*2lf1n/,#).
g*g1-((-*-1)/(-1*-1--*-')).
printf(/ne! guess is*2lf1n/,g).
d#*((g-g1)/g).
printf(/error*2lf1n/,d#).
g1*g.
if (fas(d#)4less than4epsilon)
{con-erged*1.5
printf(/the root of e"uation is*2lf
i*2d1n/,g,i).
i*i(1.
5
5
6rg. to convert upper case to lower case or lower case to upper case
%epen%ing on the name it is invo.e% with as foun% in argument.
<inc%&de 1"tdio:hE
<inc%&de 1conio:hE
void %o!erFtoF&pper();
void &pperFtoF%o!er();
void main()
{
int n;
c%r"cr();
printf("
7%ea"e enter >o&r choice:");
printf("
(1) for &pper to %o!er conver"ion:");
printf("
(@) for %o!er to &pper conver"ion:");
printf("
$U'4$E+D ");
"canf(",d",-n);
"!itch (n)
{
ca"e 1+
{
printf("7%ea"e enter a "trin9 in &pper ca"e:");
printf("
/trin9 !i%% be terminated if >o& pre"" $tr%DX:");
printf("
/T4;S+D ");
&pperFtoF%o!er();
break;
3
ca"e @+
{
printf("7%ea"e enter a "trin9 in %o!er ca"e:");
printf("
/trin9 !i%% be terminated if >o& pre"" $tr%DX:");
printf("
/T4;S+D ");
%o!erFtoF&pper();
break;
3
defa&%t+
printf("E'");
3
printf("
U#VE # ;4$E ?#B8 IBE:");
9etch();
3
void &pperFtoF%o!er()
{
int i,j;
char cK[Q0],cJ;
for (i00;(cJ09etchar())80E'(;i22)
cK[i]0(cJE0G#G -- cJ10GXG)T(GaG 2 cJ DG#G)+cJ;
printf("
The %o!er ca"e eq&iva%ent i" ");
for (j00;j1i;j22)
p&tchar(cK[j]);
ret&rn;
3
void %o!erFtoF&pper()
{
int i,j;
char c@[Q0],c1;
for (i00;(c109etchar())80E'(;i22)
c@[i]0(c1E0GaG -- c110GRG)T(G#G 2 c1 DGaG)+c1;
printf("
The &pper ca"e eq&iva%ent i" ");
for (j00;j1i;j22)
p&tchar(c@[j]);
ret&rn;
3
Konvert string to upper case an% lower case
$inclu%e &ctPpe.h'
$inclu%e &st%io.h'
int main(voi%)
*
char strLI#M,
int i,
printf(-Anter a stringH -),
gets(str),
for( i = #, strL i M, i++)
strL i M = toupper( strL i M ),
printf(-0s/n-+ str), /3 uppercase string 3/
for(i = #, strL i M, i++)
strLiM = tolower(strL i M),
printf(-0s/n-+ str), /3 lowercase string 3/
return #,
}
@ow %o Pou write a K program to input a string of lowercase alphabets an%
convert it to uppercaseQ
Uere i" pro9ram code !ritten in p%ain $+
<inc%&de 1"tdio:hE
<inc%&de 1ct>pe:hE
void &p/trin9(char 6"tr);
int main() {
char "tr[100];
printf("Enter "trin9+ ");
9et"("tr);
&p/trin9("tr);
printf("=pper$a"e ver"ion+ ,".n", "tr);
ret&rn 0;
3
void &p/trin9(char 6"tr) {
re9i"ter int ind 0 0;
!hi%e ("tr[ind]) {
"tr[ind] 0 to&pper("tr[ind]);
ind22;
3
3
K <unction2Konvert ;o CpperKase 2 K 6rogramming

566666666666666666666666666666666
6 $onvert the to =pper$a"e 6
6666666666666666666666666666666665
void $onvertTo=pper$a"e(char 6 "tr)
{
int ch, i;
for(i00;i 1 "tr%en("tr); i22)
{
ch 0 to&pper("tr[i]);
"tr[i] 0 ch;
3
3
Write a c program to convert upper case letter to lower case letter without
using librarP functionQ
<inc%&de1"tdio:hE
<inc%&de1conio:hE
void main()
{
char ch;
c%r"cr();
printf("Enter a $haracter");
"canf(",c",-ch);
if(chE0PH -- ch10N0)
ch0ch2J@;
printf("=pper $a"e 0,c",ch);
9etch();
3
K pgm to convert lower case to upper case an% upper case ...
$inclu%e &st%io.h'
$inclu%e &st%lib.h'
/3
3 >otice that
3/
int Ttolower ( int ch )
*
unsigne% char Tch = (unsigne% char)ch '' ,
/3 =f K@ is alrea%P in lower case+ return it 3/
if ( Tch == #x! [[ Tch == #xF )
return ch,
/3 convert it to lower case 3/
if ( Tch == #x )
return (int)( ( (unsigne% char)ch 1 #x#f ) [ #x!# ),
else
if ( Tch == #x5 )
return (int)( ( (unsigne% char)ch 1 #x#f ) [ #xF# ),
else
return ch,
4
int Ttoupper ( int ch )
*
unsigne% char Tch = (unsigne% char)ch '' ,
/3 =f K@ is alrea%P in upper case+ return it 3/
if ( Tch == #x [[ Tch == #x5 )
return ch,
/3 convert it to upper case 3/
if ( Tch == #x! )
return (int)( ( (unsigne% char)ch 1 #x#f ) [ #x# ),
else
if ( Tch == #xF )
return (int)( ( (unsigne% char)ch 1 #x#f ) [ #x5# ),
else
return ch,
4
int main ( voi% )
*
printf ( -0c/n-+ Ttoupper ( U+U ) ),
printf ( -0c/n-+ Ttoupper ( UrU ) ),
printf ( -0c/n-+ Ttoupper ( UlU ) ),
printf ( -0c/n-+ Ttoupper ( U6U ) ),
printf ( -0c/n-+ Ttolower ( U\U ) ),
printf ( -0c/n-+ Ttolower ( U7U ) ),
printf ( -0c/n-+ Ttolower ( U8U ) ),
printf ( -0c/n-+ Ttolower ( UOU ) ),
return #,
4
K program to implement the linear regression algorithm
$inclu%e
$inclu%e
$inclu%e
$inclu%e
float mean(float 3a+ int n),
voi% %eviation(float 3a+ float mean+ int n+ float 3%+ float 3B),
voi% main()
*
float aL2#M+bL2#M+%xL2#M+%PL2#M,
float sP=#+sx=#+meanTx=#+meanTP=#+sumTxP=#,
float corrTcoff=#+regTcoffTxP=#+ regTcoffTPx=#,
char tPpeTcoffLFM,
int n=#+i=#,
clrscr(),
printf(-Anter the value of nH -),
scanf(-0%-+1n),
printf(-Anter the values of x an% PH/n-),
for(i=#,i&>,=++)
scanf(-0f0f-+1aLiM+1bLiM),
meanTx=mean(a+n),
meanTP=mean(b+n),
%eviation(a+meanTx+n+%x+1sx),
%eviation(b+meanTP+n+%P+1sP),
for(i=#,i&>,=++)
sumTxP=sumTxP+%xLiM3%PLiM,
corrTcoff=sumTxP/(n3sx3sP),
printf(-Anter the tPpe of regression coefficient as Ux on PU or UP on xUH -),
fflush(st%in),
gets(tPpeTcoff),
if(strcmp(tPpeTcoff+-x on P-)==1)
*
regTcoffTxP=corrTcoff3(sx/sP),
printf(-/n;he value of linear regression coefficient is 0f-+regTcoffTxP),
4
else if(strcmp(tPpeTcoff+-P on x-)==1)
*
regTcoffTPx=corrTcoff3(sP/sx),
printf(-/n;he value of linear regression coefficient is 0f-+regTcoffTPx),
4
else
printf(-/nAnter the correct tPpe of regression coefficient.-),
getch(),
4
float mean(float 3a+ int n)
*
float sum=#+ i=#,
for(i=#,i&>,=++)
sum=sum+aLiM,
sum=sum/n,
return (sum),
4
voi% %eviation(float 3a+ float mean+ int n+ float 3%+ float 3s)
*
float sum=#+t=#,
int i=#,
for(i=#,i&>,=++)
*
%LiM=aLiM2mean,
t=%LiM3%LiM,
sum=sum+t,
4
sum=sum/n,
3s=sRrt(sum),
4
K program that implement =nsertion sort to sort a given list of integers in
ascen%ing or%er
$inclu%e
$inclu%e
voi% instTsort(int LM),
voi% main()
*
int numL5M+count,
clrscr(),
printf(-/nAnter the <ive Alements to sortH/n-),
for (count=#,count&5,count++)
scanf(-0%-+1numLcountM),
instTsort(num),
printf(-/n/nAlements after sortingH /n-),
for(count=#,count&5,count++)
printf(-0%/n-+numLcountM),
getch(),
4
// <unction for =nsertion Borting
voi% instTsort(int numLM)
*
int i+N+.,
for(N=1,N&5,N++)
*
.=numLNM,
for(i=N21,i'=# 11 .&>C:L=M,=22)
numLi+1M=numLiM,
numLi+1M=.,
4
4
Sa&""DLordan E%imination
(&nction for performin9 Sa&""DLordan e%imination to obtain the "o%&tion to a
">"tem of %inear eq&ation", inc%&din9 matri* inver"ion: (or do&b%e arra>" on%>
56666666666666666666666666666666666666666666666666666666666666666666666666666665
56 7erform Sa&""DLordan e%imination !ith ro!Dpivotin9 to obtain the "o%&tion to
6 the ">"tem of %inear eq&ation"
6 # C 0 I
6
6 #r9&ment"+
6 %h" D %eftDhand "ide of the eq&ation, matri*
#
6 rh" D ri9htDhand "ide of the eq&ation, matri*
I
6 nro!" D n&mber of ro!" in the arra>" %h" and rh"
6 nco%"rh"D n&mber of co%&mn" in the arra> rh"
6
6 The f&nction &"e" Sa&""DLordan e%imination !ith pivotin9: The "o%&tion C to
6 the %inear ">"tem !ind" &p "tored in the arra> rh"; create a cop> to pa"" to
6 the f&nction if >o& !i"h to retain the ori9ina% U/ arra>:
6
6 7a""in9 the identit> matri* a" the rh" ar9&ment re"&%t" in the inver"e of
6 matri* #, if it e*i"t":
6
6 ;o %ibrar> or header dependencie", b&t req&ire" the f&nction "!apro!", !hich
6 i" inc%&ded here:
65
55 "!apro!" D e*chan9e" the content" of ro!0 and ro!1 in a @d arra>
void "!apro!"(do&b%e66 arr, %on9 ro!0, %on9 ro!1) {
do&b%e6 temp;
temp0arr[ro!0];
arr[ro!0]0arr[ro!1];
arr[ro!1]0temp;
3
55 9je%im
void 9je%im(do&b%e66 %h", do&b%e66 rh", %on9 nro!", %on9 nco%"rh") {
55 a&9ment %h" arra> !ith rh" arra> and "tore in arr@
do&b%e66 arr@0ne! do&b%e6[nro!"];
for (%on9 ro!00; ro!1nro!"; 22ro!)
arr@[ro!]0ne! do&b%e[nro!"2nco%"rh"];
for (%on9 ro!00; ro!1nro!"; 22ro!) {
for (%on9 co%00; co%1nro!"; 22co%) {
arr@[ro!][co%]0%h"[ro!][co%];
3
for (%on9 co%0nro!"; co%1nro!"2nco%"rh"; 22co%) {
arr@[ro!][co%]0rh"[ro!][co%Dnro!"];
3
3
55 perform for!ard e%imination to 9et arr@ in ro!Deche%on form
for (%on9 dinde*00; dinde*1nro!"; 22dinde*) {
55 r&n a%on9 dia9ona%, "!appin9 ro!" to move Rero" in !orkin9 po"ition
55 (a%on9 the dia9ona%) do!n!ard"
if ( (dinde*00(nro!"D1)) -- (arr@[dinde*][dinde*]000)) {
ret&rn; 55 no "o%&tion
3 e%"e if (arr@[dinde*][dinde*]000) {
"!apro!"(arr@, dinde*, dinde*21);
3
55 divide !orkin9 ro! b> va%&e of !orkin9 po"ition to 9et a 1 on the
55 dia9ona%
if (arr@[dinde*][dinde*] 00 0:0) {
ret&rn;
3 e%"e {
do&b%e tempva%0arr@[dinde*][dinde*];
for (%on9 co%00; co%1nro!"2nco%"rh"; 22co%) {
arr@[dinde*][co%]50tempva%;
3
3
55 e%iminate va%&e be%o! !orkin9 po"ition b> "&btractin9 a m&%tip%e of
55 the c&rrent ro!
for (%on9 ro!0dinde*21; ro!1nro!"; 22ro!) {
do&b%e !va%0arr@[ro!][dinde*];
for (%on9 co%00; co%1nro!"2nco%"rh"; 22co%) {
arr@[ro!][co%]D0!va%6arr@[dinde*][co%];
3
3
3
55 back!ard "&b"tit&tion "tep"
for (%on9 dinde*0nro!"D1; dinde*E00; DDdinde*) {
55 e%iminate va%&e above !orkin9 po"ition b> "&btractin9 a m&%tip%e of
55 the c&rrent ro!
for (%on9 ro!0dinde*D1; ro!E00; DDro!) {
do&b%e !va%0arr@[ro!][dinde*];
for (%on9 co%00; co%1nro!"2nco%"rh"; 22co%) {
arr@[ro!][co%]D0!va%6arr@[dinde*][co%];
3
3
3
55 a""i9n re"&%t to rep%ace rh"
for (%on9 ro!00; ro!1nro!"; 22ro!) {
for (%on9 co%00; co%1nco%"rh"; 22co%) {
rh"[ro!][co%]0arr@[ro!][co%2nro!"];
3
3
for (%on9 ro!00; ro!1nro!"; 22ro!)
de%ete[] arr@[ro!];
de%ete[] arr@;
3
56666666666666666666666666666666666666666666666666666666666666666666666666666
6 Sa&""F/eide%@:cpp 6
6 6
6 /o%ve" a ">"tem of %inear eq&ation" &"in9 Sa&""D/eide% iteration 6
6 6
6
6 "amp%e te"t that i &"e i" matri* # 0 O D@ 1 @ I 0 J 6
6 @ Q J 1 D@ 6
6 D1 0 H @ H 6
6 0 @ D1 K K 6
6 6
6 the "o%&tion for * "ho&%d be print %ike thi" + D0:@ D0:H 0:K 1:K 6
66666666666666666666666666666666666666666666666666666666666666666666666666665
<inc%&de 1"tdio:hE
<inc%&de 1"td%ib:hE
<inc%&de "mpi:h"
<inc%&de 1math:hE
<define /!ap(*,>) {f%oat6 temp; temp 0 *; * 0 >; > 0 temp;3
<define )#C 1@
56 <define to%erance 0:0001 65
f%oat ?i"tance(f%oat *[], f%oat >[], int n) {
int i;
f%oat "&m 0 0:0;
for (i 0 0; i 1 n; i22) {
"&m 0 "&m 2 (*[i] D >[i])6(*[i] D >[i]);
3
ret&rn (f%oat)"qrt("&m);
3
55 Thi" !i%% read the matri*
void eadFmatri*(char6 prompt, f%oat #[)#C][)#C], int n, int m>Frank, int proc)
{
int i, j;
f%oat temp[)#C][)#C];
int nFbar;

nFbar 0 n5proc;
55 (i%% d&mm> entrie" in temp !ith Reroe"
for (i 0 0; i 1 n; i22)
for (j 0 n; j 1 )#C; j22)
temp[i][j] 0 0:0;
if (m>Frank 00 0) {
printf(",".n", prompt);
for (i 0 0; i 1 n; i22)
for (j 0 0; j 1 n; j22)
"canf(",f",-temp[i][j]);
3
55/catter temp to # from proce"" 0
)74F/catter(temp, nFbar6)#C, )74F(A'#T, #, nFbar6)#C, )74F(A'#T, 0,
)74F$'))FM'A?);
3
55Thi" !i%% read the vector *
void eadFvector(char6 prompt, f%oat *[], int n, int m>Frank, int proc)
{
int i;
f%oat temp[)#C];
int nFbar;

nFbar 0 n5proc;
if (m>Frank 00 0)
{
printf(",".n", prompt);
for (i 0 0; i 1 n; i22)
"canf(",f", -temp[i]);
3
55/catter temp to * from proce"" 0
)74F/catter(temp, nFbar, )74F(A'#T, *, nFbar, )74F(A'#T, 0,
)74F$'))FM'A?);
3
void main(int ar9c, char6 ar9v[])
{
55)ain 7roce""
int proc;
int m>Frank;
f%oat #[)#C][)#C];
f%oat *[)#C];
f%oat I[)#C];
int n;
55(%oat to%erance;
int ma*Fiteration;
55Sa&""D/eide% 4teration (&nction
int iteration 0 0;
int i, j;
f%oat %a"tFiteration[)#C];
f%oat "i9ma1, "i9ma@;
f%oat prece"ion;
int k;
55?i"p%a>in9 arra>"
int i;
f%oat temp[)#C];
)74F4nit(-ar9c, -ar9v);
)74F$ommF"iRe()74F$'))FM'A?, -proc);
)74F$ommFrank()74F$'))FM'A?, -m>Frank);
if (m>Frank 00 0)
{
">"tem("c%"");
printf("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD.n");
printf("7ro9ram !i%% perform Sa&""D/eide% 4teration )ethod to "o%ve
Ainear Eq&ation .n");
printf("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD.n");
printf("Enter variab%e n and ma* n&mber of iteration"+ .n.n");
"canf(",d ,d", -n, -ma*Fiteration);
3
55Iroadca"t n - ma*im&m iteration to a%% other proce""
)74FIca"t(-n, 1, )74F4;T, 0, )74F$'))FM'A?);
)74FIca"t(-ma*Fiteration, 1, )74F4;T, 0, )74F$'))FM'A?);
nFbar 0 n5proc;
55(i%% the matri* and the vector
eadFmatri*(".n4n"ert the variab%e for the matri* # .n", #, n, m>Frank, proc);
eadFvector(".nEnter the ri9htDhand "ide of I .n", I, n, m>Frank, proc);
55 4nitia%iRe *

)74F#%%9ather(I, nFbar, )74F(A'#T, k, nFbar, )74F(A'#T,
)74F$'))FM'A?);

55$a%c&%ate req&e"ted preci"ion and ma*im&m iteration"
prece"ion 0 po!(10:0, D(f%oat)k);
ma*Fiteration" 0 (int)po!(10:0, (f%oat)k);
55 4nitia%iRe %a"tFiteration matri* to Rero
for (i00; i1)#C; i22)
%a"tFiteration[i] 0 0:0;
55$a%c&%ate iteration"
do
{
55$a%c&%ate the ne*t iteration
for (i00; i1)#C; i22)
{
55$omp&te /i9ma(j+j1i)(#(i,j) 6 *(j)(n))
"i9ma1 0 0:0;
for (j00; j1i; j22)
"i9ma1 20 #[i][j] 6 *[j];
55$omp&te /i9ma(j+jEi)(#(i,j) 6 *(j)(nD1))
"i9ma@ 0 0:0;
for (j0i21; j1)#C; j22)
"i9ma@ 20 #[i][j] 6 %a"tFiteration[j];
55$omp&te the va%&e of thi" iteration
*[i] 0 (I[i] D "i9ma1 D "i9ma@) 5 #[i][i];
3
55(i9&re o&t if !eGre done >et
done 0 T=E;
for (i00; i1)#C; i22)
done -0 fab"(*[i] D %a"tFiteration[i]) 1 (prece"ion 6 fab"(*[i]));
55if an> entr> i" 9reater than EAE)E;TF)#C, an overf%o! ha" occ&rred,"o
abort
for (i00; i1)#C; i22)
if ((*[i] E0 EAE)E;TF)#C) YY (*[i] 10 DEAE)E;TF)#C))
ret&rn 0;
554ncrement the iteration co&nt
iteration22;
554f iteration co&nt e*ceed" ma*im&m n&mber of iteration", abort
if (iteration E ma*Fiteration")
ret&rn 0;
55$op> the c&rrent iteration to the %a"t iteration vector
(void)memcp>(%a"tFiteration, *, "iReof(f%oat) 6 )#C);
3 !hi%e (8done);
56 !e !ere "&cce""f&% 65
ret&rn iteration;
3

)74F#%%9ather(*, nFbar, )74F(A'#T, k, nFbar, )74F(A'#T,
)74F$'))FM'A?);
)74FSather(*, nFbar, )74F(A'#T, temp, nFbar, )74F(A'#T, 0,
)74F$'))FM'A?);
if(m>Frank000)
{
printf(".n,d) ",iterationFn&m);
for (i 0 0; i 1 n; i22)
printf(".t,K:Hf ", temp[i]);
printf(".n");
3
3
!hi%e ((iterationFn&m 1 ma*Fiteration) -- (?i"tance(k,n) E0 prece"ion));
if (?i"tance(k,n) 1 prece"ion)
{
)74FSather(*, nFbar, )74F(A'#T, temp, nFbar, )74F(A'#T, 0,
)74F$'))FM'A?);
if (m>Frank 00 0)
{
printf(".nThe "o%&tion for Sa&""D/eide% 4teration )ethod
i".n"); 55?i"p%a> /o%&tion
for (i 0 0; i 1 n; i22)
printf(",K:1f ", temp[i]);
printf(".n");
3
3
e%"e
if (m>Frank 00 0)
printf("(ai%ed to conver9e in ,d iteration".n", ma*Fiteration);
)74F(ina%iRe(); 55End 7roce""
3
Write a c program to implement tower of hanoiQ
<inc%&de1"tdio:hE
<inc%&de1conio:hE
<inc%&de1math:hE
void hanoi(int *, char from,char to,char a&*)
{
if(*001)
{
printf(")ove ?i"k (rom ,c to ,c.n",from,to);
3
e%"e
{
hanoi(*D1,from,a&*,to);
printf(")ove ?i"k (rom ,c to ,c.n",from,to);
hanoi(*D1,a&*,to,from);
3
3
void main()
{
int di"k;
int move";
c%r"cr();
printf("Enter the n&mber of di"k" >o& !ant to p%a> !ith+");
"canf(",d",-di"k);
move"0po!(@,di"k)D1;
printf(".nThe ;o of move" req&ired i"0,d .n",move");
hanoi(di"k,G#G,G$G,GIG);
9etch();
3
Write the program of tower of @anoi in c languageQ
56 hanoi:c 65
<inc%&de 1"tdio:hE
<inc%&de 1"td%ib:hE
"tatic %on9 "tep;
"tatic void Uanoi (int n, int from, int to,int "pare)
{
if (nE1) Uanoi (nD1,from,"pare,to);
printf ("/tep ,%d+ move <,d ,dDDE,d.n", 22"tep, n, from, to);
if (nE1) Uanoi (nD1,"pare,to,from);
3
int main (int ar9c, char 66ar9v)
{
int n;
if (ar9c001 YY (n0 atoi(ar9v[1]))000) n0 H;
"tep0 0;
Uanoi (n, 1, @, J);
ret&rn 0;
3
K programming of 7unge2Sutta metho%Q
67897A: H2
/3 7unge Sutta for a set of first or%er %ifferential eRuations 3/
$inclu%e &st%io.h'
$inclu%e &math.h'
$%efine > 2 /3 number of first or%er eRuations 3/
$%efine %ist #.1 /3 stepsiVe in t3/
$%efine :AD E#.# /3 max for t 3/
<=GA 3output, /3 internal filename 3/
main()
*
%ouble t+ PL>M,
int N,
voi% runge(%ouble x+ %ouble PLM+ %ouble step), /3 7unge2Sutta function 3/
%ouble f(%ouble x+ %ouble PLM+ int i), /3 function for %erivatives 3/
output=fopen(-osc.%at-+ -w-), /3 external filename 3/
PL#M=1.#, /3 initial position 3/
PL1M=#.#, /3 initial velocitP 3/
fprintf(output+ -#/t0f/n-+ PL#M),
for (N=1, N3%ist&=:AD ,N++) /3 time loop 3/
*
t=N3%ist,
runge(t+ P+ %ist),
fprintf(output+ -0f/t0f/n-+ t+ PL#M),
4
fclose(output),
4
voi% runge(%ouble x+ %ouble PLM+ %ouble step)
*
%ouble h=step/2.#+ /3 the mi%point 3/
t1L>M+ t2L>M+ tEL>M+ /3 temporarP storage arraPs 3/
.1L>M+ .2L>M+ .EL>M+.L>M, /3 for 7unge2Sutta 3/
int i,
for (i=#,i&>,i++) t1LiM=PLiM+#.53(.1LiM=step3f(x+ P+ i)),
for (i=#,i&>,i++) t2LiM=PLiM+#.53(.2LiM=step3f(x+h+ t1+ i)),
for (i=#,i&>,i++) tELiM=PLiM+ (.ELiM=step3f(x+h+ t2+ i)),
for (i=#,i&>,i++) .LiM= step3f(x+step+ tE+ i),
for (i=#,i&>,i++) PLiM+=(.1LiM+23.2LiM+23.ELiM+.LiM)/!.#,
4
%ouble f(%ouble x+ %ouble PLM+ int i)
*
if (i==#) return(PL1M), /3 %erivative of first eRuation 3/
if (i==1) return(2#.23PL1M2PL#M), /3 %erivative of secon% eRuation 3/
4
1. -* ; =unge/>utta Method for solving ?i##erential 7@uations*-
.. -* d:-dt = /:(t), :()=$, <=!<=A, start h=.$*-
J:
K: <inc%&de 1"tdio:hE
H:
P: <define di"t 0:1 56 "tep"iRe 65
F. <define *f H 56 ma* for * 65
Q:
N:
10: (4AE 6o&tp&t; -* internal #ilename *-
11:
12. %ouble rk&tta( %ouble *, %ouble >, %ouble h); -*=unge Kutta Bunction
*-
1E. %ouble ((%ouble *, %ouble >); -*Bunction derivative*-
1K:
15. main()
1!. *
1F. %ouble *, >, h;
1I. int n;
1N:
2#. o&tp&t0fopen("*>data:dat", "!"); -* 7!ternal #ilename *-
@1: h00:1;
@@: >01; -* Cnitial condition *-
2E. fprintf(o&tp&t, "0/t,f/n", >);
@K:
25. for (n00;di"t6n10*f;n22) -* Dhe time loo0 *-
2!. *
@O: *0n6di"t;
2I. >D0rk&tta(*, >, di"t);
@N:
E#. fprintf (o&tp&t, ",f/t,f/n", *, >);
E1. 4
J@:
EE. fc%o"e(o&tp&t);
E. 4 -* 7nd o# main #unction*-
JH:
E!. %ouble rk&tta(%ouble *, %ouble >, %ouble h) -*Ealled on => #unction*-
EF. *
EI. %ouble >n, k1, k@, kJ, kK;
EO. %ouble U 0 h5@:0;
K0:
1. k1 0 (h6((*, >));
2. k@ 0 (h6((*2U, >2(k15@)));
E. kJ 0 (h6((*2U, >2(k@5@)));
. kK 0 (h6((*2h, >2kJ));
5. return(>20(>2(k12@6k@2@6kJ2kK)615P));
!. 4
KO:
KQ:
O. %ouble ((%ouble *, %ouble >) -*Ealled on derivative*-
H0:
51. *
52. return (>);
HJ:
HK:
HH:
HP:
HO:
HQ:
HN:
P0:
!1. 4
/3 7unge Sutta for a set of first or%er %ifferential eRuations 3/
<inc%&de 1"tdio:hE
<inc%&de 1math:hE
$%efine > 2 /3 number of first or%er eRuations 3/
$%efine %ist #.1 /3 stepsiVe in t3/
$%efine :AD E#.# /3 max for t 3/

(4AE 6o&tp&t; 56 interna% fi%ename 65
voi% runge(%ouble x+ %ouble PLM+ %ouble step); 56 &n9eDZ&tta f&nction 65
%ouble f(%ouble x+ %ouble PLM+ int i); 56 f&nction for derivative" 65
main()
{
do&b%e t, >[;];
int j;

o&tp&t0fopen("o"c:dat", "!"); 56 e*terna% fi%ename 65
>[0]01:0; 56 initia% po"ition 65
>[1]00:0; 56 initia% ve%ocit> 65
fprintf(o&tp&t, "0.t,f.n", >[0]);

for (j01; j6di"t10)#C ;j22) 56 time %oop 65
{
t0j6di"t;
r&n9eK(t, >, di"t);
fprintf(o&tp&t, ",f.t,f.n", t, >[0]);
3
fclose(output);
3
voi% runge(%ouble x+ %ouble PLM+ %ouble step)
{
do&b%e h0"tep5@:0, 56 the midpoint 65
t1[;], t@[;], tJ[;], 56 temporar> "tora9e arra>" 65
k1[;], k@[;], kJ[;],kK[;]; 56 for &n9eDZ&tta 65
int i;

for (i00;i1;;i22) t1[i]0>[i]20:H6(k1[i]0"tep6f(*, >, i));
for (i00;i1;;i22) t@[i]0>[i]20:H6(k@[i]0"tep6f(*2h, t1, i));
for (i00;i1;;i22) tJ[i]0>[i]2 (kJ[i]0"tep6f(*2h, t@, i));
for (i00;i1;;i22) kK[i]0 "tep6f(*2"tep, tJ, i);
for (i00;i1;;i22) >[i]20(k1[i]2@6k@[i]2@6kJ[i]2kK[i])5P:0;
3
%ouble f(%ouble x+ %ouble PLM+ int i)
{
if (i000) ret&rn(>[1]); 56 derivative of fir"t eq&ation 65
if (i001) ret&rn(D0:@6>[1]D>[0]); 56 derivative of "econd eq&ation 65
3
;he K co%e to implement Simpo!" Ru#e. ;he number of steps is ta.en to
be 2#.
<inc%&de 1math:hE
<inc%&de 1"tdio:hE
$%efine > 2#
$%efine a #.#
$%efine b 2.#
%ouble f(%ouble x);
main()
{
int c, k01; 56 $o&nter" in the a%9orithm 65
do&b%e *, h, /=);
56 (4AE 6fp; ?ec%are" a pointer to a fi%e 65
56 fp0fopen(""imp"on:o&t","!"); 'pen" the fi%e for o&tp&t of data 65
printf(".n/imp"onG" &%e for n&merica% inte9ration of f(*).n");
printf(".n (rom a0,%f to b0,%f", a,b);
printf(".n.n4nterva%".t.t/tep /iRe.t.t/imp"on /&m.n");
/=)0f(a); 56 4nitia% f&nction va%&e 65
c0@;
h0(bDa)5;; 56 /tep "iRe h0(bDa)5; 65
!hi%e (k 10 ;D1) 56 /tep" thro&9h the iteration 65
{
c0PDc; 56 9ive" the K,@,K,@,::: in the a%9orithm 65
/=) 0 /=) 2 c6f(a2k6h); 56 #dd" on the ne*t area 65
k22; 56 4ncrea"e" k, the no: of "tep" taken, b> 1 65
3
/=) 0 ( /=) 2 f(b) )6h5J ; 56 add the va%&e f(b) to the "&m and m&%tip%>65
56 b> overa%% factor, h5J 65
printf(",d .t.t,%f .t.t,%f.n", ;, h, /=) ); 56 print the an"!er 65

56 the G.tG here i" j&"t to format the o&tp&t: 4t corre"pond" to hittin9
the T#I ke> on the ke>board ie: "kip" a n&mber of "pace" before printin9
the ne*t o&tp&t:
65
3
%ouble f(%ouble x)
{
do&b%e f&nction;
f&nction 0 *6*6*6*;
ret&rn(f&nction);
3

Das könnte Ihnen auch gefallen