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
Differentiate between ordinary variable and pointer in c.
What is the difference between new and malloc functions?
What is #line used for?
What are two dimensional arrays alternatively called as?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
Can a variable be both constant and volatile?
What is linear search?
Why do we use c for the speed of light?
What is function prototype in c with example?
What are the 4 types of organizational structures?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
What should malloc() do?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
Why is main function so important?
The statement, int(*x[]) () what does in indicate?