1.What will be yield of emulating c code?
#include<stdio.h>
int main(){
printf(“%dt”,sizeof(6.5));
printf(“%dt”,sizeof(90000));
printf(“%d”,sizeof(‘a’));
return 0;
}
Pick all that apply:
(A) 4 2 1
(B) 8 2 1
(C) 4 4 1
(D) 8 4 1
(E) 8 4 2
Clarification:
Turbo C++ 3.0: 8 4 2
Turbo C ++4.5: 8 4 2
Linux GCC: 8 4
Visual C++: 8 4
Of course information kind of numeric constants is:
6.5 : double
90000: long int
‘A’: char
In C size of information sort fluctuates from compiler to compiler.
In TURBO C 3.0 (16 bit compilers) size of:
twofold is 8 byte
Long int is 4 byte
Character consistent is 2 byte (size of singe information sort is one byte)
In TURBO C 4.5 or Linux GCC compilers (32 bit compilers) size of:
double is 8 byte
long int is 8 byte
Character consistent is 2 byte
2.What is difference between proclaiming a variable and characterizing avariable?
Announcing a variable means portraying its writes to the compiler however not designating any space for it. Characterizing a variable means announcing it furthermore designating space to hold the variable .
3.What is a lvalue?
A lvalue is a representation to which a worth can be appointed the lvalue outflow is spotted on the left half of a task explanation. though a rvalue is spotted on the right half of a task explanation.
4.Separate between an interior static and outer static variable?
An interior static variable is proclaimed inside a piece with static stockpiling class thoughan outside static variable is announced outside all the square in a record. An inward static variable has relentless capacity, piece extension and no linkage. An outer static variable has changeless capacity, document scope and inside linkage.
5.What is a void pointer?
A void pointer is a C tradition for a crude location. The compiler has no clue what kind of a void pointer truly indicates. Case in the event that you compose..
int *p;
p focuses to an int. on the off chance that you compose
void *p;
p doesn’t indicate a void
A void pointer is utilized for working with crude memory or for passing a pointer to an unspecified sort.
6.At the point when ought to a type cast not be utilized?
A type cast ought not be utilized to override a consistent or unpredictable statement.overriding these sort modifiers can result in the project to neglect to run effectively.
7.At the point when is switch proclamation better than numerous if articulations?
A switch proclamation is for the most part best to utilize when you have more than two contingent interpretations focused around a solitary variable of numeric sort.
8.What are the distinction in the middle of malloc() and calloc()?
Malloc() takes a solitary argument(memory needed in bytes), while calloc() needs 2 contentions (number of variables to assign memory, measure in bytes of a solitary variable).
Furthermore, malloc() does not instate the memory assigned, while calloc() introduce the allotted memory to ZERO.
9.What is a register variable?
Register variables are put away in the CPU registers. Its default worth is a trash esteem.Extent of a register variable is neighborhood to the piece in which it is characterized. Lifetime is till control stays inside the piece in which the register variable is characterized. Variable put away in a CPU register can simply be gotten to quicker than the particular case that is put away in memory. Thusly, if a variable is utilized atnumerous places within a project, it is better to announce its capacity.