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
Is c is a low level language?
What are integer variable, floating-point variable and character variable?
Is file a keyword in c?
Why is sprintf unsafe?
How can you increase the size of a statically allocated array?
What is the heap?
What are the features of c language?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
What do you mean by scope of a variable in c?
What is a double c?
Explain how can I make sure that my program is the only one accessing a file?
List some basic data types in c?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)
Explain how do you search data in a data file using random access method?