Advertisement
Niloy007

Pranto's Problem 6

Apr 16th, 2021
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main() {
  4.     int a, b;
  5.     printf("Input the first number: ");
  6.     scanf("%d", &a);
  7.     printf("Input the second number: ");
  8.     scanf("%d", &b);
  9.     if (a >= 0) {
  10.         if (a % 2 == 0) {
  11.             printf("First number is positive and even\n");
  12.         } else {
  13.             printf("First number is positive and odd\n");
  14.         }
  15.     } else if (a < 0) {
  16.         if (a % 2 == 0) {
  17.             printf("First number is negative and even\n");
  18.         } else {
  19.             printf("First number is negative and odd\n");
  20.         }
  21.     }
  22.     if (b >= 0) {
  23.         if (b % 2 == 0) {
  24.             printf("Second number is positive and even\n");
  25.         } else {
  26.             printf("Second number is positive and odd\n");
  27.         }
  28.     } else {
  29.         if (b % 2 == 0) {
  30.             printf("Second number is negative and even\n");
  31.         } else {
  32.             printf("Second number is negative and odd\n");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement