C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

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

C Basic Input/Output - Aptitude Questions & Answers

C programming Basic Aptitude Questions and Answers: In this section, you will find C Aptitude Questions and Answers on Basic Input, Output, Data Type, printf, scanf etc.

List of C programming basic input, output, declaration, data types Aptitude Questions and Answers

1) What will be the output of following program ?
#include <stdio.h>
void main()
{
	printf("includehelp.com\rOK\n");
	printf("includehelp.com\b\b\bOk\n");
}
  1. OK
    includehelp.ok
  2. OK
    includehelp.okm
  3. includehelp.com
    includehelp.okm
  4. OKcludehelp.com
    includehelp.okm

2) What will be the output of following program ?
#include <stdio.h>
void main(){
    unsigned char c=290;
    printf("%d",c);
}
  1. 34
  2. 290
  3. Garbage
  4. ERROR

3) What will be the output of following program ?
#include <stdio.h>
void main(){
	int a=0;
	a=5||2|1;
	printf("%d",a);
}

  1. 1
  2. 7
  3. 0
  4. 8

4) What will be the output of following program (on 32 bit compiler)?
#include <stdio.h>
int main(){
	float a=125.50;
	int	  b=125.50;
	char  c='A';

	printf("%d,%d,%d\n",sizeof(a),sizeof(b),sizeof(125.50));
	printf("%d,%d\n",sizeof(c),sizeof(65));
	return 0;
}
  1. 4,4,4
    1,4
  2. 4,4,8
    1,1
  3. 4,4,4
    1,1
  4. 4,4,8
    1,4

5) What will be the output of following program ?
#include <stdio.h>
int main(){
	static char a;
	static long b;
	int c;

	printf("%d,%d,%d",a,b,c);
	return 0;
}
  1. 0,0,0
  2. Garbage,Garbage,Garbage
  3. Garbage,Garbage,0
  4. 0,0,Gargabe

6) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int ok=-100;
	-100;
	printf("%d",ok);
	return 0;
}
  1. 100
  2. ERROR
  3. -100
  4. 0

7) What will be the output of following program ?
#include <stdio.h>
enum numbers
{
	zero, one, two, three , four=3,five,six,seven=0,eight
};
void main()
{
	printf("%d,%d,%d,%d,%d,%d,%d,%d,%d",zero,one,two,three,four,five,six,seven,eight);
}
        
  1. 0,1,2,3,3,4,5,0,1
  2. 0,1,2,4,5,6,7,8,9
  3. 0,1,2,3,3,1,2,3,4
  4. 0,1,2,3,3,4,5,0,9

8) What will be the output of following program ?

#include <stdio.h>
int main(){
	int a,b,c;
	a=0x10; b=010;
	c=a+b;
	printf("\nAddition is= %d",c);
	return 0;
}
  1. Addition is = 20
  2. Addition is = 24
  3. Addition is = Garbage
  4. ERROR

9) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int var=250;
	printf("value of var = %d\n",var);
	200+50;
	"includehelp.com";
	printf("%s\n","includehelp");
	return 0;
}
  1. value of var = 250
    includehelp.com
  2. value of var = 250
    includehelp
  3. ERROR
  4. value of var = 250
    Garbage

10) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int a=100;
	printf("%d\n"+1,a);
	printf("Value is = %d"+3,a);
	return 0;
}

  1. ERROR
  2. 101,
    Value is = 103
  3. d
    ue is = 100
  4. 100
    100

11) What will be the output of following program ?
#include <stdio.h>
int main()
{
	extern int ok;
	printf("value of ok = %d",ok);
	return 0;
}
	extern int ok=1000;
  1. Declaration error
  2. value of ok = 1000.
  3. Linking error
  4. value of ok = 0.

12) What will be the output of following program ?
#include <stdio.h>
int main()
{
	int a=23;
	;
	;printf("%d",a);
	;
	return 0;
}
  1. 23
  2. Error
  3. ;23;
  4. ;23

13) Find the output of this program,(program name is : static_ex.c)?
#include <stdio.h>
int main()
{
	int intVar=24;
	static int x=intVar;
	printf("%d,%d",intVar,x);
	return 0;
}
  1. 24,24
  2. 24,0
  3. ERROR: Illegal Initialization
  4. Run time error.

14) Find the output of this program ?
#include <stdio.h>
int main()
{
	int a=15;
	float b=1.234;
	printf("%*f",a,b);
	return 0;
}
  1. 1.234
  2. 1.234000
  3.        1.234000
  4. ERROR

15) Find the output of this program ?

#include <stdio.h>
int main()
{
	float a,b;
	a=3.0f;
	b=4.0f;
	printf("%.0f,%.1f,%.2f",a/b,a/b,a/b);
	return 0;
}
  1. 1,0.8,0.75
  2. 0,0.7,0.75
  3. 0,0.8,0.75
  4. ERROR: Invalid format specifier

16) Which is the valid identifier (variable name) to store student’s age?
  1. int student-age;
  2. int student_age;
  3. int -age;
  4. int _age;

17) What type of declaration is it?
        unsigned num;
        
  1. num is an unsigned integer.
  2. num is an unsigned character.
  3. num is an unsigned float.
  4. It’s an invalid declaration.

18) Which statement does not require semicolon?
  1. goto xyz
  2. int x=20
  3. #define MAX 1000
  4. do{ ... }while(count<=100)









COMMENTS