Answers for "palindrome number c with guide"

C
1

c how to check a palindrome string

#include <stdio.h>
#include <string.h>

int main(){
    char string1[20];
    int i, length;
    int flag = 0;
    
    printf("Enter a string:");
    scanf("%s", string1);
    
    length = strlen(string1);
    
    for(i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1]){
            flag = 1;
            break;
   }
}
    
    if (flag) {
        printf("%s is not a palindrome", string1);
    }    
    else {
        printf("%s is a palindrome", string1);
    }
    return 0;
}
Posted by: Guest on January-18-2022
0

Palindrome number in c program

#include<stdio.h>
void main(){
    int num, cNum, rev, rem;
    printf("Enter a number = ");
    scanf("%d",&num);   //0

    cNum = num; //123
    rev = 0;
    while(cNum != 0){
        rem = cNum % 10;
        rev = rev * 10 + rem;
        cNum /= 10;
    }
    if(num == rev){
        printf("Palindrome");
    }
    else{
        printf("Not Palindrome");
    }
}
Posted by: Guest on February-24-2022

Code answers related to "C"

Browse Popular Code Answers by Language