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 is the explanation for the dangling pointer in c?
Explain the difference between call by value and call by reference in c language?
Explain zero based addressing.
What are structure members?
What is const volatile variable in c?
Differentiate between #include<...> and #include '...'
How many levels of indirection in pointers can you have in a single declaration?
Why n++ execute faster than n+1 ?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
write a progrmm in c language take user interface generate table using for loop?
When can a far pointer be used?
Which is best book for data structures in c?
How do I convert a string to all upper or lower case?
Write a program to reverse a given number in c?