Write a program that reads two integer values (A and B) from the keyboard and displays the product sign of A and B without performing the multiplication.
Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
void main()
{
int A, B;
printf("Enter 2 integers :");
scanf("%i %i", &A, &B);
if ((A>0 && B>0) || (A<0 && B<0))
printf("The sign of the product %i * %i is positive\n", A, B);
else if ((A<0 && B>0) || (A>0 && B<0))
printf("The sign of the product %i * %i is negative\n", A, B);
else
printf("Thee product %i * %i is zero\n", A, B);
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Asymptotic Analysis 12