Write a program generates three single-digit integers and prompts the user to enter the lowest of
these three. The program then reports true if the answer is correct, false otherwise
1
Expert's answer
2011-06-25T06:37:44-0400
#include<stdio.h> #include<stdlib.h>
int main() { & int a,b,c, m, k; & // generate random digits & a=rand()%10; & b=rand()%10; & c=rand()%10; & // calculate minimum of a,b,c & m = (a<b) ? a : b; & if (c<m) { m=c; }; & & printf("Please enter minimum of the following numbers a,b,c:\n"); & printf("a=%d, b=%d, c=%d\n", a,b,c); & scanf("%d",&k); & & if(k==m) & { printf("Your answer is correct!\n"); & } & else & { printf("Your answer is not correct!\n"); & }; & return 0; };
Comments