Lecture34 - ComputerProgrammingITAC162. Todays Agenda...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Computer Programming I TA C162 . 7 Apr 2006 Today’s Agenda Character Arrays One dimensional Arrays Coding Examples Arrays of strings (Two Dimensional Char Arrays) Declaration Initialization Printing Reading Coding Examples
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Computer Programming I TA C162 . 7 Apr 2006 Palindrome problem: Algorithm Design 1. Read a string in str[0….n-1] pre condition n>=1 2. Initialize left = 0 and right = n-1 1. Repeat for left<right 3.1 str[left] != str[right] terminate with false 3.2 Increment left and decrement right 1. Terminate with true Post condition Returns false If str[left] != str[right] for any value of left>=0 and right<=n-1 Where left<right
Background image of page 2
3 Computer Programming I TA C162 . 7 Apr 2006 Palindrome problem: Implementation void main() { char str[80]; int left,right,i,len,flag = 1; printf("Enter a string"); for(i = 0;(str[i] = getchar())!='\n';++i); len = i-1; for(left = 0,right = len; left < right; ++left,--right) { if(str[left]!= str[right])
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/14/2010 for the course CS SS ZG653 taught by Professor Shanta during the Spring '09 term at Birla Institute of Technology & Science.

Page1 / 11

Lecture34 - ComputerProgrammingITAC162. Todays Agenda...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online