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
write a program to create a sparse matrix using dynamic memory allocation.
What are conditional operators in C?
What's the total generic pointer type?
Differentiate between static and dynamic modeling.
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
What is the difference between union and anonymous union?
Write a program to print factorial of given number without using recursion?
How can I discover how many arguments a function was actually called with?
How can I direct output to the printer?
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.
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What are pointers in C? Give an example where to illustrate their significance.
What is structure data type in c?
What is the hardest programming language?