Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / chandrashekhar
# include<stdio.h>
void main()
{
int a[10];
int max=0,min=0,n,i=0;
printf("enter array size");
scanf("%d",&n);
printf("enter elements");
for( i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
//mini num
min=a[i];
for(int i=1;i<n;i++)
{
if(min>a[i])
{
min=a[i++];
}
}
//max num
max=a[i];
for(int i=1;i<n;i++)
{
if(max<a[i])
{
max=a[i++];
}
}
printf( "min=%d max=%d",min,max);
getch();
}
| Is This Answer Correct ? | 21 Yes | 17 No |
Post New Answer View All Answers
What are the rules for the identifier?
How can a number be converted to a string?
Why malloc is faster than calloc?
Explain continue keyword in c
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
how many key words availabel in c a) 28 b) 31 c) 32
What is multidimensional arrays
Write a program to implement queue.
What are the ways to a null pointer can use in c programming language?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
c program to compute AREA under integral
What is function definition in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
What is a memory leak? How to avoid it?
in iso what are the common technological language?