Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / dinesh
#include <stdio.h>
int main()
{
int a[20],min,max;
int n,i;
printf("enter the num of elements\t:");
scanf("%d",&n);
printf("enter the elements\n");
for( i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(i==0)
{
min=max=a[i];
}
if(a[i]<min)
min=a[i];
else if(a[i]>max)
max=a[i];
}
printf("Biggest element is %d and Smallest element
is %d ",max,min);
}
Is This Answer Correct ? | 11 Yes | 9 No |
Post New Answer View All Answers
What does the function toupper() do?
How many types of functions are there in c?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
What are the advantages of Macro over function?
In C language, a variable name cannot contain?
Differentiate between the expression “++a” and “a++”?
Explain what is the most efficient way to store flag values?
What is meant by int main ()?
Is it possible to initialize a variable at the time it was declared?
What oops means?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What are identifiers in c?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
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.
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }