728x90 AdSpace

Latest Article

C++ String Function Quiz sample MCQ Question and Solution





C++ Programming String Function Quiz sample MCQ Multiple Choice Question and Solution 

1. What character ends all strings?
A. '.'
B. ' '
C. '\0'
D. '\n'

2. Which of the following reads in a string named x with one hundred characters?
A. cin.getline(x, 100, '\n');
B. cin.getline(100, x, '\n');
C. readline(x, 100, '\n');
D. read(x);

3. Which of the following functions compares two strings?
A. compare();
B. stringcompare();
C. cmp();
D. strcmp();

4. Which of the following adds one string to the end of another?
A. append();
B. stringadd();
C. strcat();
D. stradd();

5. What will be the output of this code?

string s="123456";
 int start=0;
 int end=s.length();
 while(start<end)
 {
  end--;
  char ctemp=s[start];
  s[start]=s[end];
  s[end]=ctemp;
  start++;
  }
 cout<<s;


 



SOLUTION


1. What character ends all strings?

C. '\0'

2. Which of the following reads in a string named x with one hundred characters?
A. cin.getline(x, 100, '\n');

3. Which of the following functions compares two strings?

D. strcmp();

4. Which of the following adds one string to the end of another?
C. strcat();


5. What will be the output of this code?


654321
 
no image
  • Title : C++ String Function Quiz sample MCQ Question and Solution
  • Posted by :
  • Date : 13:01
  • Labels :





  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top