Test on C Programming Fundamentals

1. How we can initialize an integer constant

 
 
 
 

2. How many keywords are there in C language?

 
 
 
 

3. Which of the following identifiers are valid?

 
 
 
 
 
 
 

4. Which of the following are not C Keywords?

 
 
 
 
 
 
 
 

5. Which of the following declarations are incorrect?

 

 
 
 
 

6. #include <stdio.h>

void main()

{

int a=10;

a=a+10;

//a=10;

a++;

printf(“%d”,a);

}

What is the output of this code?

 
 
 
 

7. Which of the following are expressions?

  1.  a=5
  2.  a=5;
  3.  x+y
  4.  x=y+z
 
 
 
 

8. Which is the C standard input output library?

 
 
 
 
 
 

9. Which conversion specification  is used to specify an unsigned decimal integer?

 
 
 
 

10. #include<stdio.h>

void main()

{

char a[30];

printf(“Enter the sentence”);

scanf(“%s”,a);

printf(“%s”,a);

}

 

Output

Enter the Sentence

This is RIT ECE Department.

What is the output of the next print statement?

 

 

 
 
 
 

11. #include<stdio.h>

void main()

{

char a[30];

printf(“Enter the sentence”);

gets(a);

puts(a);

}

 

Output

Enter the Sentence

This is RIT ECE Department.

What is the output of the next print statement?

 

 

 
 
 
 

12. #include<stdio.h>

void main()

{

int a=10;

+a;

a++;

printf(“%d”,a);

}

what is the output of the program?

 

 

 

 
 
 
 

13. Which are valid statements?

 
 
 
 

14.

#include <stdio.h>

void main()

{

int a=1, r1,r2,r3,r4;

r1=a++;

r2=++a;

r3= – -a;

r4=a- -;

printf(“%d,%d,%d,%d”,r1,r2,r3,r4);

}

 

What is the output of the program?

 

 
 
 
 

15. What is the output of the following program?

#include<stdio.h>

void main()

{

int a,b,max;

a=10;

b=15;

max=a>b?a:b;

printf(“%d”,max);

}

 
 
 
 

16. What is the output of the following code?

 

#include<stdio.h>

void main()

{

printf(“%d”,printf(“hello”);

}

 
 
 
 

17. #include<stdio.h>

#include<conio.h>

void main()

{

unsigned int a = 10;

clrscr();

printf(“%X”,a);

getch();

}

 
 
 
 

18. #include<stdio.h>

#include<conio.h>

{

if(printf(“\nHello World\n”))

{

}

}

 

 
 
 
 

19. #include<stdio.h>

#include<conio.h>

void main()

{

int a=5,b=4;

a = a+ b;

b = a-b;

a = a-b;

printf(“a=%d\nb=%d”,a,b);

}

 

 

 
 
 
 

20. #include<stdio.h>

void main()

{

char a[30];

printf(“Enter the sentence”);

scanf(“%s”,a);

printf(“%s”,a);

}

 

Output

Enter the Sentence

This is RIT ECE Department.  (user input)

This

What change must be done in the scanf() statement to read and print the whole sentence?

 

 

 
 
 
 

21. #include <stdio.h>

void main()

{

int s;

printf(“enter a number”);

scanf(“%d”,&s);

if(s%2=0)

{

printf(“the number is even”);

}

else

{

printf(“the number is odd”);

}

}

 

 

What is the output of this program?

 

 
 
 
 

22. What is the output of the following program?

#include<stdio.h>

#include<conio.h>

void main()

{

unsigned char b=9;

clrscr();

printf(“%d\t”,b<<1);

printf(“%d”,b>>1);

getch();

}

 

 
 
 
 

23. Find the output of the given program:

#include<stdio.h.>

#include<conio.h>

void main()

{

short int a = 10;

printf(“%d”,sizeof(a));

}

 

 
 
 
 

24. #include<stdio.h>

#include<conio.h>

void main()

{

int a=3,b=4,c=1;

b=(a>b?(a>c?a:c):(b>c?b:c);

printf(“%d”,b);

}

 
 
 
 

25. Find the output of given program:

#include<stdio.h>

#include<conio.h>

void main()

{

int x = 2, y = 6, z = 6;

x=y==z;

printf(“%d”,x);

}

 
 
 
 

26. Find the output  of the following program:

#include<stdio.h.>

#include<conio.h>

void main()

{

int x = 3, y,z;

y=x=10;

z=x<10;

printf(“x=%d y=%d z=%d”,x,y,z);

}

 

 
 
 
 

27. How you can print %d using printf?

 

 
 
 
 

28. #include<stdio.h>

#include<conio.h>

void main()

{

int x=7,y=10,a,b;

a=x||y;

printf(“a=%d \t”,a);

b=x|y;

printf(“b=%d”,a);

}

 
 
 
 

29. Find the output of the given program :

#include<stdio.h>

#include<conio.h>

void main()

{

int x=5;

x+=x++;

printf(“x=%d”,x);

}

 
 
 
 

30. What is the output of the program?

 

#include<stdio.h>

#include<conio.h>

void main()

{

if(1)

printf(“this is the last question”);

else

printf(“No! this is not the last”);

 

}

 
 
 
 

Question 1 of 30

Leave a Reply

Your email address will not be published. Required fields are marked *