Home » Aptitude Questions and Answers » C Aptitude Questions and Answers

C Declaration and Initialization Aptitude Questions and Answers

This section contains aptitude questions and answers on C language Declarations and Initialization.

1) What will be the output of following program ?
int main(){
    int m=10;
	int x=printf("%d ",m);
	printf("%d",x);
	return 0;
}
  1. 10 3
  2. 103
  3. 10 2
  4. 102

2) What will be the output of following program ?
int main(){
	int x='A';
	printf("%02X",x);
	return 0;
}
  1. 65
  2. 97
  3. Error
  4. 41


3) What will be the output of following program ?
int main(){
	char a=0b1010;
	printf("%02X",a);
	return 0;
}
  1. 0A
  2. A
  3. 0a
  4. 10

4) What will be the output of following program (on 32 bit compiler)?
int main(){
	char a=2*2+2;
	printf("%d",a);
	return 0;
}
  1. 0
  2. Garbage
  3. 6
  4. 8

5) What will be the output of following program ?
int main(){
	unsigned char x=-1;
	printf("%02X",x);
	return 0;
}
  1. 0xFFFFFFFF
  2. FF
  3. 0xFF
  4. ff


6) Which is the correct name of a variable?

(A) -var (B) var-1 (C) _var (D) var_1

  1. Only (A)
  2. Only (B)
  3. Both (A) and (B)
  4. Both (C) and (D)

7) Which special character can be used to separate two parts (words) of a variable/identifier name?

  1. - (Hyphen)
  2. _ (Underscore)
  3. $ (Dollar)
  4. # (Hash)

8) What will be the result of following program?

#include <stdio.h>
int main()
{
	char x='AB';	
	printf("%c",x);	
	return 0;
}
  1. Error
  2. Runs successfully and prints 'A' (without quote)
  3. Run with warnings and prints 'B' (without quote)
  4. None of these


9) Will following string be terminated with NULL?

char str[]={'H','e','l','l','o'};
  1. YES
  2. NO

10) Predict the output of following program.

#include <stdio.h>

int main()
{
	int (x)=10;
	printf("x= %d",x);
	
	return 0;
}
  1. x= 10
  2. x= 0
  3. Error
  4. None of these

11) Predict the output of following program.

#include <stdio.h>

int main()
{
	int i=50;
	const int x=i++;
	
	printf("x= %d",++x);
	
	return 0;
}
  1. x= 50
  2. x= 51
  3. x= 52
  4. Error

12) Predict the output of following program.

#include <stdio.h>

int main()
{
	int a=(10,20);
	
	printf("a= %d",a);
	
	return 0;
}
  1. a= 10
  2. a= 20
  3. a= 30
  4. Error







Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.