Answer to Question #3230 in C++ for vivek

Question #3230
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;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS