Professional Documents
Culture Documents
(a)cache memory
(b)secondary memory
(c)main memory
(d)none
Ans:A
2. void main()
printf("%d",++(*p));
3.
main()
printf("%d ",var--);
if(var)
main();
4.
main()
printf("\nab");
printf("\bsi");
printf("\rha");
(a) has
(b) hasaiaab
(c) hai
(d) aas
Ans :c
5.
#include
#define a 10
main()
#define a 50
printf("%d",a);
(a) 10
(b) 50
(c) error
(d) none
Ans:B
7. What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?
(a) Reverse Polish notations
(b) Polish
(c) both
(d) none
Ans :C
9. Of the following tree structure, which is, efficient considering space and time complexities?
(a) Incomplete Binary Tree
(b) Complete Binary Tree
(c) Full Binary Tree
(d) None
Ans:B
12. What is the use of the DROP option in the ALTER TABLE command?
(a) It is used to drop constraints specified on the row
(b) It is used to drop constraints specified on the table.
(c) It is used to drop constraints specified on the column
(d) all
Ans :B
13. Which is the parameter that is added to every non-static member function when it is called?
(a)‘this’ pointer
(b) ‘far’ pointer
(c)‘near’ pointer
(d) all
Ans:A
14. A collection of programs that enables user to create and maintain a database is called
(a) DBMS
(b) DB
(c) DBA
(d) All
Ans:A
16. When one of the data elements stored within a construct is utilized as the primary key, then it is called
(a) Foreign key
(b) Natural key
(c) Primary key
(d) Alternate key
Ans:B
18.
void main()
{
int i=7;
printf("%d",i++*i++);
}
main()
int i=0;
for(i=0;i<20;i++)
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
(a) 0,5,9,13,17
(b) 5,9,13,17
(c) 12,17,22
(d) 16,21
Ans:D
20. Find the output
main()
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
(a) 1 5 20
(b) 20 5 1
(c) 5 20 1
(d) 1 5 10
Ans:C
2. What is a pointer?
Ans: Pointers are variables which stores the address of another variable. That variable may be a scalar
(including another pointer), or an aggregate (array or structure). The pointed-to object may be part of a
larger object, such as a field of a structure or an element in an array.
4. What is a structure?
Ans: Structure constitutes a super data type which represents several different data types in a single unit.
A structure can be initialized if it is static or global.
5. What is a union?
Ans: Union is a collection of heterogeneous data type but it uses efficient memory utilization technique by
allocating enough memory to hold the largest member. Here a single area of memory contains values of
different types at different time. A union can never be initialized.
10. What are macros? What are its advantages and disadvantages?
Ans: Macros are abbreviations for lengthy and frequently used statements. When a macro is called the
entire code is substituted by a single line though the macro definition is of several lines.
The advantage of macro is that it reduces the time taken for control transfer as in case of
function.
The disadvantage of it is here the entire code is substituted so the program becomes
lengthy if a macro is called several times.
14. Where does global, static, and local, register variables, free memory and C Program instructions get
stored?
Ans: Global: Wherever the linker puts them. Typically the “BSS segment” on many platforms.
Static: Again, wherever the linker puts them. Often, they’re intermixed with the globals. The only
difference between globals and statics is whether the linker will resolve the symbols across compilation
units.Local: Typically on the stack, unless thevariable gets register allocated and never spills.Register:
Nowadays, these are equivalent to “Local” variables. They live on the stack unless they get register-
allocated.
15. Difference between arrays and linked list?
Ans: An array is a repeated pattern of variables in contiguous storage. A linked list is a set of
structures scattered through memory, held together by pointers in each element that point to the next
element. With an array, we can (on most architectures) move from one element to the next by adding a
fixed constant to the integer value of the pointer. With a linked list, there is a “next” pointer in each
structure which says what element comes next.
17. Describe about storage allocation and scope of global, extern, static, local and register variables?
Ans:
Globals have application-scope. They’re available in any compilation unit that includes an
appropriate declaration (usually brought from a header file). They’re stored wherever the linker puts them,
usually a place called the “BSS segment.”
Extern? This is essentially “global.”
Static: Stored the same place as globals, typically, but only available to the compilation unit that contains
them. If they are block-scope global, only available within that block and its subblocks.
Local: Stored on the stack, typically. Only available in that block and its subblocks.
(Although pointers to locals can be passed to functions invoked from within a scope where that local is
valid.)
Register: See tirade above on “local” vs. “register.” The only difference is that
the C compiler will not let you take the address of something you’ve declared as “register.”
18. What are register variables? What are the advantages of using register variables?
Ans: If a variable is declared with a register storage class,it is known as register variable.The
register variable is stored in the cpu register instead of main memory.Frequently used variables
are declared as register variable as it’s access time is faster.
20. Can we specify variable field width in a scanf() format string? If possible how?
Ans: All field widths are variable with scanf(). You can specify a maximum field width for a given
field by placing an integer value between the ‘%’ and the field type specifier. (e.g. %64s). Such a specifier
will still accept a narrower field width.
The one exception is %#c (where # is an integer). This reads EXACTLY # characters, and it is the
only way to specify a fixed field width with scanf().
21. Out of fgets() and gets() which function is safe to use and why?
Ans: fgets() is safer than gets(), because we can specify a maximum input length. Neither one is
completely safe, because the compiler can’t prove that programmer won’t overflow the buffer he pass to
fgets ().
25. What is storage class? What are the different storage classes in C?
Ans: Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope
and linkage. The storage classes in c are auto, register, and extern, static, typedef.