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

for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????

8 Answers  


How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


What are the different types of C instructions?

0 Answers   InterGraph,


write a program to display numbers from 1 to 10 and 10 to 1?

2 Answers  


What is wrong with this statement? Myname = 'robin';

0 Answers  






What is wrong in this statement? scanf(“%d”,whatnumber);

0 Answers  


is compiler do read the data line by line or not. ??

6 Answers   LG Soft, Satyam, Tech Mahindra,


Which are low level languages?

0 Answers  


can we print any string in c language without using semicolon(;)(terminator) in whole program.

11 Answers  


Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….

1 Answers  


Explain what is the concatenation operator?

0 Answers  


Write a program to swap two numbers without using third variable?

0 Answers  


Categories