0% found this document useful (0 votes)
86 views10 pages

C Skills

1. The document contains 35 coding questions related to C programming. It covers topics like loops, conditional statements, operators, functions, arrays, pointers etc. 2. The questions range from basic to advanced level and test understanding of core C concepts as well as ability to analyze code snippets and predict output. 3. Solving these questions will help to evaluate and strengthen C programming skills.

Uploaded by

muroorkarthik55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views10 pages

C Skills

1. The document contains 35 coding questions related to C programming. It covers topics like loops, conditional statements, operators, functions, arrays, pointers etc. 2. The questions range from basic to advanced level and test understanding of core C concepts as well as ability to analyze code snippets and predict output. 3. Solving these questions will help to evaluate and strengthen C programming skills.

Uploaded by

muroorkarthik55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

Test Your C Skills: By-Yashavant Kanetkar: Books

http://www.pskills.org/c.jsp

https://www.geeksforgeeks.org/c-programming-language/

1.
What will be output when you will execute following code?
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf("%d%d",x,y);

2.
#include<stdio.h>
main()
{
char arr[11]="The African Queen";
printf("%s",arr);
}

3.
void main()
{
int a;
a='a'>'A'; a=97, A=65
printf("%d",a);
}

4.
void main()
{
float a;
a=8.5;
if(a==8.5)
printf("1");
else
printf("2");
}

5.
switch(option)
{
case 'H' : printf("Hello");
case 'W' : printf("Welcome");
case 'B' : printf("Bye");
break;
}
what would be the output if option = 'H' ?
6.
How many times the below loop will run
main()
{
int i;
i=0;
do
{
--i; -1
printf("%d",i);
i++; 0
}
while(i>=0);
}

7.
Suppose a,b,c are integer variables with values 5,6,7 respectively. What is the
value of the expression:
!((b+c)>(a+10))

8.
What will be the output
main()
{
int i;
i = 10;
if(i == 20 || 30) (0||30) 0||1
{
printf("True");
}
else
{
printf("False");
}
}

9.
What will be the output
main()
{
if(1,0) - RHS will be considered. if(10>20,12<6)
{
printf("True");
}
else
{
printf("False");
}
}

10.
What will be the output
main()
{
int i, j, *ptr, *ptr1;
i = 10;
j = 10;
ptr = &i;
ptr1 = &j;
if(ptr == ptr1)
{
printf("True");
}
else
{
printf("False");
}
}

11.
How many times the below loop will get executed?
main()
{
int i;
for(i=20, i=10; i<=20; i++)
{
printf("\n %d", i);
}
}

11

12.
main ()
{
int i, j, k;
i = 3;
j =2*(i++);
k =2*(++i);
}

5,6,10

13.
main()
{
int x=5;
printf("%d,%d,%d",x,x<<2,x>>2);
}

5, 101
10100

14.
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf("%d %d",x,y);
}

15.
void abc(int a)
{
++a;
printf("%d",a);
}

void main()
{
int a=10;
abc(++a);
abc(a++);
printf("%d",a);
}
12,12,12

16.
What the below statement will print if a=10 and b = 20?
printf("%d",a==b);

17.
How many times the below loop will get executed?
main()
{
int i,j;
i = 10;
for (j=i==10 ; j<=10 ; j++) j=1
{
printf("\n%d",j);
}
}

18.
How many times the while loop will get executed?
main ( )
{
int a = 1 ;
while ( a <= 100) ;
{
printf ( "%d", a++ ) ;
}
}

19.
main()
{
int i;
i = 10;
printf("%d\t",5,6);
printf("%d%d", i , i++);
}

20.
void main()
{
int a=1;
void xyz(int , int);
xyz(++a,a++);
xyz(a++,++a);
printf("%d",a);
}

void xyz(int x, inty)


{
printf("%d%d",x,y);
}
2,1

21.
void main(){
int a=2;
switch(a);
{
case 1: printf("A");
case 2: printf("B");
case 3: printf("C");
break;
case 4: printf("D");
default: printf("E");
break;
}
}

22.
void abc(int a, int b){
printf("%d%d",++a,++b);
}
void main(){
int a=10;
abc(++a,a++);
abc(a++,++a);
printf("%d",a);
}

23.
main()
{
printf(3+"Proskills"+4);
}

24.
main()
{
int i;
for(i=0;i<5;i++)
{
static int a=0;
int b=0;
a++;
b++;
printf("%d %d",a,b);
}
}

25.
main()
{
int a = 5;
switch(a)
{
default:
a = 4;
case 6:
a--;
case 5:
a = a+1;
case 1:
a = a-1;
}
printf("%d \n",a);
}

26.
main()
{
static int s;
++s;
printf("%d",s);
if(s<=3)
main();
printf("%d",s);
}

27.
int a;
main(){
printf("\n a= %d",a);
}

28.
main()
{
int a, b, c;
a = 10;
b = 20;
c = printf("%d",a) + ++b;
printf ("%d",c);
}

29.
main()
{
int _ = 5;
int __ = 10;
int ___;
___ = _ + __;
printf("%i", ___);
}

30.
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

31.
main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}

32.
main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}

33.
enum colors {BLACK,BLUE=4,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
}

34.
main()
{
clrscr();
}
clrscr();

A. Error
B. No output
C. No error
D. both B and C

35.
#define int char
main()
{
int i=65;
printf("sizeof i=%d",sizeof(i));
}

36.
main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
}

i=-1, -i=-(-1)=1

37.
main()
{
int i;
i=2;
pskills:
printf("%d",i);
i=i+2;
if(i<=20)
goto pskills;
}

2,4,6,8,.....20

38.
#include <stdio.h>
extern int a=10;
main()
{
int a=5;
printf("\n a=%d",a);
disp();
}
disp()
{
printf("\n a=%d",a);
}

39.
main()
{
printf("%d\t%d\t%d\t",50,100);
}
40.
main()
{
char s1[]="Cisco";
char s2[]= "systems";
printf("%s",s1);
}

41.
int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1); 14
}
void main()
{
int x=10;
x++;
changevalue(x); 11
x++; 12
modifyvalue();
printf("First output:%d\n",x); 12
x++; 13
changevalue(x); 13
printf("Second output:%d\n",x); 13
modifyvalue();
printf("Third output:%d\n",x); 13
}

42.
#include "stdio.h" valid
void fun(int _)
{
printf("%d",_);
}
main()
{
fun(23);
}

43.
what is the output of following program?

void main()
{
printf("%d%d",47%5,47%-5); 2,2
printf("%d%d%d",-47%5,-47%-5,5%7); -2,-2,5
}
44.
main(){
auto a;
register r;
static s;
extern e;
printf("%d",sizeof a);
printf("%d",sizeof r);
printf("%d",sizeof s);
printf("%d",sizeof e);
}

45.
main(){
int a,b;
a=b=100;
scanf("%d",&b); //Entered Value is 85
printf("%d %d",a,b);
}

100,85

46.

#include "stdio.h"
main(){
int a=1;
while(a++<=1)
while(a++<=2);
printf("%d",a);
}

You might also like