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 the basis for selection of arrays or pointers as data structure in a program

3790


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

593


What is #pragma statements?

594


What is printf () in c?

582


Under what circumstances does a name clash occur?

695






What is double pointer in c?

593


Write a program to swap two numbers without using the third variable?

602


What are the difference between a free-standing and a hosted environment?

747


What are the different types of data structures in c?

610


How can I automatically locate a programs configuration files in the same directory as the executable?

634


What oops means?

588


Can you assign a different address to an array tag?

704


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

651


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1677


Write a program which returns the first non repetitive character in the string?

606