Exercise: Typedef

Questions for: Typedef

In the following code snippet can we declare a new typedef named ptr even though struct employee has not been completely declared while using typedef?
typedef struct employee *ptr;
struct employee
{
    char name[20];
    int age;
    ptr next;
}
A:
Yes
B:
No
C:
D:
Answer: A
No answer description is available. Let's discuss.
What will be the output of the program?
#include<stdio.h>

typedef struct error {int warning, err, exception;} ERROR;
int main()
{
    ERROR e;
    e.err=1;
    printf("%d\n", e.err);
    return 0;
}
A:
0
B:
1
C:
2
D:
Error
Answer: B
No answer description is available. Let's discuss.
What will be the output of the program?
#include<stdio.h>

int main()
{
    typedef float f;
    static f *fptr;
    float fval = 90;
    fptr = &fval;
    printf("%f\n", *fptr);
    return 0;
}
A:
9
B:
0
C:
90.000000
D:
90
Answer: C
No answer description is available. Let's discuss.
What will be the output of the program?
#include<stdio.h>

int main()
{
    typedef int LONG;
    LONG a=4;
    LONG b=68;
    float c=0;
    c=b;
    b+=a;
    printf("%d,", b);
    printf("%f\n", c);
    return 0;
}
A:
72, 68.000000
B:
72.000000, 68
C:
68.000000, 72.000000
D:
68, 72.000000
Answer: A
No answer description is available. Let's discuss.
What will be the output of the program?
#include<stdio.h>

int main()
{
    typedef int arr[5];
    arr iarr = {1, 2, 3, 4, 5};
    int i;
    for(i=0; i<4; i++)
        printf("%d,", iarr[i]);
    return 0;
}
A:
1, 2, 3, 4
B:
1, 2, 3, 4, 5
C:
No output
D:
Error: Cannot use typedef with an array
Answer: A
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz