Accept 5 numbers in an array and display it.
#include
void main(){
int a[5];
clrscr();
for(register int i=0;i<=4;i++)
{
cout<<"\n\ta["<
cin>>a[i];
}
for(i=0;i<=4;i++)
{
cout<<"\n\tAreay a["<
}
getch();
}
Accept 10 numbers in an array, sort it and display it.
#include
void sorting(int []);
void main(){
int a[10];
clrscr();
for(register int i=0;i<=9;i++)
{
cout<<"\n\ta["<
cin>>a[i];
}
sorting(a);
getch();
}
void sorting(int a[])
{
int t;
for(register int i=0;i<=9;i++)
{
for(register int j=i+1;j<=9;j++)
{
if(a[i]>a[j]){
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
cout<<"\n\n\t**AFTER SORTING**";
for(i=0;i<=9;i++)
{
cout<<"\n\tAreay a["<
}
}
Accept 9 numbers in form of matrix. (3 X 3 matrix)
#include
void matrix(int []);
void main(){
int a[9];
clrscr();
for(register int i=0;i<9;i++)
{
cout<<"\n\tmatrix ele.["<
cin>>a[i];
}
matrix(a);
getch();
}
void matrix(int a[])
{
int k=0;
cout<<"\n\n\n";
for(register int i=0;i<=2;i++)
{
for(register int j=0;j<=2;j++)
{
k++;
}
cout<<"\n";
}
}
0 comments:
Post a Comment