Page 1 :
CHAPTER 8, FUNCTIONS, I. FILL IN THE BLANKS, 1. Functions, 2. String functions 3. strcmp(), 4. strcat() 5. counts, II. MATCH THE FOLLOWING, 1. strrev() accepts single string, 2. strcpy() used for copying strings, 3. “\0”, null character, 4. Library functions built-in functions, 5. scanf() does not accept space, III. ANSWER THE FOLLOWING, 1. What is a function and what are its types?, Functions are self-contained program blocks used to do a specific task. Functions are, of 2 types namely Library functions and User-defined functions., 2. Mention the classifications of Library functions., The library functions in C are classified into different types. Some of them are, Mathematical functions, String functions, Time & Date functions, Standard Input /, Output functions and Character class test functions., 3. What is a user defined function?, As the name suggests these functions are defined by the user and are written as a part, of the program according to the programmer’s requirement. They can be called in a, program as many times as needed., 4. Differentiate strcpy( ) and strcat( )., Strcpy( ), It accepts two strings and, copies thesecond string to the, first string., Eg : Str1=“Unique”,, Str2=”Software”, strcpy(Str1,Str2), Output : Software, , VI.PROGRAM:, 1. Program to reverse a String., #include<stdio.h>, #include <string.h>, void main(), { char arr[100];, printf("Enter a string to reverse\n");, gets(arr);, strrev(arr);, printf("Reverse of the string is \n%s\n", arr);, }, , Strcat( ), It accepts two strings and, combinestwo strings into a single, string., Eg : Str1=”Unique”,, Str2=”Software”strcat(Str1,Str2), Output : UniqueSoftware
Page 2 :
2. Program to find the length of a string without using strlen()., #include <stdio.h>, #include<conio.h>, int main(), {, char s[1000];, int c = 0;, printf("Input a string\n");, gets(s);, while (s[c] != '\0'), c++;, printf("Length of the string: %d\n", c);, return 0;, }, 3. Accept any two string, copy it and return it along with the string “ GOOD BYE”, #include <stdio.h>, #include <string.h>, int main(), {, char a[1000], b[1000], c[100]=”GOOD BYE”;, printf("Enter the first string\n");, gets(a);, printf("Enter the second string\n");, gets(b);, strcat(a, c);, strcat(b, c);, printf("String obtained on concatenation: %s\n", a);, printf("String obtained on concatenation: %s\n", b);, return 0;, }, ************