[S2-SUMMATIVE] Summative Assessment 2 - CHAR AND STRING MANIPULATION REVIEWER

Character and String Manipulation Quiz
Test your knowledge of character and string manipulation in C++ with this comprehensive quiz! Designed for students and developers alike, it covers essential fun
- 30 multiple-choice questions
- Enrich your understanding of C++ string handling
- Perfect for revision or self-assessment
What is the error in the following program?
#include <cstring>
#include <iostream>
using namespace std;
int main ()
{
char key[] = "apple";
char buffer[80];
do {
cout << "Guess my favorite fruit? ";
cin.getline(buffer,80);
} while (strcmp (key,buffer) != 0);
cout << "Correct answer!"
return 0;
}
What is the output of the given program?
#include <iostream>
#include <ctype.h>
int main ()
{
int i=0;
char str[]="first line \n second line \n";
while (!iscntrl(str[i]))
{
putchar (str[i]);
i++;
}
return 0;
}
Check the following program
#include <iostream>
#include <ctype.h>
using namespace std;
int main ()
{
int I;
char str[]="c3po...??";
i=0;
while (isalnum(str[i])) i++;
cout << "The first " << I << " characters are alphanumeric.\n";
return 0;
}
What is the value of i?
What is the output of the given program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string a = "Jessica ";
a += "Jones";
cout << a;
return 0;
}
What is the output of the given program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str1 = "";
cout << str1.empty();
return 0;
}
What is the output of the following program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1 = "Hello";
string s2 = "Programming";
cout<< s1 + " " + s2 + "!";
return 0;
}
What is the output of the given program?
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
char str1 []= "Bianca";
char str2 []= "Bianca";
cout << strcmp(str1, str2);
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str1 = "This is a test";
cout << str1.empty();
return 0;
}
OUTPUT: _______
What is the output of the given program?
#include <iostream>
#include <ctype.h>
int main ()
{
int i=0;
char str[]="first line ";
return 0;
}
What is the output of the following program?
#include <iostream>
#include <string>
using namespace std;
int main () {
string myString = "Hello";
cout << myString[0];
return 0;
}
More Quizzes
- it's free to start.