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 :: pointer arithmetic in c 
C :: second largest element in an array 
C :: convert string to int error checking c 
C :: string array in c 
C :: set the nth bit 
C :: how to take comma separated integer input in c 
C :: malloc c 
C :: C strlen implementation 
C :: c linked list 
C :: signed and unsigned in c 
C :: Turn on the first n Bits in number 
C :: c memcpy array 
C :: how to print % in c 
C :: prime numbers 
C :: function that changes all lowercase letters of a string to uppercase. 
C :: %g and %e in c 
C :: declare and initialize a string in C 
C :: man strstr 
C :: yt derived field 
C :: setw in c 
C :: convert c to phyton 
C :: c program for fibonacci series 
C :: delimter in c 
C :: c timespec 
C :: buble sort in c that ask user input 
C :: change data type inline in c 
C :: Trier lexicographiquement en c 
C :: Single-line Comments in C 
C :: Print fabionci with fork in C 
C :: Trasmettere variabile float attraverso seriale 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =