Write a program to find the smallest and largest element in
a given array in c language

Answer Posted / dally

#include<stdio.h>
int main()
{
int a[]= {4,3,6,7};
int l.n = 0;
int s.n = 9;
int i=0;
while(a[i] != '\0')
{
if(a[i]>= l.n)
l.n = a[i];
else if(a[i]<=s.n)
s.n = a[i]
i++;
}
printf("%d %d",s.n,l.n) ;

}

Is This Answer Correct ?    45 Yes 51 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I avoid the abort, retry, fail messages?

597


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

1720


Why is c called "mother" language?

863


What are qualifiers?

621


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1746






What are the keywords in c?

647


Hi can anyone tell what is a start up code?

1622


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

1779


How can I write a function that takes a format string and a variable number of arguments?

609


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

673


Why do we use stdio h and conio h?

645


Differentiate abs() function from fabs() function.

604


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1500


What is difference between %d and %i in c?

698


When would you use a pointer to a function?

591