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

void main() {int a[5],i,b=16; for(i=0;i<5;i++) a[i]=2*i; f(a,5,b); for(i=0;i<5;i++) printf("\n %d",a[i]); printf("\n %d",b); } f(int *x,int n,int y) { int i; for(i=0;i<n;i++) *(x+i)+=2; y=y+2; }wat r the errors in the prg.and improvise the prg to get o/p.?

2 Answers   TCS,


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

0 Answers   TISL,


What do you understand by normalization of pointers?

0 Answers  


implement NAND gate logic in C code without using any bitwise operatior.

4 Answers   Alcatel,


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

0 Answers  






Write a program to accept a character & display its corrosponding ASCII value & vice versa?

9 Answers  


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


What is pass by reference in functions?

0 Answers  


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CISOC, CitiGroup, College School Exams Tests,


how memory store byte

4 Answers   Huawei,


Write a c program to enter a string of paragraph and replacing a particular word which is repeated in the paragraph by another word?

2 Answers   ME, Synfusion, Wipro,


Differentiate abs() function from fabs() function.

0 Answers  


Categories