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 keywords (reserve words) are in c?
Can we access the array using a pointer in c language?
List some of the static data structures in C?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What are the differences between Structures and Arrays?
What is the difference between a string and an array?
Is it better to bitshift a value than to multiply by 2?
What are the advantages of using Unions?
How old is c programming language?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What is the return type of sizeof?
List some basic data types in c?
What is data type long in c?
What is dynamic variable in c?