Please answer all (C++) 1.What does the function “isalpha” do? 2.What does the f
ID: 3826011 • Letter: P
Question
Please answer all (C++)
1.What does the function “isalpha” do?
2.What does the function “ispunct” do?
3.What is the size of the array “name”? Explain.
char name[] = “JohnDoe”;
4.Give an example program snippet that uses the functions “strncat” and “strncpy”.
5.What does the function “strstr” return?
6.Read program 10-10 on page 572 of the text book. Why does the program not take integer numbers as input? Why does it need to read in text and then convert it to an integer?
Program 10-10, Page 572:
7. What happens with the following piece of code? Why? Explain in detail.
string name1 = "Mary";
string name2 = "Mark";
if (name1 > name2)
cout << "Mary is greater than Mark";
else
cout << "Mark is greater than Mary";
Explanation / Answer
(1) 'Isalpha' function ----> isalpha() is a function used to check whether the given argument is entered alphabetic character or not . even though it accepts int but it deals with character , It returns zero if the argument is not character else it will returns non zero .
syntax --- int isalpha ( int character )
header file used for this function is ---- 'cctype' .
(2) 'ispunct' --------> ispunct() function is similar to 'isalpha()' the only difference is that it check the punctuation character instead of albhabetic character . ispunct takes an argument and check wether it is a punctuation character or not . punctution character includes all printing symbol except alphanumeric and space .
syntax ------- int ispunct ( int char )
same header file is used for this function also .
(3) The size of the array “name”
char name[] = “JohnDoe”;
here it is clear that name is initialized as string and it will be allocated in the array as
array size will be as :
(5) "strstr()' ---------- > strstr() is used to locate a substring by returning a pointer to the first occurence of str2 in str1 . It is alos used to find the first occurence of a substring in a string . if no such substring full it returns null
syntax ---- > const char * strstr ( const char* str , const char* target )
char* strstr ( char* str , const char* target )
str ---- > striing to examine
target ----- > string to search for
It is defined under ' <cstring> ' header file
j o h n d o eRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.