Design an algorithm, draw a corresponding flowchart and write a C program to check whether a given string is a palindrome or not. 10m Jun2006

By | June 13, 2014

Design an algorithm, draw a corresponding flowchart and write a C program to check whether a given string is a palindrome or not. 10m Jun2006

An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English rather than within the programming language

  1. A sequential solution of any program that written in human language, called algorithm.
  2. Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem.

Pseudo code: 

  • Input a String
  • Initialize Len to zero , Flag to zero
  • While String[Len] is not equal to NULL
  •    Increment Len
  • Initialize I to zero , J to Len-1
  • While I is less than (Len/2)+1
  •               If String[I] equal to String[J]
  •                           Flag=0
  •                 else
  •                            Flag=1
  •                 Increment I , Decrement J
  • If Flag equal to zero
  •         Print Key Is a Palindrome
  • else
  •         Print Key Is Not a Palindrome
  • Stop

Detailed Algorithm:

Step 1:  Input S (string)

Step 2:  Len = 0 , Flag =0

Step 3:  While (S[Len] != NULL)

                        Len++

Step 4:  I = 0 , J = Len-1

Step 5:  While ( I < (Len/2)+1 )

                        If ( S[I] == S[J] )

                                 Flag=0

                        else

                                  Flag=1

                        I++ , J–

Step 6:      If ( Flag == 0 )

                               Print Key Is a Palindrome

                     else

                                Print Key Is Not a Palindrome

Step 7: End

 Flowchart:-

 FlowChart_Palindrome

 Solved program can be found on this link http://cssimplified.com/c-programming/an-interactive-c-program-to-add-two-matrices-or-subtract-two-matrices

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.