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 static volatile in c?
What is the difference between text and binary modes?
How can I use a preprocessorif expression to ?
What is the Purpose of 'extern' keyword in a function declaration?
What is 1d array in c?
will u please send me the placement papers to my mail???????????????????
What extern c means?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
What does %p mean?
What is a pointer on a pointer in c programming language?
Explain what is the use of a semicolon (;) at the end of every program statement?
how can use subset in c program and give more example
What is integer constants?
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...