by CodeChum Admin
The square of an integer refers to the result of multiplying the integer with itself once. While the cube of an integer refers to the result of multiplying the integer with itself twice. As long as you know that, you could easily solve this!
Instructions:
Input
1. First integer
2. Second integer
3. Third integer
Output
The first three lines will contain message prompts to input the three integers.
The last line contains "Positive" or "Negative"
Enter the first integer: 1
Enter the second integer: 2
Enter the third integer: 3
Positive
Enter the first integer: 1
Enter the second integer: -5
Enter the third integer: 4
Negative
#include <stdio.h>
int main()
{
int a, b, c;
printf("%s", "Enter the first integer: ");
scanf("%d", &a);
printf("%s", "Enter the second integer: ");
scanf("%d", &b);
printf("%s", "Enter the third integer: ");
scanf("%d", &c);
int result = a * a * a + b * b * b + c * c *c;
if(result >= 0)
{
printf("%s", "Positive ");
}
else
{
printf("%s", "Negative ");
}
return 0;
}
Comments
Leave a comment