Solution :-
1. Algorithm Development :
Step
1 : Start
Step
2 : Read two numbers
Step
3 : Calculate product=(first*second)
Step
4 : If product is greater than, first number,
if product is greater
than, second number,
Display product is
greater than both numbers
else Display
product is greater than first but less than second number
Step4
: else
if product is greater
than second no.
Display product is
lesser than First & greater than 2nd no.
else Display product is
lesser than both numbers
Step5:
End
3.Coding :
/* WAP that inputs two numbers and then determine whether the product of two number is greater than both of them. */
#include<stdio.h>
int main()
{
float first, second, product; //Variable Declaration
printf("Enter two numbers: ");
scanf("%f %f", &first, &second);
product=first*second;
if(product>first)
{
if(product>second)
printf("\n The product =%.2f is greater than both numbers", product);
else
printf("\n The product =%.2f is greater than first but lesser than second number", product);
}
else
{
if(product>second)
printf("\n The product =%.2f is lesser than first but greater than second number",product);
else
printf("\n The product =%.2f is lesser than both numbers",product);
}
return 0;
} // End of Main Program
Output :
Output 1:
Output 2:
I have used Dev CPP to compile this program.
If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
0 comments:
Post a Comment