Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / n.sankeerthan
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
int a[50],large,small;
printf("\n size of an array:"):
scanf("%d",&n);
printf("\n %d",n);
printf("\n array elements:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
printf("\n %5d",a[i]);
printf("\n"); /*initialization*/
large=a[10];
small=a[10] /*large & smallest elements*/
for(i=0;i<n;i++)
{
if(a[i]>large)
large=a[i];
else if(a[i]<small)
small=a[i];
}
printf("\n largest element is %3d",large);
printf("\n smallest element is %3d",small);
getch();
}
Is This Answer Correct ? | 15 Yes | 17 No |
Post New Answer View All Answers
Explain what are the different file extensions involved when programming in c?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
Explain what are multidimensional arrays?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
Why is not a pointer null after calling free?
What is keyword in c?
What is build process in c?
What does main () mean in c?
How can you tell whether a program was compiled using c versus c++?
Can a local variable be volatile in c?
What is identifier in c?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
When should the volatile modifier be used?
Why is c called c?
What is the role of && operator in a program code?