String Data Structure Quiz for Beginners (original) (raw)
string a = "10";
string b = "20";
string c = a + b;
Guess the output:
What the below program will Print?
C++ `
#// C program to find the length of string #include <bits/stdc++.h> using namespace std; int main() {
string str = "Hello Geeks";
int i;
for (i = 0; str[i] != '\0'; ++i)
;
cout << i;
return 0;}
`
Which of these methods of class String is used to obtain the length of the String object?
What is the output of the below code?
C++ `
#include using namespace std;
int main() {
string str = "GeeksForGeeks";
cout << str.substr(2).substr(4);
return 0;}
`
Which of the following is a palindromic string?
What is the time complexity to reverse a string?
Which of these methods from the String class is used to extract a single character from an object of String?
How does strcmp() function work to compare two strings?
- It compares characters based on their index.
- It compares strings based on the index.
- It compares characters of the string based on their ASCII values.
Which of the following statement is a binary string?
What is the output of the following code?
C++ `
#include using namespace std;
int main() {
cout << "GFG!"[0] <<" "<<"GFG!"[3] ;
return 0;}
`
There are 20 questions to complete.
Take a part in the ongoing discussion