Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
241 views
in Arrays by (30.5k points)
closed by

Consider the following C++ statements 

char str[] = “NO/nSMOKING”;

cout<<str;

1. What is the output of the above code? 

2. How many bytes will be allocated in the memory for the variable str?

1 Answer

+1 vote
by (30.4k points)
selected by
 
Best answer

1. NO 

SMOKING. The output is in 2 lines. 

2. A total of 11 bytes is used to store this string.

1 byte for \n. 1 byte for \0(The null character that is automatically appended) and 9 bytes for the remaining characters (N, 0, S, M, 0, K, l, N AND G).

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...