How this statement in C is evaluated? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How this statement in C is evaluated?

I was asked to choose the output for this statement in C. printf(6+"Hello World!");

9th Sep 2023, 10:46 AM
Marjuk Sajid
Marjuk Sajid - avatar
4 Answers
+ 4
I will add another hint to William Owens answer. The literal string "Hello World" evaluates as a pointer (char *). Think of the expression being evaluated in the context of pointer arithmetic.
9th Sep 2023, 8:53 PM
Brian
Brian - avatar
+ 1
Think about the indice numbering. The first argument in the printf function is a pointer to a char.
9th Sep 2023, 12:51 PM
William Owens
William Owens - avatar
+ 1
W
10th Sep 2023, 8:35 AM
Alhaaz
Alhaaz - avatar
+ 1
Alhaaj [LESS ACTIVE] ,Close try running it in a main function and see the output, why do you think the output is slightly different?
10th Sep 2023, 2:23 PM
William Owens
William Owens - avatar