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
How many bytes is a struct in c?
What is a static variable in c?
Can two or more operators such as and be combined in a single line of program code?
What is a constant and types of constants in c?
How to delete a node from linked list w/o using collectons?
Explain null pointer.
Can include files be nested?
Do pointers take up memory?
What is array of structure in c programming?
Is calloc better than malloc?
Write a program to generate the Fibinocci Series
if p is a string contained in a string?
Explain how can type-insensitive macros be created?
What is the difference between struct and union in C?
How can I sort a linked list?