Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / alive
#include <stdio.h>
#include <conio.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);
getch();
}
| Is This Answer Correct ? | 15 Yes | 13 No |
Post New Answer View All Answers
Can you mix old-style and new-style function syntax?
What does *p++ do? What does it point to?
What is mean by data types in c?
What header files do I need in order to define the standard library functions I use?
please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics
Explain what is wrong with this program statement? Void = 10;
What is the purpose of scanf() and printf() functions?
What should malloc() do?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What are register variables? What are the advantage of using register variables?
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
What the different types of arrays in c?
When should structures be passed by values or by references?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
Does c have function or method?