Discover the depth  of  C

  C C++  Linux ProgrammingNEW   Operating Systems  Data StructuresNEW  Compilers  Contact Us

Navigation

?? Interview Questions ??New

Join C4Swimmers

 sitepromotion.gif (577 bytes) New Member

Weekly Queries New

 Queries for this week

 All Weekly Queries

Code Zone - Free

Newbie Level

Intermediate Level

Tools Zone

C/C++ Tools

Test Your C/C++ Skills

  Playing with printf

  Playing with scanf

  Branching & Loops

  Pointers Part I

  Pointers Part II

  Structure & Union

C Special

  Discovering C
  IFAQs

  Self-reproducing C Code

  C/C++ Links
  C/C++ Books NEW

Programming Problems

  Part I
  Part II
Downloads
C4S - Solution Pack
Data Structures
C++ & 8086 ALP
ADA & System S/w
Online Certifications
premiumservices.gif (1070 bytes) Brainbench
premiumservices.gif (1070 bytes) Benchmarks Global
Help and Support
customer_care_small.gif (1018 bytes)  Suggestions
post-question_icon.gif (1062 bytes)  Contribute
premiumservices.gif (1070 bytes)  Advertise with us
memberhome.gif (1052 bytes)  -Home Page-

premiumservices.gif (1070 bytes) Feedback

As a webmaster of this site, I regard you as our most important critic and commentator. We value your opinion and want to know what we are doing right, what we could do better and any other words of wisdom you're willing to pass our way. It would be our greatest motivation which will help us in developing areas you would like to see in this site. We hope you will continue to encourage and support us in our future endeavors.

 
.  

C For Swimmers : Mastering C step-by-step

Google


WWW c4swimmers.esmartguy.com
NOTE : It is assumed that -

Necessary header files are included
Programs/Snippets are tested under Linux as well as Windows platform
Programs/Snippets are compiled using VC++ 6.0 as well as gcc 3.2
The underlying machine is an x86 system

