C printf based Aptitude Questions and Answers

This section contains Aptitude Questions and Answers on C language C printf based (with multiple answers) with explanation.
Submitted by Ashish Varshney, on February 21, 2018

List of C programming printf based Aptitude Questions and Answers

1) What will be the answer of the code?

int main()
{
	int a=1,b=2,c=3;
	printf("%d %d %d");
	return 0;
}
  1. Garbage value
  2. compile_time Error
  3. 3 2 1
  4. None of above

2) What will be the answer of the code?

#define print  "%sincludehelp "
int main()
{
	int a=1,b=2,c=3;
	printf(print,print);
	return 0;
}
  1. Garbage value
  2. includehelp %sincludehelp
  3. %sincludehelp includehelp
  4. None of the above

3) What will be the output?

int main()
{
	int a=34;
	printf("%d %i %p %n",a,a,a,a);
	return 0;
}
  1. 34 34 00 22
  2. compilation error
  3. 34
  4. None of these.

4) What will be the output?

int main()
{
	char *str="includehelp";
	printf("%s",str+7);
	return 0;
}
  1. help
  2. includehelp
  3. ehelp
  4. None of these

5) What will be the output?

int main()
{
	printf("%d",printf("includehelp"));
	return 0;
}
  1. 11includehelp
  2. includehelp11
  3. compile_time error
  4. None of these

6) What will be the output?

int main()
{
	int n=0;
	while(n<printf("MENU\n"))
	{
		n++;
	}
	return 0;
}
  1. MENU
    MENU
    MENU
    MENU
    MENU
    MENU
  2. MENU
    MENU
    MENU
    MENU
    MENU
  3. compile_time error
  4. None of these





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.