C Skills
C Skills
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);
}
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);
}