Write a program to convert a string into uppercase using library function

Write a program to convert a string into uppercase

This preview shows page 7 - 10 out of 13 pages.

15. Write a program to convert a string into uppercase using library function. 16. Write a program to convert a string into uppercase without -using library function.
Image of page 7
C Programming Lecture Notes VVSV 115 After conversion: ANIL Passing string to a function Function prototype:- Return-type function name(char string name[size]); or Return-type function name(char [size]); or Return-type function name(char []); Calling function:- Function name(string name); Called function:- Return-type function name(char string name[size]) { } here ‘size’ is optional. Write a program to read and print string values using functions . #include<stdio.h> void read(char [20]); void display(char []); main() { char str[20]; read(str); display(str); } void read(char s[20]) { printf("\nEnter a string:"); gets(s); } void display(char s[]) { printf("The string is:"); puts(s); } output: Enter a string: krishna The string is: Krishna Write a program to find whether the given string is palindrome or not? #include<stdio.h> void read(char [20]); void display(char []); void palindrome(char []); main() { char str[20]; read(str); display(str); palindrome(str); }
Image of page 8
C Programming Lecture Notes VVSV 116 void read(char s[20]) { printf("\nEnter a string:"); gets(s); } void display(char s[]) { printf("The string is:"); puts(s); } void palindrome(char s[20]) { int length,c=0,i,j; length=strlen(s); for(i=0,j=length-1;i<=j;i++,j--) if(s[i]==s[j]) c++; if(c>=length/2) printf("The string is palindrome:"); else printf("Not palindrome"); } output: Enter a string: madam The string is: madam The string is palindrome Enter a string: sai krishna The string is: sai Krishna Not palindrome Double dimensional character arrays:- Collection of single character arrays Syntax :- char variable name[size1][size2]; or char variable name[row][column]; Here variable name indicates name of the double dimensional character array. Here row size indicates no of strings it can store and column size indicates the size of each string. Initialization of double dimensional character arrays:- Compile time initialization Run time initialization. Compile time initialization:- Char names[10][20]={{‘I’,’N’,’D’,’I’,’A’,’\0’}, {‘A’,’S’,’I’,’A’,’\0’}, {‘E’,’U’,’R’,’O’,’P’,’E’,’\0’}}; char names[][20]={{‘I’,’N’,’D’,’I’,’A’,’\0’}, {‘A’,’S’,’I’,’A’,’\0’}, {‘E’,’U’,’R’,’O’,’P’,’E’,’\0’}}; char names[10][20]={“INDIA”,”ASIA”,”EUROPE”}; char names[][20]={“INDIA”,”ASIA”,”EUROPE”}; Write a program to print the contents of double dimensional character array in different ways.
Image of page 9
Image of page 10

You've reached the end of your free preview.

Want to read all 13 pages?

  • Fall '17
  • sreelatha
  • ASCII, Anil

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture