Search
 
SCRIPT & CODE EXAMPLE
 

C

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;
}
Comment

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");
    }
}
Comment

palindrome program in c language

/*
Palindrome number in c: A palindrome number is a number that is same after 
reverse. For example 121, 34543, 343, 131, 48984 are the palindrome numbers.
*/

#include<stdio.h>  
int main()    
{    
int n,r,sum=0,temp;    
printf("enter the number=");    
scanf("%d",&n);    
temp=n;    
while(n>0)    
{    
r=n%10;    
sum=(sum*10)+r;    
n=n/10;    
}    
if(temp==sum)    
printf("palindrome number ");    
else    
printf("not palindrome");   
return 0;  
}   
Comment

PREVIOUS NEXT
Code Example
C :: printf type format 
C :: divide and conquer program in c 
C :: function for quicksort in c 
C :: find length of int number in c 
C :: puts without newline c 
C :: addition in c 
C :: pg_restore: error: input file appears to be a text format dump. Please use psql. 
C :: how to check if a string pointer is empty in c 
C :: c program for swapping of two numbers using temporary variable 
C :: Area of a Circle in C Programming 
C :: add char to char array c 
C :: c print to stderr 
C :: Firebase Connecting with ESP8266 
C :: memcpy c 
C :: plt legend top right outside 
C :: prime factorization of factorials using c 
C :: ft_putchar 
C :: flip exis in dataframe 
C :: how to malloc for matrix in c 
C :: addition of matrix 
C :: c change value of const 
C :: faire une facture en langage c 
C :: powershell search big files 
C :: fread 
C :: time include c 
C :: passing pointer to function 
C :: declare an array 
C :: C Pass Individual Array Elements 
C :: c program for calculating product of array 
C :: <fileset joomla 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =