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

9/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 (if run with no options or arguments)?
#include <stdio.h>
int main(int argc, char *argv[])
{
    printf("%d\n", argc);
    return 0;
}

Select an option to see the answer and solution.

Comment on the following C statement.
const int *ptr;

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char a[10][5] = {"hi", "hello", "fellows"};
    printf("%p\n", a);
    printf("%p", a[0]);
}

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[1]));
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void f(int a[2][])
{
    a[0][1] = 3;
    int i = 0, j = 0;
    for (i = 0;i < 2; i++)
    for (j = 0;j < 3; j++)
    printf("%d", a[i][j]);
}
void main()
{
    int a[2][3] = {0};
    f(a);
}

Select an option to see the answer and solution.

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

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[4] = {1, 2, 3, 4};
    int *p = ary + 3;
    printf("%d\n", p[-2]);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int x = 0;
void main()
{
    int *ptr = &x;
    printf("%p\n", ptr);
    x++;
    printf("%p\n ", ptr);
}

Select an option to see the answer and solution.

Which of the following is not possible in C?

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 = 5;
    char name[20];
};
void main()
{
    struct student s;
    s.no = 8;
    printf("hello");
}

Select an option to see the answer and solution.

Which of the following can never be sent by call-by-value?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void first()
{
    printf("Hello World");
}
void main()
{
    void *ptr() = first;
    ptr++
    ptr();
}

Select an option to see the answer and solution.

An array of strings can be initialized by . . . . . . . .

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[1][5] = {"hello"};
    printf("%s", a[0]);
    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()
{
    char *s = "hello";
    char *p = s;
    printf("%p\t%p", p, s);
}

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 strary[] = "hello world";
    printf("%d %d\n", strlen(str), strlen(strary));
    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!!\n";
    char strc[] = "good morning\n";
    strcpy(strc, str);
    printf("%s\n", strc);
    return 0;
}

Select an option to see the answer and solution.

A program that has no command line arguments will have argc . . . . . . . .

Select an option to see the answer and solution.

What is argv[0] in command line arguments?

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, 4};
    p = &a[3];
    int *ptr = &a[2];
    int n = (int*)p - ptr;
    printf("%d\n", n);
}

Select an option to see the answer and solution.