Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / chandrashekhar
# include<stdio.h>
void main()
{
int a[10];
int max=0,min=0,n,i=0;
printf("enter array size");
scanf("%d",&n);
printf("enter elements");
for( i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
//mini num
min=a[i];
for(int i=1;i<n;i++)
{
if(min>a[i])
{
min=a[i++];
}
}
//max num
max=a[i];
for(int i=1;i<n;i++)
{
if(max<a[i])
{
max=a[i++];
}
}
printf( "min=%d max=%d",min,max);
getch();
}
Is This Answer Correct ? | 21 Yes | 17 No |
Post New Answer View All Answers
Explain what standard functions are available to manipulate strings?
The file stdio.h, what does it contain?
Why is structure important for a child?
write a program to copy the string using switch case?
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
Implement bit Array in C.
What is return in c programming?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
What are the usage of pointer in c?
What is pass by value in c?
What does do in c?
What is atoi and atof in c?
What is call by reference in functions?
What is data types?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop