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 const and volatile in c?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
Why array is used in c?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
what value is returned to operating system after program execution?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
What is multidimensional arrays
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Why can arithmetic operations not be performed on void pointers?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
What is actual argument?
What is the use of header files?
Define recursion in c.
What are the types of type specifiers?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?