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

Blade logic interview question. 1st round is a written tests with 15 multiple questions from c and c++. All are simple basic question. Like int main () { Int i=65; Return printf(ā€œ%cā€, i); } 2nd and 3rd round is technical interview. The position for which I was interview was core UNIX and c. Yes it is for system programming. The company has product name blade server. For their server they are creating their own command for their purpose. Example cd command. We can implement it in a c program by using the chdir() function. So the question asks related to PID, fork, pipe, shared memory, signal. Write a program in c which will act as cp command.

1 Answers   BladeLogic, Infosys,


What is wrong with this program statement?

0 Answers  


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1 Answers   IBM,


What are the characteristics of arrays in c?

0 Answers  


What is ambagious result in C? explain with an example.

0 Answers   Infosys,






write a program to fined second smallest and largest element in a given series of elements (without sorting)

9 Answers   Yahoo,


Can a binary search tree be used as an index? If yes, how? Explain

0 Answers   TCS,


If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.

12 Answers   Google,


How to add two numbers with using function?

4 Answers  


wap in c to accept n number display the highest and lowest value

2 Answers  


Can anyone help me with this please? Need to print the below values.. Thanks 1 1 2 1 2 3 1 2 3 4

3 Answers  


what are threads ? why they are called light weight processes ? what is the relation between process and threads ?

1 Answers  


Categories