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 c value paradox explain?
What is keyword with example?
Does c have class?
What is a far pointer in c?
i want to know the procedure of qualcomm for getting a job through offcampus
Explain what happens if you free a pointer twice?
Combinations of fibanocci prime series
How is a structure member accessed?
Why is #define used?
What is the use of the function in c?
What is 'bus error'?
When should you not use a type cast?
What is huge pointer in c?
What does the function toupper() do?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler