{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture35 - Todays Agenda Character Arrays One dimensional...

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

1 Computer Programming I TA C162 . 10 Apr 2006 Today’s Agenda Character Arrays One dimensional Two dimensional Coding Examples

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

View Full Document
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); }
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

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

View Full Document
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++]); }
5 Computer Programming I TA C162 .

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 14

Lecture35 - Todays Agenda Character Arrays One dimensional...

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

View Full Document
Ask a homework question - tutors are online