\* PROGRAM TO FIND THE MAXIMUM VALUE USING ARRAY*\
#include<stdio.h>
#include<conio.h>
void main() {
int a[155],n,i,max;
clrscr();
printf("Enter No. of items:");
scanf("%d", &n);
for(i=0;i<n;i++)
{ printf("Enter value a[%d]", i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
printf("\t%d", a[i]);
}
max=a[0];
for(i=0;i<n;i++)
{
if(max<a[i])
max=a[i];
}
printf("\nMaximum value is %d", max);
getch();
}
\*OUTPUT:
Enter No. of items:4
Enter value a[0]5
Enter value a[1]7
Enter value a[2]99
Enter value a[3]656
5 7 99 656
Maximum value is 656 *\
#include<stdio.h>
#include<conio.h>
void main() {
int a[155],n,i,max;
clrscr();
printf("Enter No. of items:");
scanf("%d", &n);
for(i=0;i<n;i++)
{ printf("Enter value a[%d]", i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
printf("\t%d", a[i]);
}
max=a[0];
for(i=0;i<n;i++)
{
if(max<a[i])
max=a[i];
}
printf("\nMaximum value is %d", max);
getch();
}
\*OUTPUT:
Enter No. of items:4
Enter value a[0]5
Enter value a[1]7
Enter value a[2]99
Enter value a[3]656
5 7 99 656
Maximum value is 656 *\
No comments:
Post a Comment