Lecture35 - ComputerProgrammingITAC162. Todays Agenda...

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

View Full Document Right Arrow Icon
1 Computer Programming I TA C162 . 10 Apr 2006 Today’s Agenda Character Arrays One dimensional Two dimensional 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 . 10 Apr 2006 Problem1: Alphabetical ordering of a word #include<stdio.h> #include<string.h> int main() { char str[50],temp; int i,j,len; printf("Enter a string: "); gets(str); len = strlen(str); /* Finding length of the string */ for(i=0; i<len-1; i++) { for(j=0; j<len-i-1; j++) if(str[j]>str[j+1]) /*Alphabetical ordering */ { temp = str[j]; str[j] = str[j+1]; str[j+1] = temp; } /* Swaping */ } printf("\n Output string is: %s",str); }
Background image of page 2
3 Computer Programming I TA C162 . 10 Apr 2006 Problem Statement: List of Names is stored in a two dimensional character array. WAP to rearrange the list of names in alphabetical order. Algorithm : Bubble sort technique
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Computer Programming I TA C162 . 10 Apr 2006 Problem 2: Sorting the list of names main(); char names[10][30],temp[30]; int i=0,j=0; /* Reading The List */ while(i<10) { printf(“Enter the %d name”,i); scanf(“%s”,names[i++]); }
Background image of page 4
5 Computer Programming I TA C162 . 10 Apr 2006
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 / 14

Lecture35 - ComputerProgrammingITAC162. Todays Agenda...

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

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