0% found this document useful (0 votes)
140 views31 pages

C Pattern Program

The document contains code snippets for various C programming concepts like arithmetic operations, variable swapping, if-else conditional statements, for loops, functions, arrays, sorting, factorials, Fibonacci series, temperature conversion, call by value vs. reference, and simple interest calculation. It provides examples to demonstrate basic programming constructs in C like input/output, variables, data types, control flow, functions, arrays etc.

Uploaded by

Saurav Naruka
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
140 views31 pages

C Pattern Program

The document contains code snippets for various C programming concepts like arithmetic operations, variable swapping, if-else conditional statements, for loops, functions, arrays, sorting, factorials, Fibonacci series, temperature conversion, call by value vs. reference, and simple interest calculation. It provides examples to demonstrate basic programming constructs in C like input/output, variables, data types, control flow, functions, arrays etc.

Uploaded by

Saurav Naruka
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 31

//print hello

#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("Hello");
getch();
}
program to perform all arithmetic operations
#include<stdio.h>
#include<conio.h>
float a,;
!oid main()
{
printf("enter no."n");
scanf("#f#f",$a,$);
printf("%um is & #'.'f"n",a();
printf(")ifference is & #'.'f"n",a*);
printf("+ultiplication is & #'.'f"n",a,);
printf(")icision is & #'.'f",a/);
getch();
}
*******************************************************
%-apping using . !ariale
#include<stdio.h>
#include<conio.h>
int main()
{
int a,,c;
printf("/nter first !ariales "n");
scanf("#d",$a);
printf("/nter second !ariles "n");
scanf("#d",$);
printf("efore s-apping numers are &"n a 0 #d"n 0 #d",a,);
c0a;
a0;
0c;
printf(""n1fter s-apping numers are &"n a 0 #d"n 0 #d",a,);
getch();
}
output&
/nter first !ariales
2
/nter second !ariles
'
efore s-apping numers are &
a 0 2
0 '
1fter s-apping numers are &
a 0 '
0 2
%-apping using ' !ariale
#include<stdio.h>
#include<conio.h>
int main()
{
int a,;
printf("/nter first !ariales "n");
scanf("#d",$a);
printf("/nter second !ariles "n");
scanf("#d",$);
printf("efore s-apping numers are &"n a 0 #d"n 0 #d",a,);
a 0 a(;
0 a*;
a 0 a*;
printf(""n1fter s-apping numers are &"n a 0 #d"n 0 #d",a,);
getch();
}
//output&
/nter first !ariales
2
/nter second !ariles
'
efore s-apping numers are &
a 0 2
0 '
1fter s-apping numers are &
a 0 '
0 2
program to compare t-o no.(if)
#include<stdio.h>
#include<conio.h>
int a,;
!oid main()
{
printf("enter no.");
scanf("#d#d",$a,$);
if(a00)
{
printf("no. are e3ual");
}
getch();
}
program to compare t-o no.(if, else)
#include<stdio.h>
#include<conio.h>
int a,;
!oid main()
{
printf("enter no.");
scanf("#d#d",$a,$);
if(a00)
{
printf("no. are e3ual");
}
else
{
printf("no. are not e3ual");
}
}
getch();
}
program to compare t-o no.(if, else)
#include<stdio.h>
#include<conio.h>
int a,;
!oid main()
{
printf("enter no.");
scanf("#d#d",$a,$);
if(a00)
{
printf("no. are e3ual");
}
else if (a>)
{
printf("#d is greater",a);
}
else
{
printf("#d is greater",);
}
getch();
}
program to compare t-o no.using nested if (if, else if)
#include<stdio.h>
#include<conio.h>
int a,;
!oid main()
{
printf("enter no.");
scanf("#d#d",$a,$);
if(a00)
{
printf("no. are e3ual");
}
else
{
if(a>)
{
printf("#d is greater",a);
printf(""n#d is least",);
}
else
{
printf("#d is greater",);
printf(""n#d is least",a);
}
}
getch();
}
program to print nos. from 2 to 24,/
#include<stdio.h>
#include<conio.h>
int i;
int main()
{

printf("nos. from 2 to 24"n");
for(i02;i<024;i(()
{
printf("#d"n",i);
}
printf(""n");
getch();
}
program to print odd nos.
#include<stdio.h>
#include<conio.h>
int i;
int main()
{

printf(" odd nos."n");
for(i02;i<024;i0i(')
{
printf("#d"n",i);
}
printf(""n");
getch();
}
5utput&
odd nos.
2
.
6
7
8
program to impliment s-itch case
#include<stdio.h>
#include<conio.h>
#include<process.h>
int i;
int main()
{
printf("enter i");
scanf("#d",$i);
s-itch(i)
{
case 2&
printf("i am in case 2");
rea9;
case '&
printf("i am in case '");
rea9;
case .&
printf("i am in case .");
rea9;
default&
e:it(4);
}
getch();
}
goto
#include<stdio.h>
#include<conio.h>
!oid main()
{
int a,;
clrscr();
printf(""tenter the !alue of a");
scanf("#d",$a);
printf(""tenter the !alue of ");
scanf("#d",$);
if(a>)
{
goto statement2;
}
else
{
goto statement';
}
statement2&
printf(""tgreater !alue is a that is #d",a);
goto end;
statement'&
printf(""tgreater !alue is that is #d",);
end&
getch();
}
continue
#include<stdio.h>
#include<conio.h>
!oid main()
{
clrscr();
for(int i 0 2 ; i<024 ;i(()
{
if(i 00 ;)
{
continue;
}
printf(""nthe !alue of i is #d",i);
}
getch();
}
<rogram to calculate a!erage using arra=
#include<stdio.h>
#include<conio.h>
int main()
{

int arra=>6?,i,n,sum04;
float a!g;
printf("Ho- much numers =ou -ant to e a!eraged & ");
scanf("#d",$n);
for(i04;i<n;i(()
{
scanf("#d",$arra=>i?);
sum0sum(arra=>i?;
}
a!g0sum/n;
printf("1!erage0#'.'f"n",a!g);
getch();
}
program for arra= sorting (deceding order)
#include<stdio.h>
#include<conio.h>
long int :>'4?,i,@,temp;
int main()
{

printf(""t"t"t /nter fi!e numers "n");
for(i04;i<6;i(()
scanf("#lu",$:>i?);
printf(""t"t"tAefore sorting "n");
for(i04;i<6;i(()
printf("#lu"n",:>i?);

//,,,,,,,,,,,)escending sorting,,,,,,,,
for(i04;i<6;i(()
for(@04;@<6;@(()
if(:>i?>:>@?)
{
/, if -e -ant it 1scending then
onl= change !alue of condition in
if statement change it to "if(arra=>i?<arra=>@?"
,/
temp0:>i?; // s-aping
:>i?0:>@?; // s-aping
:>@?0temp; // s-aping
}
printf(""t"t"t1fter sorting "n");
for(i04;i<6;i(()
printf("#lu"n",:>i?);
getch();
}
program to calculate factorial
#include<stdio.h>
#include<conio.h>
long int n,i,f02;
int main()
{
printf("/nter numer & ");
scanf("#ld",$n);

for(i02;i<0n;i(()
{
f0f,i;
}
printf("Bactorial is & #ld",f);
getch();
return(4);
}
program to calculate factorial using recursi!e function
#include<stdio.h>
#include<conio.h>
long int n,f;
long int fac(long int n);
int main()
{
printf("/nter numer -hom =ou -ant factorial & ");
scanf("#ld",$n);
f0n,fac(n*2);
printf("factorial is #ld",f);
getch();
return 4;
}
long int fac(long int n)
{
if(n004)
return 4;
if(n002)
return 2;
else
return n,fac(n*2);
}
<rogram to <rint Bionacci series
#include<stdio.h>
#include<conio.h>
int main()
{
int i,902,@,sum04,n;
printf("enter limit & ");
scanf("#d",$n);
printf("se3uence is &*"n");
for(i02;i<0n;i(()
{
@09;
90sum;
sum09(@;
printf("#d,",sum);
}
getch();
}
5utput&
enter limit & 2.
se3uence is &*
2,2,',.,6,C,2.,'2,.D,66,C8,2DD,'..,
program to con!ert tempreture from EBarenheit to FelciusG or EFelcius to BahrenheitG

#include<stdio.h>
#include<conio.h>
int choice,a;
float f,fare,c,cel;

!oid ftoc();
!oid ctof();
int main()
{
printf(""t"t"tHempreture Falculator"n");
printf(""t"t<ress 2. to Fon!ert Barenheit to Felcius"n");
printf(""t"t<ress '. to Fon!ert Felcius to Barenheit"n");
printf("/nter =our choice & ");
scanf("#d",$choice);
s-itch(choice)
{
case 2&
ftoc();
rea9;
case '&
ctof();
rea9;
}
getch();
}
!oid ftoc()
{
printf("/nter Hempreture in Barenheit & ");
scanf("#f",$f);
cel0(f*.'),6/8;
printf("Hempreture in Felcius & #'.'f"n",cel);
}
!oid ctof()
{
printf("/nter Hempreture in Felcius& ");
scanf("#f",$c);
fare0c,8/6(.';
printf("Hempreture in Barehite & #'.'f"n",fare);
}
Fall = !alue
program to chec9 that call = !alue cahnges !alues of gi!en integers or not,/
#include<stdio.h>
#include<conio.h>
int a,,t;
int s-ap(int :, int =)
{
t0:;
:0=;
=0t;
printf(""n"n!alue of :,="n"n");
printf(": is #d"n= is #d"n",:,=);
}
int main()
{
printf("enter numer "n");
scanf("#d#d",$a,$);
printf("!alue of a, efore s-aping"n");
printf("a is #d"n is #d"n",a,);
s-ap(a,);
printf(""n"n!alue of a, after s-aping"n");
printf("a is #d"n is #d"n",a,);
getch();
}
5utput&
enter numer
2
'
!alue of a, efore s-apinf
a is 2
is '
!alue of :,=
: is '
= is 2
!alue of a, after s-apinf
a is 2
is '
call = reference& example1:
program to chec9 that call = reference cahnges !alues of gi!en integers or not,/
#include<stdio.h>
#include<conio.h>
int a,,t;
!oid s-ap(int $:, int $=) //
{
t0:;
:0=;
=0t;
printf(""n"n!alue of :,="n"n");
printf(": is #d"n= is #d"n",:,=);
}
int main()
{
printf("enter numer "n");
scanf("#d#d",$a,$);
printf("!alue of a, efore s-aping"n");
printf("a is #d"n is #d"n",a,);
s-ap(a,);
printf(""n"n!alue of a, after s-aping"n");
printf("a is #d"n is #d"n",a,);
getch();
}
5utput&
enter numer
2
'
!alue of a, efore s-aping
a is 2
is '
!alue of :,=
: is '
= is 2
!alue of a, after s-aping
a is '
is 2
call = reference& example2:
program to chec9 that call = reference cahnges !alues of gi!en integers or not,/
#include<stdio.h>
#include<conio.h>
int a,,t;
int s-ap(int ,:, int ,=) //
{
t0,:;
,:0,=;
,=0t;
printf(""n"n!alue of :,="n"n");
printf(": is #d"n= is #d"n",,:,,=);
}
int main()
{
printf("enter numer "n");
scanf("#d#d",$a,$);
printf("!alue of a, efore s-aping"n");
printf("a is #d"n is #d"n",a,);
s-ap($a,$);
printf(""n"n!alue of a, after s-aping"n");
printf("a is #d"n is #d"n",a,);
getch();
}
5utput&
enter numer
2
'
!alue of a, efore s-aping
a is 2
is '
!alue of :,=
: is '
= is 2
!alue of a, after s-aping
a is '
is 2
<rogram to calculate simple interest
#include<stdio.h>
#include<conio.h>
int main()
{
int p;
float r,t,si;
printf("/nter <rincipal mone= & ");
scanf("#d",$p);
printf("/nter rate of interest & ");
scanf("#f",$r);
printf("/nter time of interest & ");
scanf("#f",$t);
si0(p,t,r)/244;
printf(""n%imple Interest is& #'.'f",si);
getch();
}
5utput&
/nter <rincipal mone= & .
/nter rate of interest & '
/nter time of interest & 2
%imple Interest is& 4.4;
program to s-ap to !ariales t-o numers
#include<stdio.h>
#include<conio.h>
int :,=;
int s-ap(int :,int =)
{
int temp;
temp0:;
:0=;
=0:;
printf("1fter s-apping numers are &"n first is #d"n second is #d",:,=);
}

int main()
{
printf("/nter first !ariales "n");
scanf("#d",$:);
printf("/nter second !ariles "n");
scanf("#d",$=);
s-ap(:,=);
getch();
}
program to s-ap to !ariles -ithout using temp !ariales

#include<stdio.h>
#include<conio.h>
int :,=;
int s-ap(int :,int =)
{
:0:(=;
=0:*=;
:0:*=;
printf("1fter s-apping numers are &"n first is #d"n second is #d",:,=);
}

int main()
{
printf("/nter first !ariales "n");
scanf("#d",$:);
printf("/nter second !ariles "n");
scanf("#d",$=);
s-ap(:,=);
getch();
}
2'.D6
2'.D
2'.
2'
2
#include <stdio.h>
#include <conio.h>
!oid main()
{
int i, @;
for(i06;i>02;i**)
{
for(@02;@<0i;@(()
{
printf("#d",@);
}
printf(""n");
}
getch();
}
*******************************
2'.D6
'.D6
.D6
D6
6
#include <stdio.h>
#include <conio.h>
!oid main()
{
int i, @;
for(i02;i<06;i(()
{
for(@0i;@<06;@(()
{
printf("#d",@);
}
printf(""n");
}
getch();
}
******************************
6D.'2
D.'2
.'2
'2
2
#include <stdio.h>
#include <conio.h>
!oid main()
{
int i, @;
for(i06;i>02;i**)
{
for(@0i;@>02;@**)
{
printf("#d",@);
}
printf(""n");
}
getch();
}
*********************************
6D.'2
6D.'
6D.
6D
6
#include <stdio.h>
#include <conio.h>
!oid main()
{
int i, @;
for(i02;i<06;i(()
{
for(@06;@>0i;@**)
{
printf("#d",@);
}
printf(""n");
}
getch();
}
*********************************
6
D6
.D6
'.D6
2'.D6
#include <stdio.h>
#include <conio.h>
!oid main()
{
int i, @;
for(i06;i>02;i**)
{
for(@0i;@<06;@(()
{
printf("#d",@);
}
printf(""n");
}
getch();
}
*********************************************
//AIJ1KL %/1KFH
/,,,,, <rogram to %earch an 1rra= using Ainar= %earch ,,,,,/
#include <stdio.h>
#include <conio.h>
void binary_search();
int a[50], n, item, loc, be, mid, end, i;
void main()
!
"rint#($%n&nter si'e o# an array( $);
scan#($)d$, *n);
"rint#($%n&nter elements o# an array in sorted #orm(%n$);
#or(i+0; i<n; i,,)
scan#($)d$, *a[i]);
"rint#($%n&nter -.&/ to be searched( $);
scan#($)d$, *item);
binary_search();
etch();
0
void binary_search()
!
be + 0; end + n12;
mid + (be,end)34;
5hile ((be<+end) ** (a[mid]6+item))
!
i# (item < a[mid])
end + mid12;
else
be + mid,2;
mid + (be,end)34;
0
i# (a[mid] ++ item)
"rint#($%n%n-.&/ #ound at location )d$, mid,2);
else
"rint#($%n%n-.&/ doesn7t e8ist$);
0
1111111111111111111111111111111111111111111111111111111111111111111
9-:;<= >&;<?@
3AAAAA Broram to >earch an ;rray usin 9inary >earch AAAAA3
#include <stdio.h>
#include <conio.h>
void binary_search();
int a[50], n, item, loc, be, mid, end, i;
void main()
!
"rint#($%n&nter si'e o# an array( $);
scan#($)d$, *n);
"rint#($%n&nter elements o# an array in sorted #orm(%n$);
#or(i+0; i<n; i,,)
scan#($)d$, *a[i]);
"rint#($%n&nter -.&/ to be searched( $);
scan#($)d$, *item);
binary_search();
etch();
0
void binary_search()
!
be + 0; end + n12;
mid + (be,end)34;
5hile ((be<+end) ** (a[mid]6+item))
!
i# (item < a[mid])
end + mid12;
else
be + mid,2;
mid + (be,end)34;
0
i# (a[mid] ++ item)
"rint#($%n%n-.&/ #ound at location )d$, mid,2);
else
"rint#($%n%n-.&/ doesn7t e8ist$);
0
program to find po-er of gi!en numer

#include<stdio.h>
#include<conio.h>
#include<math.h>
int n,p,po-er;
int main()
{
printf("/nter numer & ");
scanf("#d",$n);
printf("/nter po-er & ");
scanf("#d",$p);

po-er0po-(n,p);
printf("numers is & #d",po-er);
getch();
}
Cactorial "roram 5orDin
#include<stdio.h>
#include<conio.h>
void main()
!
int number,#act;
#act+2;
"rint#($%n enter the number$);
scan#($)d$,*number);
5hile(number>2)
!
#act+#actAnumber;
number11;
0
"rint#($#act )d$,#act);
etch();
0
33array
#include<stdio.h>
#include<conio.h>
void main()
!
clrscr();
int a[] + !4,E,F,G,H0;
"rint#($%t)d%n$,a[E]);
"rint#($%t)d%n$,a[4]);
etch();
0
33 array 5ith #or
#include<stdio.h>
#include<conio.h>
void main()
!
clrscr();
int a[5] + !2,4,H,E,50;
#or (int i + 0; i<5; i,,)
!
"rint#($%t)d%n$,a[i]);
0
etch();
0
33 array 5ith #or
#include<stdio.h>
#include<conio.h>
void main()
!int i;
clrscr();
int a[5];
#or (i + 0; i<5; i,,)
!
"rint#($enter the value in inde8 )d$,i);
scan#($)d$,*a[i]);
0
#or (i + 0; i<5; i,,)
!
"rint#($%t)d%n$,a[i]);
0
etch();
0
334d array
#include<stdio.h>
#include<conio.h>
void main()
!
clrscr();
int a[5][4] + ! !2,40,
!H,E0,
!5,I0,
!F,J0,
!G,200 0;
#or (int i + 0; i<5; i,,)
!
#or(int K + 0; K<4; K,,)
!
"rint#($)d$,a[i][K]);
0
"rint#($%n$);
0
etch();
0
33 array 5ith #or
#include<stdio.h>
#include<conio.h>
void main()
!int i,K;
clrscr();
int a[5][4];
#or (i + 0; i<5; i,,)
!
#or(K + 0; K<4; K,,)
!
"rint#($enter the value in inde8 )d$,i);
scan#($)d$,*a[i][K]);
0
0
#or (i + 0; i<5; i,,)
!
#or(K + 0; K<4; K,,)
!
"rint#($%t)d$,a[i][K]);
0
"rint#($%n$);
0
etch();
0
Cile handlin
#include<stdio.h>
#include<conio.h>
C-L& A#";
struct student
!
int rno;
char nm[45];
#loat m2,m4,mH;
0stud;
int i;
void main()
!
#"+#o"en($marD.t8t$,$5$);
#or(i+2;i<+4;i,,)
!
"rint#($enter roll no.$);
scan#($)d$,*stud.rno);
"rint#($enter name1>$);
scan#($)s$,*stud.nm);
"rint#($enter H subKet marDs$);
scan#($)#)#)#$,*stud.m2,*stud.m4,*stud.mH);
#"rint#(#",$)d%n)s%n)#%n
)#%n$,stud.rno,stud.nm,stud.m2,stud.m4,stud.mH);
0
#close(#");
0
Cile handlin
#include<stdio.h>
#include<conio.h>
C-L& A#";
struct student
!
int rno;
char nm[45];
#loat m2,m4,mH;
0stud;
int i;
void main()
!
#"+#o"en($marD.t8t$,$5$);
#or(i+2;i<+4;i,,)
!
"rint#($&nter <oll :o.1>$);
scan#($)d$,*stud.rno);
"rint#($&nter :ame1>$);
scan#($)s$,*stud.nm);
"rint#($&nter H >ubKect /arDs$);
scan#($)#)#)#$,*stud.m2,*stud.m4,*stud.mH);
#"rint#(#",$)d%n)s%n)#%n)#%n
)#%n$,stud.rno,stud.nm,stud.m2,stud.m4,stud.mH);
0
#close(#");
0
Cile handlin
#include<stdio.h>
#include<conio.h>
C-L& A#";
struct student
!
int rno;
char nm[45];
#loat m2,m4,mH;
0stud;
int i;
void main()
!
#"+#o"en($marD.t8t$,$u$);
#or(i+2;i<+4;i,,)
!
"rint#($enter roll no.$);
scan#($)d$,*stud.rno);
"rint#($enter name1>$);
scan#($)s$,*stud.nm);
"rint#($enter H subKet marDs$);
scan#($)#)#)#$,*stud.m2,*stud.m4,*stud.mH);
#"rint#(#",$)d%n)s%n)#%n
)#%n$,stud.rno,stud.nm,stud.m2,stud.m4,stud.mH);
0
#close(#");
0
Cile handlin
#include<stdio.h>
#include<conio.h>
#include<"rocess.h>
C-L& A#";
struct student
!
int rno;
char nm[45];
#loat m2,m4,mH;
0stud;
int i,n,",d;
void main()
!
"rint#($Bress 2 .o Mive -n#o. 9y N5n%nBress 4 .o Mive -n#o. 9y
?om"uter%nBress H .o &8it$);
scan#($)d$,*n);
s5itch(n)
!
case 2(
#"+#o"en($marD.t8t$,$5$);
#or(i+2;i<+2;i,,)
!
"rint#($&nter <oll :o.1>$);
scan#($)d$,*stud.rno);
"rint#($&nter :ame1>$);
scan#($)s$,*stud.nm);
"rint#($&nter H >ubKect /arDs1>$);
scan#($)#)#)#$,*stud.m2,*stud.m4,*stud.mH);
#"rint#(#",$)d%n)s%n)#%n)#%n
)#%n$,stud.rno,stud.nm,stud.m2,stud.m4,stud.mH);
0
breaD;
case 4(
#"+#o"en($marD.t8t$,$r$);
#or(i+2;i<+2;i,,)
!
#scan#(#",$)d)s)#)#
)#$,*stud.rno,*stud.nm,*stud.m2,*stud.m4,*stud.mH);
"+((stud.m2,stud.m4,stud.mH)A200)3H00;
i#("<E0)
d+7C7;
else
i#("<50)
d+7?7;
else
i#("<I0)
d+797;

else
d+7;7;
"rint#($%n<oll :o. ()d$,stud.rno);
"rint#($%n:ame ()s$,stud.nm);
"rint#($%n/arDs ()#)#
)#$,stud.m2,stud.m4,stud.mH);
"rint#($%nBercentae ()#$,");
"rint#($%nMrade ()d$,d);
breaD;
case H(
e8it(02);
breaD;
0
etch();
00
<ead #ile #rom user
#include<stdio.h>
#include<conio.h>
void main()
!
C-L& Ain_#ile;
char marD[40];
int c;
clrscr();
"rint#($enter the #ile name%n$);
scan#($)s$,*marD);
i#((in_#ile+#o"en(marD,$r$))++:OLL)
!
"rint#($#ile does not e8ist%n$);
0
else
!
5hile((c+etc(in_#ile))6+&NC)
!
"utchar(c);
0
0
#close(in_#ile);
etch();
0
PuicD sort
#include<iostream.h>
#include<conio.h>
const int ma8+5;
class array
!
"rivate(
int ar[ma8];
int count;
"ublic(array();
void add(int item);
int etcount();
static int s"lit(intA,int,int);
void QuicDsort(int lo5,int hih);
void dis"lay();
0;
array((array()
!
count+0;
#or(int i+0;i<ma8;i,,)
ar[i]+0;
0
void array((add(int item)
!
i#(count<ma8)
!
ar[count]+item;
count,,;
0
else
cout<<$%n array is #ull$<<endl;
0
int array((etcount()
!
return count;
0
void array((QuicDsort(int lo5,int hih)
!
i#(hih>lo5)
!
int i+s"lit(ar,lo5,hih);
QuicDsort(lo5,i12);
QuicDsort(i,2,hih);
0
0
int array((s"lit(int Aa,int lo5,int hih)
!
int i,",Q,t;
"+lo5,2;
Q+hih;
i+a[lo5];
5hile(Q>+")
!
5hile(a["]<i)
",,;
5hile(a[Q]>i)
Q11;i#(Q>")
!
t+a["];a["]+a[Q];
a[Q]+t;
0
0
t+a[lo5];
a[lo5]+a[Q];
a[Q]+t;
return Q;
0
void array((dis"lay()
!
#or(int i+0;i<count;i,,)
cout<<ar[i]<<$%t$;
cout<<endl;
0
void main()
!
array a;
a.add(44);
a.add(II);
a.add(FF);
a.add(EE);
a.add(22);
cout<<$%n element o# QuicD sort be#ore sortin $;
a.dis"lay();
int c+a.etcount();
a.QuicDsort(0,c12);
cout<<$%n elements o# QuicD sort a#ter sortin$;
a.dis"lay();
etch();
0

You might also like