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


Please Help Members By Posting Answers For Below Questions

What is c value paradox explain?

566


What is keyword with example?

628


Does c have class?

608


What is a far pointer in c?

590


i want to know the procedure of qualcomm for getting a job through offcampus

1927






Explain what happens if you free a pointer twice?

603


Combinations of fibanocci prime series

1105


How is a structure member accessed?

581


Why is #define used?

786


What is the use of the function in c?

594


What is 'bus error'?

637


When should you not use a type cast?

654


What is huge pointer in c?

575


What does the function toupper() do?

646


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

620