Array Program
#include
#include
void main()
{
int a[50],n,i,j,t;
clrscr();
printf("Enter the
value:\n");
scanf("%d",&n);
printf("\n Enter the unsorted
numbers");
for(i=0;i
{
scanf("%d",&a[i]);
}
for(i=0;i
{
for(j=i+1;j
{
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("Asending
Order\n");
for(i=0;i
{
printf("%d\n",a[i]);
}
getch();
}
Output
Enter the value
5
Enter
the unsorted numbers
2
9
7
3
4
Ascending
Order
2
3
4
7
9
Multidimensional Array
#include
#include
void main()
{
char sub[10][25];
int i,m[10][25];
clrscr();
printf("\n Enter how many
subjects");
scanf("%d",&n);
for(i=0;i
{
printf("Enter the subject:\n");
scanf("%s",sub[i]);
printf("Enter the mark:\n");
scanf("%d",&m[i]);
}
printf("\n**************************************");
printf("\n Subject name \t
Subject Mark\n");
printf("\n
*************************************");
for(i=0;i
{
printf("%s \t\t %d\n",
sub[i],m[i]);
}
printf("\n**************************************");
getch();
}
Output
Enter
how many subjects
2
Enter
the subject : English
Enter
the mark : 50
Enter
the subject : Maths
Enter
the mark : 70
************************************************
Subject
Name Subject Mark
************************************************
English 50
Maths 70
********************************************
No comments:
Post a Comment