0% found this document useful (0 votes)
10 views1 page

Input

Uploaded by

vinitsoni560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Input

Uploaded by

vinitsoni560
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Q-3. Write a Program to Check Whether a Number is Palindrome or Not.

INPUT=
#include <stdio.h>

int main() {
int num, reversedNum = 0, remainder, originalNum;

// Ask user for the number


printf("Enter an integer: ");
scanf("%d", &num);

originalNum = num; // Store the original number

// Reverse the number


while (num != 0) {
remainder = num % 10; // Get the last digit
reversedNum = reversedNum * 10 + remainder; // Build the reversed number
num /= 10; // Remove the last digit from num
}

// Check if the original number and reversed number are the same
if (originalNum == reversedNum) {
printf("%d is a palindrome.\n", originalNum);
} else {
printf("%d is not a palindrome.\n", originalNum);
}

return 0;
}

You might also like