C Interview Questions 81-90

This post contains 81-90 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.

81-90 Questions

Q1:

main()
{
    static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
    int i;
    char *t;
    t=names[3];
    names[3]=names[4];
    names[4]=t;
    for (i=0;i<=4;i++)
        printf("%s",names[i]);
}
Answer:
Compiler error: Lvalue required in function main

Q2:

#include
main()
{
    char s[]={'a','b','c','\n','c','\0'};
    char *p,*str,*str1;
    p=&s[3];
    str=p;
    str1=s;
    printf("%d",++*p + ++*str1-32);
}
Answer:
M

Q3:

main( )
{
    int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
    printf("%u %u %u %d \n",a,*a,**a,***a);
    printf("%u %u %u %d \n",a+1,*a+1,**a+1,***a+1);
}
Answer:
100, 100, 100, 2
114, 104, 102, 3

Q4:

main( )
{
    int a[ ] = {10,20,30,40,50},j,*p;
    for(j=0; j<5; j++)
    {
        printf("%d" ,*a);
        a++;
    }
    p = a;
    for(j=0; j<5; j++)
    {
        printf("%d " ,*p);
        p++;
    }
}
Answer:
Compiler error: lvalue required.

Q5:

main( )
{
    static int a[ ] = {0,1,2,3,4};
    int *p[ ] = {a,a+1,a+2,a+3,a+4};
    int **ptr = p;
    ptr++;
    printf("\n %d %d %d", ptr-p, *ptr-a, **ptr);
    *ptr++;
    printf("\n %d %d %d", ptr-p, *ptr-a, **ptr);
    *++ptr;
    printf("\n %d %d %d", ptr-p, *ptr-a, **ptr);
    ++*ptr;
    printf("\n %d %d %d", ptr-p, *ptr-a, **ptr);
}
Answer:
111
222
333
344    

Q6:

pointers are of 
a) integer data type 
b) character data type 
c) unsigned integer data type 
d) none of these
Answer:

Q7:

main( )
{
    void *vp;
    char ch = 'g', *cp = "goofy";
    int j = 20;
    vp = &ch;
    printf("%c", *(char *)vp);
    vp = &j;
    printf("%d",*(int *)vp);
    vp = cp;
    printf("%s",(char *)vp + 3);
}
Answer:
g20fy

Q8:

main ( )
{
    static char *s[ ] = {"black", "white", "yellow", "violet"};
    char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
    p = ptr;
    **++p;
    printf("%s",*--*++p + 3);
}
Answer:
ck

Q9:

main()
{
    int i, n;
    char *x = "girl";
    n = strlen(x);
    *x = x[n];
    for(i=0; i<n; ++i)
    {
        printf("%s\n",x);
        x++;
    }
}
Answer:
(blank space)
irl
rl
l

Q10:

main()
{
    char *cptr,c;
    void *vptr,v;
    c=10; v=0;
    cptr=&c; vptr=&v;
    printf("%c%v",c,v);
}
Answer:
Compiler error (at line number 4): size of v is Unknown.