Pointers - Part II

 [Q001] What will be the output of the following program :
 int main()
 {
    int val=1234;
    int* ptr=&val;
    printf("%d %d",++val,*ptr);
   return(0);
 }
 (a)1234 1234
 (b)1235 1235
 (c)1234 1235
 (d)1235 1234
 [Q002] What will be the output of the following program :
 int main()
 {
    int val=1234;
    int* ptr=&val;
    printf("%d %d",val,*ptr++);
   return(0);
 }
 (a)1234 1234
 (b)1235 1235
 (c)1234 1235
 (d)1235 1234
 [Q003] What will be the output of the following program :
 int main()
 {
    int val=1234;
    int *ptr=&val;
    printf("%d %d",val,++*ptr);
   return(0);
 }
 (a)1234 1234
 (b)1235 1235
 (c)1234 1235
 (d)1235 1234
 [Q004] What will be the output of the following program :
 int main()
 {
   int val=1234;
   int *ptr=&val;
   printf("%d %d",val,(*ptr)++);
   return(0);
 }
 (a)1234 1234
 (b)1235 1235
 (c)1234 1235
 (d)1235 1234
 [Q005] What will be the output of the following program :
 int main()
 {
   int val=1234;
   int *ptr=&val;
   printf("%d %d",++val,(*(int *)ptr)--);
   return(0);
 }
 (a)1234 1233
 (b)1235 1234
 (c)1234 1234
 (d)None of these
 [Q006] What will be the output of the following program :
 int main()
 {
   int a=555,*ptr=&a,b=*ptr;
   printf("%d %d %d",++a,--b,*ptr++);
   return(0);
 }
 (a)Compile-Time Error
 (b)555 554 555
 (c)556 554 555
 (d)557 554 555
 [Q007] What will be the output of the following program :
 int main()
 {
   int a=555,b=*ptr,*ptr=&a;
   printf("%d %d %d",++a,--b,*ptr++);
   return(0);
 }
 (a)Compile-Time Error
 (b)555 554 555
 (c)556 554 555
 (d)557 554 555
 [Q008] What will be the output of the following program :
 int main()
 {
   int a=555,*ptr=&a,b=*ptr;
   printf("%d %d %d",a,--*&b,*ptr++);
   return(0);
 }
 (a)Compile-Time Error
 (b)555 554 555
 (c)556 554 555
 (d)557 554 555
 [Q009] What will be the output of the following program :
 int main()
 {
   int a=555,*ptr=&a,b=*ptr=777;
   printf("%d %d",--*&b,*(int *)&b);
   return(0);
 }
 (a)Compile-Time Error
 (b)776 777
 (c)554 555
 (d)None of these
 [Q010] What will be the output of the following program :
 int main()
 {
   int a=5u,*b,**c,***d,****e;
   b=&a;
   c=&b;
   d=&c;
   e=&d;
   printf("%u %u %u %u",*b-5,**c-11,***d-6,65535+****e);
   return(0);
 }
 (a)Compile-Time Error
 (b)0 65530 65535 4
 (c)0 65530 65535 65539
 (d)0 -6 -1 -2
 [Q011] What will be the output of the following program :
 int main()
 {
   float val=5.75;
   int *ptr=&val;
   printf("%.2f %.2f",*(float *)ptr,val);
   return(0);
 }
 (a)Compile-Time Error
 (b)5.75 5.75
 (c)5.00 5.75
 (d)None of these
 [Q012] What will be the output of the following program :
 int main()
 {
   int val=50;
   const int *ptr1=&val;
   int const *ptr2=ptr1;
   printf("%d %d %d",++val,*ptr1,*ptr2);
   *(int *)ptr1=98;
   printf("\n%d %d %d",++val,*ptr1,*ptr2);
   return(0);
 }
 (a)Compile-Time Error
 (b)51 50 50
     99 98 98
 (c)Run-Time Error
 (d)None of these
 [Q013] What will be the output of the following program :
 int main()
 {
   int val=77;
   const int *ptr1=&val;
   int const *ptr2=ptr1;
   printf("%d %d %d",--val,(*ptr1)++,*ptr2);
   return(0);
 }
 (a)Compile-Time Error
 (b)77 78 77
 (c)76 77 77
 (d)77 77 77
 [Q014] What will be the output of the following program :
 int main()
 {
   int a=50,b=60;
   int* const ptr1=&a;
   printf("%d %d",--a,(*ptr1)++);
   ptr1=&b;
   printf("\n%d %d",++b,(*ptr1)++);
   return(0);
 }
 (a)Compile-Time Error
 (b)49 50
     61 60
 (c)50 50
     62 60
 (d)None of these
 [Q015] What will be the output of the following program :
 int main()
 {
   int a=50;
   const int* const ptr=&a;
   printf("%d %d",*ptr++,(*ptr)++);
   return(0);
 }
 (a)Compile-Time Error
 (b)51 51
 (c)51 50
 (d)None of these
 [Q016] What will be the output of the following program :
 int main()
 {
   int val=77;
   const int const *ptr=&val;
   printf("%d",*ptr);
   return(0);
 }
 (a)Compile-Time Error
 (b)Run-Time Error
 (c)77
 (d)None of these
 [Q017] What will be the output of the following program :
 int main()
 {
   int a[]={1,2,3,4,5,6};
   int *ptr=a+2;
   printf("%d %d",--*ptr+1,1+*--ptr);
   return(0);
 }
 (a)Compile-Time Error
 (b)1 2
 (c)2 3
 (d)1 3
 [Q018] What will be the output of the following program :
 int main()
 {
   int a[]={1,2,3,4,5,6};
   int *ptr=a+2;
   printf("%d %d",*++a,--*ptr);
   return(0);
 }
 (a)Compile-Time Error
 (b)2 2
 (c)3 2
 (d)4 2
 [Q019] What will be the output of the following program :
 int main()
 {
   int matrix[2][3]={{1,2,3},{4,5,6}};
   printf("%d %d %d\n",*(*(matrix)),*(*(matrix+1)+2),*(*matrix+1));
   printf("%d %d %d",*(matrix[0]+2),*(matrix[1]+1),*(*(matrix+1)));
   return(0);
 }
 (a)Compile-Time Error
 (b)1 5 2
     6 3 4
 (c)1 6 2
     3 5 4
 (d)1 6 2
     3 4 5
 [Q020] What will be the output of the following program :
 int main()
 {
   int (*a)[5];
   printf("%d %d",sizeof(*a),sizeof(a));
   return(0);
 }
 (a)Compile-Time Error
 (b)2 5
 (c)5 2
 (d)None of these

Click here to see the Solutions for the above queries.

You are Visitor No.

Sign my Guestbook View my Guestbook

Subscribe to C4Swimmers Group
Designed and Maintained by  Nanda Kishor

Thanks for using C For Swimmers.
Regarding this material, you can send Bug Reports, Suggestions, Comments, etc. to

nandakishorkn@rediffmail.com

Note: All logos or trademarks are related to their respective owners.

Although every precaution has been taken, the designer(s) owe no responsibility for malicious errors.

No liability assumed for damages resulting from the use of the available information.