ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
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?
 Question Submitted By :: Avula_sujatha@yahoo.co.in
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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?
Answer
# 1
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 ?    0 Yes 1 No
Vignesh1988i
 
  Re: 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?
Answer
# 2
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 ?    0 Yes 0 No
Abdur Rab
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Write one statement equalent to the following two statements x=sqr(a); return(x); Choose from one of the alternatives a.return(sqr(a)); b.printf("sqr(a)"); c.return(a*a*a); d.printf("%d",sqr(a)); TCS4
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.  1
pgm to find middle element of linklist(in efficent manner) Huawei1
Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press 'g' it shows the answer 7.. any can help me  2
What ios diff. Between %e & %f? Honeywell1
how to print "hai" in c?  9
How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?  1
what is a far pointer TCS8
code snippet for creating a pyramids triangle ex 1 2 2 3 3 3  2
AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST? HCL9
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; } Honeywell2
How can I invoke another program from within a C program?  1
proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output? Hughes5
plz answer..... a program that reads non-negative integer and computes and prints its factorial  1
x=2,y=6,z=6 x=y==z; printf(%d",x) HCL7
What is the difference between big endian form and little endian form? write a code to convert big endian form to little endian and vice versa.. Aricent1
What are the different pointer models in c?  3
Average of a couple 10 years ago was 25. The average remains same after having a child and twins after 3 years. What is the present age of the first child IBM9
What will be the output of x++ + ++x? MBT10
how many error occurs in C language ? Wipro9
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com