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
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What do you mean by recursion in c?
What is assert and when would I use it?
What are pointers?
What does %p mean c?
Why do we use namespace feature?
Write a program which returns the first non repetitive character in the string?
Where static variables are stored in c?
Explain main function in c?
praagnovation
What is the difference between test design and test case design?
Is there any demerits of using pointer?
What are the ways to a null pointer can use in c programming language?
What is a void * in c?
How can you allocate arrays or structures bigger than 64K?