











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












โ
โ
โ Function is a named unit of statements in a program to perform a specific task as part of the solution. โ There are two types of functions in C++: โ a). Predefined functions or Built in Functions : Functions that are already written , compiled and their definitions are grouped and stored in header files. Eg. sqrt(), toupper() โ b). User Defined Functions : Functions that are written by the user to carry on some task. Eg. main( )
โ
โ Stream Functions is used to perform input/output operations on character and strings. โ It allow a stream of bytes (data) to flow between memory and objects like Keyboard or Monitor. iostream header file required. i. get() : It can accept a single character or multiple characters (string) through the keyboard. Eg cin.get(str,10) ii.getline() : It accepts a string through the keyboard. Eg cin.getline(str,len); iii.put() : It is used to display a character constant or the content of a character variable given as argument. Eg. cout.put('B'); iv.write() : This function displays the string contained in the argument. Eg. cout.write(str,10);
โ (^) String functions allow manipulation of strings. โ cstring header file required. i. strlen() : used to find the length of a string(Number of characters ). Its return value is an integer. ii.strcpy() : used to copy one string into another. The function will copy string2 to string1. Syntax : strcpy(string1, string2); iii.strcat() : used to append one string to another string. Syntax: strcat(string1, string2); iv.strcmp() : used to compare two strings. In this comparison, the alphabetical order of characters in the strings is considered. Syntax: strcmp(string1, string2); v.strcmpi() :used to compare two strings ignoring cases (both the upper case and lower case letters are treated as same). syntax is same as strcmp.
โ (^) These functions are used to perform various operations on characters. โ (^) These functions require the inclusion of header file cctype 1)isupper() : This function is used to check whether a character is in upper case(capital letter) or not. The function returns 1 if the given character is in uppercase, and 0 otherwise. 2)islower() : This function is used to check whether a character is in lower case (small letter) or not. The function returns 1 if the given character is lower case, and 0 otherwise. 3)isalpha() : This function is used to check whether the given character is an alphabet or not. The function returns 1 if the given character is an alphabet, and 0 otherwise. 4)isdigit() : This function is used to check whether the given character is a digit or not. The function Output: 1 returns 1 if the given character is a digit, and 0 otherwise. 5)isalnum() : This function is used to check whether a character is alphanumeric or not. The function returns 1 if the given character is alphanumeric, and 0 otherwise. 6)toupper() : This function is used to convert the given character into its uppercase. The function returns the upper case of the given character. If the given character is in upper case, the output will be the same. 7)tolower() : This function is used to convert the given character into its lower case. The function returns the lower case of the given character. If the given character is in lowercase, the output will be the same.
โ
โ
โ
โ
FUNCTION HEADER FUNCTION BODY
โ
โ
โ
โ
โ
โ
โ
โ
โ
โ Q1) Name the mathematical function which returns the absolute value of an integer number โ abs() โ Q2) Explain any two built-in functions in C++ that are used for string manipulation โ Q3) Define built-in functions. Give two examples? โ Q4) The process of breaking large program into smaller sub-programs is called........ โ Modularization โ Q5) Define modular programming. โ Q6) Explain the merits of modular programming
โ Q7) Identify the built in C++ functions for the following cases โ i) to convert -25 to 25 โ abs() โ ii) compare โcomputerโ and โCOMPUTERโ ignoring cases โ strcmpi() โ iii) to check the given character is digit or not โ isdigit() โ iv) to convert the character โBโ to โbโ โ tolower() โ v) to find square root of 64 or a number โ sqrt()
โ