Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / puspendu adak
#include<stdio.h>
#include<conio.h>
void main()
{clrscr();
int i,arrb,arrl,arr[20],num;
printf("enter the number of elements");
scanf("%d",&num);
printf("enter the elements");
for(i=0;i<num;i++)
scanf("%d",&arr[i]);
arrl=arrb=arr[0];
for(i=0;i<num;i++)
{if(arr[i]>=arrb)
arrb=arr[i];
}
for(i=0;i<num;i++)
{if(arr[i]<arrl)
arrl=arr[i];
}
printf("the smallest number is %d.\nthe biggest number is
%d.",arrl,arrb);
getch();
}
| Is This Answer Correct ? | 27 Yes | 22 No |
Post New Answer View All Answers
What is the difference between declaring a variable and defining a variable?
State the difference between realloc and free.
Write a program to use switch statement.
What is the purpose of ftell?
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What is meant by preprocessor in c?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Why is a semicolon (;) put at the end of every program statement?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What are the advantages of c preprocessor?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
what will be maximum number of comparisons when number of elements are given?
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);
What is a wrapper function in c?
Explain the term printf() and scanf() used in c language?