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.
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:
1 // This program demonstrates the strcmp and atoi functions. 2 #include3 #include // For tolower 4 #include // For strcmp 5 #include // For atoi 6 using namespace std; 7 8 int main() 9 { 10 const int SIZE = 20; // Array size 11 char input[SIZE]; // To hold user input 12 int total = 0; // Accumulator 13 int count = 0; // Loop counter 14 double average; // To hold the average of numbers 15 16 // Get the first number. 17 cout << "This program will average a series of numbers. "; 18 cout << "Enter the first number or Q to quit: "; 19 cin.getline(input, SIZE); 20 21 // Process the number and subsequent numbers. 22 while (tolower(input[0]) != 'q') 23 { 24 total += atoi(input); // Keep a running total 25 count++; // Count the numbers entered 26 // Get the next number. 27 cout << "Enter the next number or Q to quit: "; 28 cin.getline(input, SIZE); 29 } 30 31 // If any numbers were entered, display their average. 32 if (count != 0) 33 { 34 average = static_cast (total) / count; 35 cout << "Average: " << average << endl; 36 } 37 return 0; 38 }
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";
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
