How to write a C program to determine the smallest among
three nos using conditional operator?

Answers were Sorted based on User's Feedback



How to write a C program to determine the smallest among three nos using conditional operator?..

Answer / sai

#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,n3,small;
clrscr();
printf("Enter three numbers");
scanf("%d%d%d",&n1,&n2,&n3);
small=n1<n2?(n1<n3?n1:n3):(n2<n3?n2:n3);
printf("smallest number is:%d",small);
printf("press any key to close");
getch();
}

Is This Answer Correct ?    32 Yes 11 No

How to write a C program to determine the smallest among three nos using conditional operator?..

Answer / azad sab;e,chiplun


void main()
{
int n1,n2,n3,small;
clrscr();
printf("Enter three numbers");
scanf("%d%d%d",&n1,&n2,&n3);
small=n1<n2?(n1<n3?n1:n3):(n2<n3?n2:n3);
printf("smallest number is:%d",small);
printf("press any key to close");
}
getch();
}

Is This Answer Correct ?    24 Yes 21 No

Post New Answer

More C Interview Questions

What is a pointer in c plus plus?

0 Answers  


Program to find the absolute value of given integer using Conditional Operators

6 Answers   N Tech,


int a=0,b=2; if (a=0) b=0; else b=*10; What is the value of b ?

6 Answers   TCS,


Explain the concept and use of type void.

0 Answers  


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

0 Answers  


What is the output of the following program main();{printf ("chennai""superkings"}; a. Chennai b. superkings c. error d. Chennai superkings

6 Answers  


Example of friendly function in c++

2 Answers  


Compare interpreters and compilers.

0 Answers  


In the below code, how do you modify the value 'a' and print in the function. You'll be allowed to add code only inside the called function. main() { int a=5; function(); // no parameters should be passed } function() { /* add code here to modify the value of and print here */ }

1 Answers  


Explain b+ tree?

0 Answers  


What is openmp in c?

0 Answers  


Can one function call another?

0 Answers  


Categories