Lec c11 - ComputerProgrammingITAC162. Passing Arrays To...

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 . Passing Arrays To Functions (Pass by reference) One- dimensional Array: int Maximum(int a[], int size); main() { int val[5]={3,5,2,7,4}; printf(“%d\n”,Maximum(val,5)); } int Maximum(int a[], int size) { int i, max = a[0]; for(i=0; i<size; i++) if(max<a[i]) max = a[i]; return(max); }
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 . Character Manipulation in the String int main() { char s[80],ws[80]; int i,j; printf(“Enter the text:\n”); gets(s); /* reading text from user */ printf(“The text without blank space is:\n”); puts(ws); /* printing text on monitor */ return; } Q. Write a separate function for the same. for(i=0,j=0; s[i]!=‘\0‘; i++) { if(s[i]!=‘ ‘) ws[j++] = s[i]; } ws[j]=‘\0’;
Background image of page 2
3 Computer Programming I TA C162 . Important Character functions in ctype.h isdigit(c) /*Returns a nonzero if c is a digit*/ islower(c) /* Returns a nonzero if c is a lower case alphabetic character */ isalpha(c) /*Returns a nonzero if c is an alphabet*/ isspace(c) /*Returns a nonzero for blanks */ isupper(c) /*Returns a nonzero if c is capital letter*/ toupper(c) /* Returns upper case of c */ tolower(c) /* Returns lower case of c */
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 / 12

Lec c11 - ComputerProgrammingITAC162. Passing Arrays To...

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