1.

Explain five string handling functions with syntax and examples. 

Answer»

1. Strlen( ) function:

It calculates the length of the given string and returns the number of characters in a string.

Syntax: integer variable = strlen(string);

Ex: length = strlen(“Bharath”);

Output : 7

2. Strcat() Function:

It adds the characters of one string to the end of another string. It is used to join the two strings together.

Syntax: strcat(stringl, string2); 

Ex: string1 = ”Bharath” string2 = ”Bhushan”, strcat(stringl, string2);

Output: Bharath Bhushan

3. Strrev() Function:

It reverses the characters in a string.

Syntax: strrev(string);

Ex: strrev(“ABCD”);

Output: DCBA

4. Strlwr() Function

Converts all characters in a string to lower (small letters) case. 

Syntax: strlwr(string);

Ex: strlwr(“BHARATH”)

Output: bharath

5. Strupr() Function

Converts all characters in a string to upper (capital letters) case.

Syntax: strupr(string);

Ex: strupr(“bharath”)

Output: BHARATH 



Discussion

No Comment Found

Related InterviewSolutions