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
What is structure in c explain with example?
#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); }
explain what are pointers?
What are the differences between Structures and Arrays?
How do you convert strings to numbers in C?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
How can I change the size of the dynamically allocated array?
How can you tell whether two strings are the same?
Can you add pointers together? Why would you?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
write a program in c language to print your bio-data on the screen by using functions.
What is the difference between array and linked list in c?
What are c preprocessors?
Why do we write return 0 in c?
What are valid operations on pointers?