Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Online Practice Test
>
c
« Previous
Next »
Output of the following program:
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}
Options
- 7
- 6
- 5
- error
CORRECT ANSWER : 5
Discussion Board
g
g
g 07-1-2017 03:47 AM
ccc
ccc
shubham bhuskade 07-1-2017 03:46 AM
Correct
\0 is escaped.hence size is 5!
Bipin Singh 09-18-2016 11:23 AM
I think the answer is 1.
AS \0 occurs,the string will end.so it takes the length before the string.so S is the only char and o/p is 1.
jakeera 07-24-2016 07:13 AM
Answer is wrong
It will output S5AB.
Sridhar 07-12-2015 02:41 PM
\065 is '5' :)
\065 is an octal code palced in our string, so the REAL string is "S5AB", the length is 4char + null terminator
Mihai 11-28-2014 10:30 AM
Explanation
5 is the correct answer. The two top comments are wrong. Barman should try running the code himself.
The null character (\0) at end of string IS counted. The embedded ascii control code '\06' (ACK) is discarded and therefore (the apparent 3 chars are) not counted. So the resulting output string is "S5AB", and the size of string is 5 (4 visible chars + null character).
gds 06-24-2014 03:17 AM
correct answer
/0 is not counted
ajinkya 04-24-2014 08:57 AM
answer is wrong
in C char[] or string is same thing and always NULL terminated
therefore char str[]="S\065AB"; has a size of 7+1=8
u can try running the code
Chinmoy Barman 01-22-2014 06:19 AM
ques.
can u please explain it?
sharmin 09-24-2013 04:35 AM
« Previous
Next »
Write your comments
*
*
Email must be in the form someone@domain.com
*
*
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
Related Content
C test (42)
C (12)
C++ for beginners (10)
C++ (20)
C++ (24)
C++ (18)
C++ (14)
C++ (12)
C++ (15)
C++ (15)
Data structure (20)
Data structure (10)
Data structure (10)
Data structure (10)
PERL (25)
VC++ (11)
Oops (30)
Mainframe (41)
Mainframe (15)
Embedded systems (15)
OOAD (49)
Advertisement
▲