C Interview Questions 41-50

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

41-50 Questions

Q1:

#include <stdio.h>
#define a 10
main()
{
    #define a 50
    printf("%d",a);
}
Answer:
50

Q2:

#define clrscr() 100
main()
{
    clrscr();
    printf("%d\n",clrscr());
}
Answer:
100

Q3:

main()
{
    clrscr();
}
clrscr();
Answer:
No output/error

Q4:

main()
{
    int i=1;
    while (i<=5)
    {
        printf("%d",i);
        if (i>2)
            goto here;
        i++;
    }
}
fun()
{
    here:
    printf("PP");
}
Answer:
Compiler error: Undefined label 'here' in function main

Q5:

#define f(g,g2) g##g2
main()
{
    int var12=100;
    printf("%d",f(var,12));
}
Answer:
100

Q6:

main()
{
    extern out;
    printf("%d", out);
}
int out=100;
Answer:
100

Q7:

main()
{
    show();
}
void show()
{
    printf("I'm the greatest");
}
Answer:
Compier error: Type mismatch in redeclaration of show.

Q8:

int i,j;
for(i=0;i<=10;i++)
{
    j+=5;
    assert(i<5);
}
Answer:
Runtime error: Abnormal program termination.
assert failed (i<5), <file name>,<line number>

Q9:

#define FALSE -1
#define TRUE 1
#define NULL 0
main() {
    if(NULL)
        puts("NULL");
    else if(FALSE)
        puts("TRUE");
    else
        puts("FALSE");
}
Answer:
TRUE

Q10:

#define max 5
#define int arr1[max]
main()
{
    typedef char arr2[max];
    arr1 list={0,1,2,3,4};
    arr2 name="name";
    printf("%d %s",list[0],name);
}
Answer:
Compiler error (in the line arr1 list = {0,1,2,3,4})