how to find the largest element of array without using relational operater?
Answer Posted / hari
/*
find a largest number out of an given array without
using relational operators
*/
#include<stdio.h>
int f(int m,int n)
{if(!(m/n)) return n;
else return m;
}
int main()
{
int a[100],n=0,i,j;
scanf("%d",&n); // length of array (max 100)
for( i=0;i<n;i++)
scanf("%d",&a[i]);
int s=a[0];
a[n+1]=0;
for( j=1;j<n;j++)
{
if(f(a[j],s))
s=a[j];
}
printf("%d",s);
return 0;
}
for further queries and discussions, just check these out !!!
http://forum.campusmaniac.com/
http://www.campusmaniac.com/
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
Explain the use of keyword 'register' with respect to variables.
What is the meaning of && in c?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
How does free() know explain how much memory to release?
What is structure in c definition?
Explain what are binary trees?
Can we access the array using a pointer in c language?
What is double pointer?
Explain what is meant by high-order and low-order bytes?
Why is struct padding needed?
What is variable declaration and definition in c?
What is wild pointer in c with example?
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
What are the advantages of c preprocessor?