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

Differentiate between ordinary variable and pointer in c.

837


What is the difference between new and malloc functions?

802


What is #line used for?

770


What are two dimensional arrays alternatively called as?

919


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

1048


Can a variable be both constant and volatile?

802


What is linear search?

893


Why do we use c for the speed of light?

809


What is function prototype in c with example?

764


What are the 4 types of organizational structures?

806


#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??

1737


What should malloc() do?

834


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.

1695


Why is main function so important?

828


The statement, int(*x[]) () what does in indicate?

881