Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Palindrome Checker Coding Problem, Exams of Computer Science

The solution to a coding problem where you are required to write a program in c to check if a given string is a palindrome or not. The problem statement, the code solution, and the expected output are provided in the document.

What you will learn

  • What is the time complexity of the provided C code solution?
  • How does the provided C code solution check if a string is a palindrome?
  • What is the purpose of the given coding problem?

Typology: Exams

2018/2019

Uploaded on 09/08/2019

kakali-das
kakali-das 🇮🇳

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TEST CODE : TCS Ninja -
Coding_2
Total number of question : 1
Test duration (min) : 20 min
Correct attempt (mark) : NA
Wrong attempt (mark) : NA
CODING
Program to check string palindrome.
#include <stdio.h>
#include <string.h>
int main(){
char string1[20];
int i, length;
int flag = 0;
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);
}
FACETCS Ninja - Coding_2
______________________________________________________________________________________________________
Focus Academy for Career Enhancement Page 1 of
2
pf2

Partial preview of the text

Download Palindrome Checker Coding Problem and more Exams Computer Science in PDF only on Docsity!

TEST CODECoding_2 : TCS Ninja - Total number of question : 1 Test duration (min) : 20 min Correct attempt (mark) : NA Wrong attempt (mark) : NA

CODING

Program to check string palindrome. #include <stdio.h> #include <string.h> int main(){ char string1[20]; int i, length; int flag = 0; 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); }

FACETCS Ninja - Coding_

______________________________________________________________________________________________________Focus Academy for Career Enhancement Page 1 of 2

return 0; }