Vidyalelo
C Programming · all questions

Pointer
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

253

Questions

10/13

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char *s= "hello";
    char *p = s;
    printf("%c\t%c", 1[p], s[1]);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
struct student
{
    int no;
    char name[20];
}
void main()
{
    struct student s;
    s.no = 8;
    printf("hello");
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#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.

What is the advantage of a multidimensional array over pointer array?

Select an option to see the answer and solution.

What will be the output of the following C statement? (assuming the input is "cool brother in city")
printf(“%s\n”, argv[argc]);

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char a[2][6] = {"hello", "hi"};
    printf("%s", *a + 1);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *str = "hello world";
    char strc[] = "good morning india\n";
    strcpy(strc, str);
    printf("%s\n", strc);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void m(int p)
{
    printf("%d\n", p);
}
void main()
{
    int a = 6, b = 5;
    m(a, b);
    printf("%d %d\n", a, b);
}

Select an option to see the answer and solution.

What will be the output of the following C code on a 32-bit system?
#include <stdio.h>
void main()
{
    char *a[10] = {"hi", "hello", "how"};
    printf("%d\n", sizeof(a));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int sub(int a, int b, int c)
{
    return a - b - c;
}
void main()
{
    int (*function_pointer)(int, int, int);
    function_pointer = ⊂
    printf("The difference of three numbers is:%d",
    (*function_pointer)(2, 3, 4));
}

Select an option to see the answer and solution.

Which of the following declaration will result in run-time error?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *a[2] = {"hello", "hi"};
    printf("%s", *(a + 1));
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int k = 5;
    int *p = &k;
    int **m  = &p;
    **m = 6;
    printf("%d\n", k);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *p = NULL;
    char *q = 0;
    if (p)
        printf(" p ");
    else
        printf("nullp");
    if (q)
        printf("q\n");
    else
        printf(" nullq\n");
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 97, *p = &i;
    foo(&i);
    printf("%d ", *p);
}
void foo(int *p)
{
    int j = 2;
    p = &j;
    printf("%d ", *p);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int ary[2][3][4], j = 20;
    ary[0][0] = &j;
    printf("%d\n", *ary[0][0]);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void m(int *p, int *q)
{
    int temp = *p; *p = *q; *q = temp;
}
void main()
{
    int a = 6, b = 5;
    m(&a, &b);
    printf("%d %d\n", a, b);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 97, *p = &i;
    foo(&p);
    printf("%d ", *p);
    return 0;
}
void foo(int **p)
{
    int j = 2;
    *p = &j;
    printf("%d ", **p);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    void *p;
    int a[4] = {1, 2, 3, 8};
    p = &a[3];
    int *ptr = &a[2];
    int n = p - ptr;
    printf("%d\n", n);
}

Select an option to see the answer and solution.

Arguments that take input by user before running a program are called?

Select an option to see the answer and solution.