Question
C++ is fhe language
3. a) Write down answer for each of the following i) Give example of any string constant: ii) What is the relational operator
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I can asnwer you for few questions.

3)

iv) SET LINESIZE command to control the width of the data displayed.

SET NUM[WIDTH] {10 | n}

Sets the default width for displaying numbers.

v)

#include<iostream>
#include<cstring>
using namespace std;
main() {
   string myStr = "This is a sample string";
   char myStrChar[] = "This is a sample string";
   cout << "String length using string::length() function: " << myStr.length() <<endl;
   cout << "String length using string::size() function: " << myStr.size() <<endl;
   cout << "String length using strlen() function for c like string: " << strlen(myStrChar) <<endl;
   cout << "String length using while loop: ";
   char *ch = myStrChar;
   int count = 0;
   while(*ch != '\0'){
      count++;
      ch++;
   }
   cout << count << endl;
   cout << "String length using for loop: ";
   count = 0;
   for(int i = 0; myStrChar[i] != '\0'; i++){
      count++;
   }
   cout << count;
}

Expected Output:

String length using string::length() function: 23
String length using string::size() function: 23
String length using strlen() function for c like string: 23
String length using while loop: 23
String length using for loop: 23
Add a comment
Know the answer?
Add Answer to:
C++ is fhe language 3. a) Write down answer for each of the following i) Give...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT