How to write a C program to determine the smallest among
three nos using conditional operator?
Answer Posted / 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 View All Answers
What is scanf_s in c?
How is null defined in c?
When a c file is executed there are many files that are automatically opened what are they files?
When can you use a pointer with a function?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What are bitwise shift operators in c programming?
What is time null in c?
What is null in c?
What is an identifier?
how to capitalise first letter of each word in a given string?
Write a program to print numbers from 1 to 100 without using loop in c?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
What is the modulus operator?
What is a buffer in c?
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none