C language: will always be first choice. online Test

predict output:

struct A

{

int a;

int b;

};

struct A var;

var.a = 1;

main()

{

var.a = 2;

printf("%d",var.a);

}


predict output:

int arr[] = {1,2,3,4,5};

int *p;

int **q;

p = arr;

q = &p;

p += 2;

printf("%d %d %d ",0[*q], *(p+ p[-2]), (1[*q]-3)[p]);


/*assume 32 bit compiler*/

predict output: case1: keep commented last line

case2: remove last line comment

main()

{

char *arr[] = {"shani","from","IIITA","to","Aricent"};

char **p;

char ***q;

p = arr;

q = &p;

p = p + 4;

printf("%d %d %s\n",sizeof(arr[0]),sizeof(arr),(-2)[*q]);

//printf(" %s",&(0[*p] = 'a'));

}


int x = 2;

void fun()

{

static int x =0;

x += 10;

}

main()

{

printf("%d ",x);

fun();

printf("%d ",x);

}


void f2(int *a,int *b)

{

*a ^= *b ^= *a ^= *b;

printf("%d, %d",*a,*b);

}

void f1(int *a, void (*p)(int *a,int *b))

{

int b = 20;

p(a,&b);

}

int main()

{

int a = 10;

void (*ptr)(int *,void(*)(int *,int *)) = f1;

ptr(&a,f2);

}


/*suppose 32 bit compiler and no pragma is used*/

predict output:

struct X

{

int a:12

char b:7;

int c:12;

};

main()

{

printf("%d",sizeof(struct X));

}


what is output

enum {F,T};

main()

{

int i=1;

do

{

printf("%d\n",i);

i++;

if(i < 15)

continue;

}while(F);

}


#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))

int array[] = {23,34,12,17,204,99,16};

int main()

{

int d;

for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)

printf("%d ",array[d+1]);

return 0;

}


output:

int main(int x )

{

static int a = 10;

if(a)

main(--a);

printf("%d ",a);

return 0;

}


what will be output in different scenario:

1. both lines r kept commented

2. comment 1 is uncommented 2nd remain unchanged

3 comment 2 is uncommented while 1st is commented

4. both comment 1&2 r uncommented

let input is: shani#

int main()

{

char ch = '#';

FILE *fp1 = stdin,*fp2 = stdout;

//fclose(fp1) comment 1

//fclose(fp2) comment 2

while((ch = getc(fp1)) != '#')

{

putc(ch,fp2);

}

}









































































































































Description:

This test is just for recap of C language concepts.

Comments
Hiren Modi
By: Hiren Modi
569 days 10 hours 19 minutes ago

What is This Yaar You can write Question in Relatinal Manner

shani kumar
By: shani kumar
569 days 9 hours 18 minutes ago

full indentation was initially when I wrote it, but there is some problem in displaying.

shani kumar
By: shani kumar
569 days 9 hours 15 minutes ago

Let me inform how did you like it as well as any conflict in answer(if any).

Want to learn?

Sign up and browse through relevant courses.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
shani kumar
When I let go of what I am, I become what I might
User
4 Followers
Test: 1

Your Facebook Friends on WizIQ

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect