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
What are the disadvantages of c language?
How can I make it pause before closing the program output window?
When should volatile modifier be used?
What is the use of linkage in c language?
how to find anagram without using string functions using only loops in c programming
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
How can I delete a file?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
Explain how do you use a pointer to a function?
What is binary tree in c?
What is static and volatile in c?
What is file in c language?
If the size of int data type is two bytes, what is the range of signed int data type?
Why isn't any of this standardized in c? Any real program has to do some of these things.
What is the most efficient way to store flag values?