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

4/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 * 3;
    printf("%c\t%c", *p, s[1]);
}

Select an option to see the answer and solution.

Which of the following operation is possible using a pointer char? (Assuming the declaration is char *a;)

Select an option to see the answer and solution.

Comment on the following C statement.
int (*a)[7];

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 *p = (int *)2;
    int *q = (int *)3;
    printf("%d", p + q);
}

Select an option to see the answer and solution.

Which of the following statements are true?
P. Pointer to Array
Q. Multi-dimensional array

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("%c\t%c", p[0], s[1]);
}

Select an option to see the answer and solution.

What will be the output of the following C code (run without any command line arguments)?
#include <stdio.h>
int main(int argc, char *argv[])
{
    while (argc--)
    printf("%s\n", argv[argc]);
    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()
{
    int a[4] = {1, 2, 3, 4};
    int *p = &a[1];
    int *ptr = &a[2];
    ptr = ptr * 1;
    printf("%d\n", *ptr);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void f(char *k)
{
    k++;
    k[2] = 'm';
}
void main()
{
    char s[] = "hello";
    f(s);
    printf("%c\n", *s);
}

Select an option to see the answer and solution.

Which of the following is not possible statically in C?

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 = 10;
    void *p = &i;
    printf("%d\n", (int)*p);
    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 *a[10] = {"hi", "hello", "how"};
    int i = 0;
    for (i = 0;i < 10; i++)
    printf("%s", *(a[i]));
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void foo( int[] );
int main()
{
    int ary[4] = {1, 2, 3, 4};
    foo(ary);
    printf("%d ", ary[0]);
}
void foo(int p[4])
{
    int i = 10;
    p = &i;
    printf("%d ", p[0]);
}

Select an option to see the answer and solution.

How to call a function without using the function name to send parameters?

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[3] = {1, 2, 3};
    int *p = a;
    printf("%p\t%p", p, a);
}

Select an option to see the answer and solution.

Comment on an array of the void data type.

Select an option to see the answer and solution.

What is the syntax for constant pointer to address (i.e., fixed pointer address)?

Select an option to see the answer and solution.

What will be the output of the following C code (run without any command line arguments)?
#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.

What will be the output of the following C code?
#include <stdio.h>
void m(int *p)
{
    int i = 0;
    for(i = 0;i < 5; i++)
    printf("%d\t", p[i]);
}
void main()
{
    int a[5] = {6, 5, 3};
    m(&a);
}

Select an option to see the answer and solution.