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

Answers were Sorted based on User's Feedback



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

Answer / pramod

#include<stdio.h>


int main()
{
int a[10]={13,12,34,56,73,21,234,5,76,2};
int tmp,i;
tmp=a[0];
for(i=0;i<=9;i++)
{
if(a[i]>tmp)
{
tmp=a[i];
}
}
printf("\n largest number is %d\n",tmp);
return 0;
}

Is This Answer Correct ?    27 Yes 2 No

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

Answer / 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

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

Answer / manjunath

#include<stdio.h>
void main()
{
int a,b[4]={3,2,7,4,9};
a[0]=b[0];
for(i=1;i<5;i++)
{
if(a<b[i])
{
a=b[i];
}
}
printf("the largest num is %d",a);
}

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More C Interview Questions

How pointer is benefit for design a data structure algorithm?

2 Answers  


Can we use any name in place of argv and argc as command line arguments?

0 Answers  


Explain about C function prototype?

0 Answers  


Explain goto?

0 Answers  


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,






What does typedef struct mean?

0 Answers  


Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays

0 Answers  


What is the difference between scanf and fscanf?

0 Answers  


how will you write a program on linked lists using JAVA programming???????????

1 Answers   Keane India Ltd,


what is difference between ++(*p) and (*p)++

17 Answers   Accenture, HCL, IBM,


What is a loop?

0 Answers  


what is the use of using linked list and array?

10 Answers   Infosys, TCS,


Categories