wap in c to accept n number display the highest and lowest
value

Answers were Sorted based on User's Feedback



wap in c to accept n number display the highest and lowest value..

Answer / abhilash.d

void main()
{
int n,a[],j,l;
printf("enter the no.of numbers to accept");
scanf("%d",&n);
printf("enter the numbers");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=1;j<=i;j++)
{
if(a[i]<a[j])
{
l=a[i];
a[j]=a[i];
a[i]=l;
}
}
}
printf("highest value is:"a[0]);
printf("lowest value is:"a[0+n-1]);
}

Is This Answer Correct ?    10 Yes 3 No

wap in c to accept n number display the highest and lowest value..

Answer / raghu

void main()
{
int n,a[],j,l,max,min;
printf("enter the no.of numbers to accept");
scanf("%d",&n);
printf("enter the numbers");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]<=min)
{
min=a[i];
}
else if(a[i]>=max)
{
max=a[i];
}
}
printf("highest value is:",max);
printf("lowest value is:",min);
}

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More C Interview Questions

Explain what is the difference between text files and binary files?

0 Answers  


Is there a way to compare two structure variables?

0 Answers  


what will be the output off the following program? #include<stdio.h> int main() { int a; a=015+0*71+5; printf("%d,a"); return0; }

9 Answers   HCL,


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

0 Answers   Sikkim Manipal University,


What is the difference b/w Structure & Union?

3 Answers  






What is the difference between the = symbol and == symbol?

0 Answers  


i have a written test in tomorrow

1 Answers   NNN, Value Labs,


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

0 Answers  


Write a C++ program without using any loop (if, for, while etc) to print numbers from 1 to 100 and 100 to 1;

18 Answers   Accenture, Cisco, Egentec, HCL, Ideaz, Infosys, M-Systems, MYR, TCS,


why u join this call center?

6 Answers   DELL,


What is malloc() function?

0 Answers  


Is it possible to execute code even after the program exits the main() function?

0 Answers  


Categories