15.what is the disadvantage of using macros?
16.what is the self-referential structure?
17.can a union be self-referenced?
18.What is a pointer?
19.What is the Lvalue and Rvalue?
20.what is the difference between these initializations?
21.Char a[]=”string”;
22.Char *p=”literal”;
23.Does *p++ increment p, or what it points to?

Answers were Sorted based on User's Feedback



15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a u..

Answer / abdur rab

The difference between
21...in char a[]="string";
22... in char *p="literal";

is

in char a[]="string";, the memory is allocated, so the
value can be changed, it can be incremented, etc.

where as in char *p="literal";, you can just read it, may
be you can increment the pointer to point to the next
location, the content cannot be changed since this is a
string literal or BSS (Block Started by Symbol). This is
often called "const_data" or "data_const", or "literal".

23. *p++ it gets the content, and then increments the
pointer to the next location.

eg:

char a[] = {"string"};
char x;
char* p = (char*) a;

x = *p++;

printf ( "%c\n, %s\n", x, p );

output
======
s
tring

Is This Answer Correct ?    2 Yes 0 No

15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a u..

Answer / vignesh1988i

15)
the disadvantage is... th macros will blindly substitute the
values which we have defined......
#define sr(s) s+s
main()
{
....
...
int c;
c=sr(10)/5;
}
can u guess what will be the output..... 12... but i want
4.... the macros wil get substitute like this before
compailation
c=s+s/5;
since '/' symbol gets the first prirority... thatr wil
happen first.... but we dont wann this.... so this is an
idiotic mode of substitution............. this is its dis
advantages.......

16...
this structure pointer which points to the same structure
whrer its declared is called self referencial structure

18...
pointer are secondary constants and are derived data types
whic can hold only the address of particular data type .. as
same as the pointer is declared..
int *p;
thid m eans that it can hold hold only the address of an
integer and points to that memory location.........

19...
Lvalue is called left assignment value..... Rvalue right
assignment value;;;
if you give: x+y=m; in C statement ... it will
show these types of errors

21...in char a[]="string";
hrer we are initilizing the array of characters to an
array called a..... and implicitely it will add '\0' at last...

22... in char *p="literal";
here p is an character pointer which can hold the
address of an character type of values....
hrer p hold the address of 'l'... this is called as base
address of the array..... when we maniplate the p value (ie)
when we do pointer arithmetic we can print and those the
full string...

23...
*p++
here * has the first precedence compared to ++ operator
therefore.. the pointer p , where it is pointing at present
that value will be incremented.......
for eg:
char q[]="sorry";
char *p;
p=&q[0];
*p++;
printf("%c",p);
now the pointer points to the very first
character of q[].. when we give *p++, *p will be 's' then
while getting incremented it will increment the ascii value
.... so the OUTPUT will be 't'...........

thank you

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More C Interview Questions

Why we use break in c?

0 Answers  


What is static memory allocation? Explain

0 Answers  


C program to find frequency of each character in a text file?

6 Answers  


can please someone teach me how to create this program using while statement.. this is the output should look like 0 2 4 6 8 10 -thanks.. :) need it asap...

7 Answers  


What is infinite loop?

0 Answers  






What does s c mean in text?

0 Answers  


void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }

3 Answers  


6)What would be the output? main() { int u=1,v=3; pf("%d%d",u,v); funct1(&u,&v); pf("%d%d\n",u,v); } void funct1(int *pu, int *pv) { *pu=0; *pv=0; return; } a)1 3 1 3 b)1 3 1 1 c)1 3 0 0 d)1 1 1 1 e) 3 1 3 1

4 Answers  


Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  


What is array in C

0 Answers  


wat are the two methods for swapping two numbers without using temp variable??

2 Answers  


for example user gives input as " 20 or 20.0 or rs 20.0 or 20.00 or rs20 and so .. on " and the output should be stored as " rs.20.00 " in a variable

2 Answers  


Categories