Write a program to find the smallest and largest element in
a given array in c language
Answer Posted / dinesh
#include <stdio.h>
int main()
{
int a[20],min,max;
int n,i;
printf("enter the num of elements\t:");
scanf("%d",&n);
printf("enter the elements\n");
for( i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(i==0)
{
min=max=a[i];
}
if(a[i]<min)
min=a[i];
else if(a[i]>max)
max=a[i];
}
printf("Biggest element is %d and Smallest element
is %d ",max,min);
}
Is This Answer Correct ? | 11 Yes | 9 No |
Post New Answer View All Answers
writ a program to compare using strcmp VIVA and viva with its output.
What is scanf () in c?
Write a C program to count the number of email on text
What are data structures in c and how to use them?
Explain a pre-processor and its advantages.
Why is c not oop?
What is indirection? How many levels of pointers can you have?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Write a program to print numbers from 1 to 100 without using loop in c?
What is bash c?
What is struct node in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
Explain what does it mean when a pointer is used in an if statement?
Explain the difference between structs and unions in c?
What is binary tree in c?