Skip to content

Instantly share code, notes, and snippets.

@Burakkepuc
Created December 10, 2020 13:05
Show Gist options
  • Select an option

  • Save Burakkepuc/d9548fb22487312b1154e8ff38de61db to your computer and use it in GitHub Desktop.

Select an option

Save Burakkepuc/d9548fb22487312b1154e8ff38de61db to your computer and use it in GitHub Desktop.
Data Structure Palindrom Program
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Please attension big-small letter. It works with ascii value.
void push(char element);
char pop();
char stack[30],ele;
int top = - 1;
int main(){
char string[30];
int i,len,count = 0;
printf("Enter String:\n ");
scanf("%s",string);
len = strlen(string);
for(i = 0; i < len; i++){
push(string[i]);
}
for(i = 0; i < len; i++){
if(string[i] == pop()){// Control first string and last popping element, if they are eqaual, count+1;
count++;
}
}
if(count == len){
printf("Palindrome\n");
}
else{
printf("Not palindrome\n");
}
}
char pop(){
ele = stack[top];
top--;
return ele;
}
void push(char element){
if(element == stack -1){
printf("Overflow\n");
}
top++;
stack[top] = element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment