Q101
Open question#include <stdio.h>
int main()
{
char *str = "hello, world\n";
str[5] = '.';
printf("%s\n", str);
return 0;
}Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
253
Questions
6/13
Page
Pick an option on a question to see the right answer and solution.
Q101
Open question#include <stdio.h>
int main()
{
char *str = "hello, world\n";
str[5] = '.';
printf("%s\n", str);
return 0;
}Select an option to see the answer and solution.
Q102
Open questionint* ((*x)())[2];Select an option to see the answer and solution.
Q103
Open question#include <stdio.h>
void main()
{
int a[2][3] = {1, 2, 3, , 4, 5};
int i = 0, j = 0;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
printf("%d", a[i][j]);
}Select an option to see the answer and solution.
Q104
Open question#include <stdio.h>
int main(int argc, char *argv[])
{
while (*argv++ != NULL)
printf("%s\n", *argv);
return 0;
}Select an option to see the answer and solution.
Q105
Open question#include <stdio.h>
void main()
{
char s[] = "hello";
s++;
printf("%c\n", *s);
}Select an option to see the answer and solution.
Q106
Open question#include <stdio.h>
int main()
{
int i = 11;
int *p = &i;
foo(&p);
printf("%d ", *p);
}
void foo(int *const *p)
{
int j = 10;
*p = &j;
printf("%d ", **p);
}Select an option to see the answer and solution.
Q107
Open question#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **p);
}Select an option to see the answer and solution.
Q108
Open question#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}Select an option to see the answer and solution.
Q109
Open question#include <stdio.h>
int main()
{
char *str = "hello, world\n";
char *strc = "good morning\n";
strcpy(strc, str);
printf("%s\n", strc);
return 0;
}Select an option to see the answer and solution.
Q110
Open question#include <stdio.h>
void main()
{
char *s = "hello";
char *p = s;
printf("%c\t%c", *p, s[1]);
}Select an option to see the answer and solution.
Q111
Open question#include <stdio.h>
int main()
{
char **p = {"hello", "hi", "bye"};
printf("%s", (p)[0]);
return 0;
}Select an option to see the answer and solution.
Q112
Open question#include <stdio.h>
struct student
{
int no;
char name[20];
};
struct student s;
void main()
{
s.no = 8;
printf("%s", s.name);
}Select an option to see the answer and solution.
Q113
Open question#include <stdio.h>
int main()
{
int i = 0, j = 1;
int *a[] = {&i, &j};
printf("%d", (*a)[0]);
return 0;
}Select an option to see the answer and solution.
Q114
Open question#include <stdio.h>
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}Select an option to see the answer and solution.
Q115
Open question#include <stdio.h>
void (*(f)())(int, float);
void (*(*x)())(int, float) = f;
void ((*y)(int, float));
void foo(int i, float f);
int main()
{
y = x();
y(1, 2);
}
void (*(f)())(int, float)
{
return foo;
}
void foo(int i, float f)
{
printf("%d %f\n", i, f);
}Select an option to see the answer and solution.
Q116
Open question#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}Select an option to see the answer and solution.
Q117
Open question#include <stdio.h>
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf("%d\n", *p);
}Select an option to see the answer and solution.
Q118
Open questionSelect an option to see the answer and solution.
Q119
Open question#include <stdio.h>
int main()
{
int ary[4] = {1, 2, 3, 4};
printf("%d\n", *ary);
}Select an option to see the answer and solution.
Q120
Open question#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
int **sptr = &ptr1; //-Ref
*sptr = ptr2;
}Select an option to see the answer and solution.