Problem 16

author
By Supreme2023-03-15
Problem Statement :
Write a C program to input an integer number and check the last digit of number is even or odd.
Code:

#include <stdio.h>

int main()
{

// 16. Write a C program to input an integer number and check the last digit of number
// is even or odd.

printf("\tOdd Or Even Check");
printf("\n========================================");

int num;

printf("\n\nEnter The Number : ");
scanf("%d", &num);

printf("\n________________________________________");

if (num % 2 == 0)
{
printf("\n\nThe Last Digit Of Number Is Even");
}

else
{
printf("\n\nThe Last Digit Of Number Is Odd");
}

printf("\n________________________________________\n\n");

return 0;
}

Description :
  • This is a C program that prompts the user to input an integer number and checks whether the last digit of the number is even or odd. The program uses the modulo operator % to determine whether the number is even or odd, and then prints the appropriate message to the console. The program ends by returning 0 to indicate that it has executed successfully.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.