

Strings - Programming
Q1: What will be the output of the program ?
#include<stdio.h>
int main()
{
char str[25] = "AptitudeCrack";
printf("%s\n", &str+2);
return 0;
}
A Garbage value
B Error
C No output
D diaAptitude
ANS:A - Garbage value Step 1: char str[25] = "AptitudeCrack"; The variable str is declared as an array of characteres and initialized with a string "AptitudeCrack". Step 2: printf("%s\n", &str+2); => In the printf statement %s is string format specifier tells the compiler to print the string in the memory of &str+2 => &str is a location of string "AptitudeCrack". Therefore &str+2 is another memory location. Hence it prints the Garbage value. |


For help Students Orientation
Mcqs Questions
One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.