Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / rajesh kumar s
int main()
{
int a[20],min,max;
int n;
printf("enter the num of elements\t:");
scanf("%d",&n);
printf("enter the elements\n");
for(int 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 ? | 234 Yes | 67 No |
Post New Answer View All Answers
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What is union in c?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
Can static variables be declared in a header file?
What is volatile variable in c?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
How are strings stored in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Can a variable be both const and volatile?
Write a program to swap two numbers without using third variable?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
Explain what is the benefit of using enum to declare a constant?
Why do we use main function?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???