find largest element in array w/o using sorting techniques.

Answer Posted / gganesh

#include<stdio.h>
#include<conio.h>
#define max 100
void main()
{
int i,j,k,num[max];
clrscr();
printf("\nEnter the number one by one and terminate with
0\nDont enter more than %d numbers\n\n",max);
i=0;
do
{
printf("Enter the number : ");
scanf("%d",&num[i]);
i++;
}while(num[i-1]!=0);
j=num[0];
for(k=1;k<i;k++)
if(j<num[k])
j=num[k];
printf("\nLargest number : %d",j);
getch();
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by preprocessor in c?

526


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

704


Explain the difference between ++u and u++?

633


What is an operator?

654


List some of the static data structures in C?

757






Describe how arrays can be passed to a user defined function

774


How are strings stored in c?

586


What are the 5 types of inheritance in c ++?

574


What is c++ used for today?

657


how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....

1366


Explain how do you determine a file’s attributes?

588


Are negative numbers true in c?

595


Why do we write return 0 in c?

545


What are dangling pointers? How are dangling pointers different from memory leaks?

616


What should malloc(0) do?

608