Discover the depth  of  C

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

Navigation

Join C4SwimmersGroup

 sitepromotion.gif (577 bytes) New Member

Test Your C/C++ Skills

  Playing with printf

  Playing with scanf

  Branching & Loops

  Functions

  Pointers Part I

  Pointers Part II

  Structure & Union

C Special

  Discovering C
  Exploring C Part I
  Exploring C Part II
  IFAQs

Programming Problems

  Part I
  Part II
 post-question_icon.gif (1062 bytes) Useful C/C++ Links
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) Feedback
premiumservices.gif (1070 bytes) Advertise with us
 

 memberhome.gif (1052 bytes) -Home Page-

 
 
.  

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

Weekly Queries : Week 1 : June 2005

 [Q001] What will be the output of the following program :
int main()
{
  int const *iptr=5;
  printf("%d",++(*iptr));
  return 0;
}
 (a)5
 (b)Compile-Time Error
 (c)6
 (d)None of these
 [Q002] What will be the output of the following program :
int main()
{
  static int val = 5;
  printf("%d ",val--);
  if (val)
     main();
  return 0;
}
 (a)5
 (b)Compile-Time Error
 (c)Run-Time Error
 (d)5 4 3 2 1
 (e)None of these
 [Q003] Identify the fault in the following program :
int main()
{
  char *s = (char *) malloc(10 * sizeof(char));
  free(s);
  free(s);
  return 0;
}
 (a)Compile-Time Error
 (b)Run-Time Error
 (c)Linker-Error
 (d)None of these
 [Q004]  Identify the fault in the following program :
void foo()
{
  char *s = (char *) malloc(10 * sizeof(char));
}

int main()
{
  foo();
  return 0;
}

 (a)No faults
 (b)Runtime-Error : Memory Corruption
 (c)Performance Bottleneck : Memory Leak
 (d)Runtime-Error : Pointer abuse
 [Q005]  Identify the fault in the following program :
int main()
{
  int val[5]={1,2,3,4,5};
  val[5] = 100;
  printf("%d",val[5]);
  return 0;
}
 (a)No faults
 (b)Run-Time Error : Boundary overflow
 (c)Performance Bottleneck : Memory Leak
 (d)Run-Time Error : Pointer abuse
 [Q006] What will be the output of the following program :
struct { int bit:1; } x;

int foo()
{
  if ( x.bit > 0 ) return !0;
  else return 0;
}

int main()
{
  x.bit = 1;
  if ( foo() ) printf( "bit status is ON" );
  else printf( "bit status is OFF" );
  return 0;
}
 (a)bit status is ON
 (b)Compile-Time Error
 (c)bit status is OFF
 (d)None of these
 [Q007] What will be the output of the following program :
int main()
{
  unsigned int a=-1;
  int b;
  b = ~0;
  if (a == b)
     printf("equal");
  else
     printf("not equal");
  return 0;
}
 (a)equal
 (b)not equal
 (c)Compile-Time Error
 (d)None of these
 [Q008] What will be the output of the following program :
 int main()
 {
   500;
   printf("%d",500);
   return(0);
 }
 (a)500
 (b)Run-Time Error
 (c)Compile-Time Error
 (d)None of these
 [Q009] What will be the output of the following program :
aaa()
{
  printf("hi!");
}

bbb()
{
  printf("hello");
}

ccc()
{
  printf("bye");
}

int main()
{
  int (*ptr[3])();
  ptr[0]=aaa;
  ptr[1]=bbb;
  ptr[2]=ccc;
  ptr[1]();
  return 0;
}
 (a)hi!
 (b)hello
 (c)bye
 (d)Compile-Time Error
 (e)None of these
 [Q010] What will be the output of the following program :
int main()
{
  float i=1.5;
  switch(i)
  {
     case 1: printf("1"); break;
     case 2: printf("2"); break;
     default : printf("0");
  }
  return(0);
}
 (a)1
 (b)2
 (c)Compile-Time Error
 (d)0
 (e)None of these

Click Here - SOLUTIONS - Weekly queries - Week1 - June 2005

Send your feedback about Weekly queries - Week1 - June 2005 section to nandakishorkn@rediffmail.com

You are Visitor No.

Sign my Guestbook View my Guestbook


Subscribe to C4Swimmers Group
Designed and Maintained by  Nanda Kishor

Make money from your website

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

nandakishorkn@rediffmail.com

TheFreeSite.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.