Get the greatest of the first two numbers. Then get the greatest of the result and the third number.
result = a > b ? a : b;
result = result > c ? result : c;
This can be combined into a single line, but that would involve too much repetition.
Use the following function:
int largest_of_3 (int a, int b, int c) {
if (a>b && a>c)
return a;
else if (b>c)
return b;
else
return c;
}
Of course it would be much easier to implement such a function using a more primitive function, returning the largest of two values:
int largest (int a, int b) {
if (a>b) return a;
else
return b;
}
Given this function, the largest of three function becomes:
int largest_of_3 (int a, int b, int c) { return largest (largest (a, b), c);
}
The greatest number is infinity.
Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
#include<stdio.h> void main() { int a=10,b=15; clrscr(); if(a>b) printf("%d is the large number",a); else printf("%d is the large number",b); getch(); }
To find greatest of 3 digits in one line #includ<stdio.h> #include<conio.h> void main() { int a,b,c; printf("enter a,b,c:); scanf("d%d%d",&a,&b,&c); printf("greatest no: %d"(a>b)?((a>c)?a:c):((c>b)?c:b)); printf("have a nice day"); getch(); }
The greatest number is infinity.
Compare the first two numbers with the ternary operator. Store the result in a temporary variable. Compare the temporary variable with the third number, again using the ternary operator.
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
Adjoint operator of a complex number?
If a number is nonzero, then the number is positive.
#include<stdio.h> void main() { int a=10,b=15; clrscr(); if(a>b) printf("%d is the large number",a); else printf("%d is the large number",b); getch(); }
The main number for reaching a telephone operator in the UK is 100.
The number of a operator will be 0 or 411.
There is no such thing as 'the greatest number'. Here is a program in unix to prove it: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc if you want to actually see the output use it this way: echo 'for (i=1; i>=0; i= i*2) print i,"\n";' | bc | less -S
Given that an integer is the same as a whole number, there are four true conditional statements.
To find greatest of 3 digits in one line #includ<stdio.h> #include<conio.h> void main() { int a,b,c; printf("enter a,b,c:); scanf("d%d%d",&a,&b,&c); printf("greatest no: %d"(a>b)?((a>c)?a:c):((c>b)?c:b)); printf("have a nice day"); getch(); }
The statement is bi-conditional. The "if and only if" should have tipped you off immediately.