Typedef in C Programming
Typedef in C Programming
Answer : (D)
Solution :
(;) this is a termination operator in C language. printf/scanf both are the functions. +,-,*,/,%) are the arithmetic
Operators. These all may create problem in a typedef. Because Each has its own task. And typedef is used
to defined the user defined data type . That datatype will create using built-in and Derived datatype.
Answer : (B)
Solution :
User define Data type Alias works same as user define data type, and unlike array it is valid to assignone
instance of structure to other structure.
Answer : (B)
Solution :
(Eg: typedef char a; typedef int a;)
4 typedef declaration
(A) Does not create a new type
(B) It merely adds a new name for some existing type.
(C) Both a & b
1/6 http://www.comprider.in
(D) None of the mentioned
Answer : (C)
Solution :
a keyword called typedef, which you can use to give a type a new name and You can use typedef to give
aname to user defined data type as well. For example you can use typedef with structure to define a new
data type and then use that data type to define structure variables directly
Answer : (A)
Solution :
In function 'x': warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default]
int (*ary)[2] = malloc(sizeof*ary);
return from incompatible pointer type [enabled by default]
return &ary;
warning: function returns address of local variable [-Wreturn-local-addr]
Answer : (A)
Solution :
Each pointer store the address of another variable. When it return the value of integer is Will be returned.
2/6 http://www.comprider.in
(D) Such expression cannot be generated in C
Answer : (B)
Solution :
In option 1st size of array is unknown,so correct answer is option b.
Answer : (A)
Solution :
struct stu s;
This is invalid statement because above code create alias of structure stu. It is invalid to write struct keyword
with alias.
Answer : (B)
Solution :
In above code cant give alias name so p k1 = {1, 2};this statement will give error at compile time.
3/6 http://www.comprider.in
10 The correct syntax to use typedef for struct is.
a) typedef struct temp
{
int a;
}TEMP;
b) typedef struct
{
int a;
}TEMP;
c) struct temp
{
int a;
};
typedef struct temp TEMP;
d) All of the mentioned
(A) a
(B) b
(C) c
(D) d
Answer : (D)
4/6 http://www.comprider.in
Solution :
The C programming language provides a keyword called typedef, which you can use to give a type a new
name. Following is an example to define a term BYTE for one-byte numbers:
BYTE b1, b2;
By convention, uppercase letters are used for these definitions to remind the user that the type name is really
a symbolic abbreviation, but you can use lowercase, as follows:
typedef unsigned char byte;
You can use typedef to give a name to user defined data type as well. For example you can use typedef with
structure to define a new data type and then use that data type to define structure variables directly as
follows:
#include <stdio.h>
#include <string.h>
int main( )
{
Book book;
Answer : (D)
5/6 http://www.comprider.in
Solution :
char *a
is a pointer variable it will easily store the string So hey will be output of this program.
Answer : (B)
Solution :
typedef char *string;
This expression declare alias of string pointer in option a .and b again declare pointer of string this invalid
declaration because of we cant create pointer of alias.
Answer : (D)
Solution :
Data type Alias works same as real data type.
6/6 http://www.comprider.in