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 is openmp in c?
Can 'this' pointer by used in the constructor?
Describe how arrays can be passed to a user defined function
Why malloc is faster than calloc?
Can we add pointers together?
How can you access memory located at a certain address?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
Without Computer networks, Computers will be half the use. Comment.
Write a program to check prime number in c programming?
What are the differences between Structures and Arrays?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
What is this pointer in c plus plus?
How can you avoid including a header more than once?
how to make a scientific calculater ?
Can include files be nested? How many levels deep can include files be nested?