Multiple Choice Questions in C (Answers not given)

Discussion in 'C' started by sibu, Jan 31, 2007.

  1. sibu

    sibu New Member

    Joined:
    Mar 27, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    1.
    Code:
    #include<stdio.h>
    #include<conio.h>
    main()
    {
    	int a[3],i;
    	for(i=0;i<3;i++)
    	a[i]=i++;
    	for(i=0;i<3;i++)
    	printf("\t%d",a[i]);
    }
    
    a. 0 Garbage Value 2
    b. 0 1 2
    c. 1 2 3
    d. None of the above


    2.
    Code:
    void main()
    {
    	int a = 123, b = 456;
    	a ^= b ^= a ^= b;
    	printf("%d\t%d",a,b);
    }
    
    a. 123 456
    b. 123 123
    c. 456 456
    d. 456 123


    3.
    Code:
    void main()
    {
    	int a=5,b=4,c=10;
    	*((a>b) ? &a : &b) = (a+b>c);
    	printf("%d\t%d",a,b);
    }
    
    a. Syntax Error
    b. Fatal Error
    c. 0 4
    d. System Hangs


    4.
    Code:
    void f(int *ip)
    {
    	static int dummy = 5;
    	ip = &dummy;
    	printf("%u\n",ip);
    }
    
    void main()
    {
    	int *ip;
    	f(ip);
    	printf("%u",ip);
    }
    
    a. Some Values
    b. 0 Some Value
    c. Error
    c. None of the Above


    5.
    Code:
    void main()
    {
    	int realarray[2]={1,2};
    	int *array = &realarray[-1];
    	int i;
    	for(i=0;i<2;i++)
    	{
    		printf("\t%d",*array);
    		array++;
    	}
    }
    
    a. Error
    b. Garbage Value 1
    b. 0 1
    d. 1 2


    6.
    Code:
    #define Str(x) #x
    #define Xstr(x) Str(x)
    #define OP plus
    void main()
    {
    	char *opname = Xstr(OP);
    	printf("%s",opname);
    }
    
    a. plus
    b. Compilation Error
    c. Runtime Error
    d. Linker Error


    7.
    Code:
    main()
    {	
    	extern i;
    	printf("%d\n",i);
    	{
    		int i=20;
    		printf("%d\n",i);
    	}
    }
    
    a. 20 20
    b. Garbage Value 20
    c. 0 20
    d. Linker Error


    8.
    Code:
    int main()
    {
    	int a=500,b=100,c=30,d=40,e=19;
    	a+=b-=c*=d/=e%=5;
    	printf("\n%d %d %d %d %d",a,b,c,d,e);
    }
    
    a. 0 -200 300 10 4
    b. 300 -200 300 10 4
    c. -200 300 10 4 0
    d. 100 -200 300 4 10


    9.
    Code:
    void main()
    {
    	int a=1,b=2,c=3,d=4;
    	printf("%d",!a?b?!c:!d:a);
    }
    
    a. 1
    b. 0
    c. No Output
    d. Error


    10.
    Code:
    	void main()
    	{
    	  int i;
    	  for (i=5; ++i; i-=3)
    	  	printf("%d ",i);
    	}
    	
    a. Program Hangs
    b. No Output
    c. 6 4 2
    d. 5 2

    11.
    What will be the output of the following program :
    Code:
    void main()
    {
    	int val=1234;
    	int* ptr=&val;
    	printf("%d %d",val,*ptr++);
    }
    
    
    a. 1234 1234
    b. 1235 1235
    c. 1234 1235
    d. 1235 1234


    12.
    What will be the output of the following program :
    Code:
    void main()
    {
    	int i;
    	float a[5];
    	for (i=0; i<5; i++)
    		a[i] = (printf, ("%d",i/10.0));
    	for (i=0; i<5; i++)
    		printf("%.1f ",a[i]);
    }
    
    a. Compile-Time Error
    b. 0.0 0.0 0.0 0.0 0.0
    c. 0.0 0.1 0.2 0.3 0.4
    d. 1.0 1.0 1.0 1.0 1.0


    13.
    What will be the output of the following program :
    Code:
    	void func()
    	{
    	  printf("Testing...Done\n");
    	}
    	void main()
    	{
    	  func;
    	  func();
    	}
    	
    a. Compile-Time Error
    b. Testing...Done
    c. Testing...Done
    Testing...Done
    d. None of these

    14.
    A signed int bitfield 1-bit wide can only hold the values

    a. 0 and 1
    b. 0 and -1
    c. 0, 1 and -1
    d. None of these


    15.
    Code:
    void main()
    	{
    	   int _;
    	   _=100;
    	   printf("%d",_);
    	}
    
    a. 100
    b. Linker Error
    c. Run Time Error
    d. Compiler Error


    16.
    Code:
    void main()
    	{
    	  int choice=2;
    	  switch(choice)
    	  {
    	     default:
    		    printf("Default1");
    
    	     case 1:
    		    printf("Case1");
    		    break;
    
    	     default:
    		    printf("Default2");
    	  }	
    	}
    
    a. Compile-Time Error
    b. Default1Case1
    c. Default2
    d. Default1


    17.
    Code:
    	#define big(a,b) a > b ? a : b
    	#define swap(a,b) temp=a; a=b; b=temp;
    	void main()
    	{
    	   int a=3,b=5,temp=0;
    	   if ((3+big(a,b)) > b)
    	      swap(a,b);
    	   printf("%d %d",a,b);
    	}
    	
    a. 3 0
    b. 5 3
    c. 3 5
    d. 5 0


    18. Evaluate the following:
    Code:
    int fn(int v)
    {
    	if(v==1 || v==0)
    		return 1;
    	if(v%2==0)
    		return fn(v/2)+2;
    	else
    		return fn(v-1)+3;
    }
    for fn(7); 
    
    a. 10
    b. 11
    c. 1
    d. 0


    19. What does the line containing "break;" do in the following code?
    Code:
    void afunction()
    {
    	if(1)
    	{
    		break;
    		afunction(); 
    		printf("Error"); 
    	}
    }
    
    a. Breaks out of the if statement
    b. Exits the function
    c. Compiler error
    d. Nothing


    20. What does the following code do?
    Code:
    void afunction(int *x)
    {
    	x=new int;
    	*x=12;
    }
    int main()
    {
    	int v=10;
    	afunction(&v);
    	printf(“%d”,v);
    }
    
    a. Outputs 12
    b. Outputs 10
    c. Outputs the address of v
    d. No Output

    21. If a machine architecture assigns 4 bytes to store the address of a variable, what should be the output of the program stated below?

    Code:
    main()
    {
    	char *p;
    	printf(“%d %d”, sizeof(char *p), sizeof(*p));
    }
    
    a. 1 4
    b. 4 4
    c. 4 1
    d. 1 1

    22. What would be the output of the following?

    Code:
    main()
    {
     int a=10,b;
     a>=5?b=100:b=200;
     printf("\n%d",b);
    }
    
    a. 100
    b. 200
    c. Compiler Error
    d. None of the above

    23. What would be the output of the following?

    Code:
    main()
     {
      int i=4;
      switch(i)
       {
         default: printf(“A”);
         case 1: printf(“B”);
    	      break;
         case 2: printf(“C”);
    	      break;
         case 3: printf(“D”);
    	       break;
        }
     }	
    
    a. A
    b. B
    c. All the above
    d. None of the above

    24. What would be the output of the following?

    Code:
    #define SQR(x) x*x
    main()
     {
       int a,b=3;
       a=SQR(b+2);
       printf(“%d”,a);
     }
    
    a. 25
    b. 11
    c. Error
    d. Garbage Value


    25. If the following program(myprog) is run from the command line as myprog mon tue wed thu, what would the output?

    Code:
    main(int argc, char *argv[])
     {
      while(--argc>0)
       printf(“%s”, *++argv);
     }
    
    a. myprog mon tue wed thu
    b. mon tue wed thu
    c. myprog tue thu
    d. tue thu


    26. What is the type of variable f2 and p2 in the following declaration?

    #define floatptr float *
    #define int * intptr

    floatptr f1,f2;
    intptr p1,p2;

    a. float, int pointer
    b. float pointer, int pointer
    c. float, int
    d. float pointer, int

    27. What would be the output of the following?

    Code:
    main()
     {
       const int x;
       x=128;
       printf(“%d”,x);
     }
    
    a. 128
    b. 0
    c. Garbage Value
    d. Error

    28. If the following program(myprog) is run from the command line as myprog fri tue sun, what would the output?

    Code:
    main(int argc, char *argv[])
     {
      printf(“%c”,**++argv);
     }
    
    a. m
    b. f
    c. s
    d. None of the above


    29. What would be the output of the following?

    Code:
    void main()
     {
      int z,x=5,y=-10,a=4,b=2;
      z=x++ - --y *b/a;
      printf("\n%d",z);
     }
    
    a. 5
    b. 12
    c. 10
    d. 11


    30. What would be the output of the following?
    Code:
    char *fun(char *ptr)
     {
      ptr+=3;
      return(ptr);
     }
    void main()
     {
      char *x,*y;
      x="Hello";
      y=fun(x);
      printf("\n%s",y);
     }
    
    a. Hello
    b. lo
    c. llo
    d. Error


    31.
    Code:
    struct node *nptr,*sptr; /*pointers for linked list*/
    for(nptr=sptr;nptr;nptr=nptr->next)
     {
       free(nptr);
     } 
    
    releases memory from a linked list. Which of the following accurately describes how it will work?

    a. It will work correctly since the for loop covers the entire list.
    b. It may fail since each node “nptr” is freed before its next address can be accessed.
    c. This is invalid syntax for freeing memory
    d. The loop will never end


    32. In C, what is the difference between a declaration and definition of a variable?

    a. Both can occur multiple times, but a declaration must occur first.
    b. Both can occur multiple times, but a definition must occur first.
    c. A definition occurs once, but declaration may occur many times.
    d. A declaration occurs once, but definition may occur many times.


    33. What would be the output of the following?

    Code:
    void main()
    {
    	int a=10,b;
    	b=a++ + ++a;
    	printf("\n%d %d %d %d",b,a++,a,++a);
    }
    
    a. 22 10 11 13
    b. 22 11 11 11
    c. 22 10 11 13
    d. 22 13 13 13


    34. sizeof is an ________________

    a. int
    b. unsigned int
    c. long int
    d. Anyone of the above


    35. . and -> are __________ operators.

    a. Binary
    b. Unary
    c. Ternary
    d. None of the above


    36. What would be the output of the following?
    Code:
    main()
    {
    	int val1=1234;
    	int val2=01234;
    	printf("%d %d",val1,val2);
    }
     
    a. 1234 1234
    b. 1234 01234
    c. 1234 668
    d. 1234 688

    37. chmod() function is defined in which header file?

    a. assert.h
    b. dos.h
    c. io.h
    d. Mem.h

    38. The header file which includes stdarg.h is_____________

    a. assert.h
    b. dos.h
    c. io.h
    d. Mem.h


    39. _______________ is a direct interface to the DOS call 0x44

    a. ioctl
    b. ios
    c. dup
    d. tell


    40. What would be the output of the following?
    Code:
    main()
    {
    	int i=strlen("Blue")+strlen("Purple")/strlen("Red")-strlen("Green");
    	printf("\n%d",i);
    }
    
    a. 0
    b. 3
    c. 2
    d. 1


    41. What would be the output of the following?
    Code:
    void main()
    {
    	int i=7;
    	printf("\n%old %old %old %old",i,i++,i--,i++);
    	getch();
    }
    
    a. old old old old
    b. 7ld 8ld 7ld 8ld
    c. 10ld 7ld 10ld 7ld
    d. Error

    42. longjmp cannot pass the value ________.

    a. -1
    b. 0
    c. 1
    d. 2


    43. Scope of a global variable which is declared as __________ is within the file.

    a. static
    b. extern
    c. register
    d. function argument


    44. What value is returned by abort function?

    a. Depends on the parameter passed
    b. 3
    c. Depends on the Operating System
    d. 0


    45. What would be the output of the following?
    Code:
    main()
    {
    	int i,j;
    	for(i=0;;i++)
    	for(j=0;;j++)
    	if(j>100) break;
    	printf("%d%d",i,j);
    }
    
    a. System Hangs
    b. 100 100
    c. 0 100
    d. 1 100


    46. What would be the output of the following?

    Code:
    main()
    {
    	const int x=5;
    	int *ptr;
    	ptr=&x;
    	*ptr=10;
    	printf("%d",x);
    }
    
    a. 5
    b. 10
    c. Error
    d. Garbage Value


    47. What would the output of the following?

    Code:
    main()
     {
      int y,x=5;
      y=++x - ++x;
      printf("\n%d%d",x,y);
     }
    
    a. 7 1
    b. 7 -1
    c. 7 0
    d. 5 1


    48. What would be the output of the following?
    Code:
    main()
    {
     char *str = "\eMissi\0ssippi\z";
     printf("%s",str);
    }
    
    a. eMissi
    b. eMissi ssippiz
    c. Mississippi
    d. Missi


    49. Format specifier %p is used for _______________

    a. Print the address contained in a pointer variable
    b. Peak a value at a location
    c. Print the address in segment: offset notation
    d. Same as %d


    50. What would be the output of the following program?
    Code:
    main()
     {
      char *str,*str1="I Love You";
      str=malloc(strlen(str1));
      strcpy(str,str1);
      printf("%s",str);
      free(str);
     }
    
    a. free() fails
    b. I Love You
    c. malloc() fails
    d. strcpy() fails


    51. What would be the output of the following?
    Code:
    main()
     {
      char a[5][5],flag;
      a[0][0] = 'A';
      flag=((a==*a)&&(*a==a[0]));
      printf("\n%d",flag);
     }
    
    a. 1
    b. 0
    c. Error
    d. No output


    52. What would be the output of the following?
    Code:
    main()
    {
     static int a[]={0,1,2,3,4};
     static int *p[]={a,a+1,a+2,a+3,a+4};
     int **ptr;
     ptr=p;
     **ptr++;
     printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
     *++*ptr;
     printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
     ++**ptr;
     printf("\n%d %d %d",ptr-p,*ptr-a,**ptr);
     getch();
    }
    
    a.
    1 0 1
    1 0 2
    1 0 2
    b.
    0 1 1
    1 1 1
    1 1 1
    c.
    1 2 3
    2 2 3
    2 3 3
    d.
    1 0 1
    1 0 1
    1 1 2

    53. What would be the output of the following?
    Code:
    main()
    {
    	int i=0;
    	for(i=0;i<20;i++)
    	{
    		switch(i)
    		{
    			case 0: i+=5;
    			case 1: i+=2;
    			case 5: i+=5;
    			default: i+=4;
    			break;
    		}
    		printf("\t%d",i);
    	}
    }
    
    a. 0 5 9 13 17
    b. 5 9 13 17
    c. 12 17 22
    d. 16 21


    54. What would be the output of the following?
    Code:
    #define CUBE(x) x*x*x
    main()
     {
      int a,b=3;
      a=CUBE(b++);
      printf("\n%d\t%d",a,b);
     }
    
    a. 64 4
    b. 27 4
    c. 27 6
    d. 64 6


    55. What would be the output of the following?

    Code:
    #define square(b) b*b
    main()
    {
     int a;
     a=64/square(4);
     printf("\n%d",a);
    }
    
    a. 64
    b. 4
    c. 16
    d. None of the above


    56. What would be the output of the following?

    Code:
    #define f(g,g2) g##g2
    main()
    {
     int var12=100;
     printf(“%d”,f(var,12));
    }
    
    a. Invalid Pragma
    b. 12
    c. 100
    d. Compiler Error

    57. What would be the output of the following?
    Code:
    main()
    {
    	int x = 5; 
    	int y = 10; 
    	double z; 
    	z = (double) (5 / 10); 
    	printf("z = %.2f\n", z); 
    }
    
    a. 1.00
    b. 0.50
    c. 0.00
    d. -0.50


    58. Which one of the following describes the chief difference between a structure and a union?

    a. The fields of a structure overlap each other in memory; the fields of a union are allocated sequentially.
    b. The compiler pads structures for word alignment; the compiler allocates exactly enough space for a union to hold all of its fields.
    c. A union may contain bitfields; a structure may not.
    d. The fields of a structure exist concurrently; the fields of a union do not.


    59. What would be the output of the following?
    Code:
    int x=5;
    void print()
    {
    	printf("%d",x--);
    }
    
    main()
    {
    	print(x++);
    }
    
    a. 4
    b. 5
    c. 6
    d. None of the above


    60. f = fopen( fileName, "r" );

    Code:
    if( ???? ) 
    { 
        fprintf( stderr, "Could not open file!" ); 
        exit( -1 ); 
    } 
    
    What should replace the ???? in the code above to determine if the file could NOT be opened?


    a. fclose( f )
    b. f == -1
    c. f != 0;
    d. f == NULL
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Now we have quite a few questions in C-C++.

    [thread=137]100 Multiple choice questions in C [/thread]
    [thread=2778]Top 100 C Questions Asked in Actual Interviews[/thread]
     
  3. karthick.RG.Rajan

    karthick.RG.Rajan New Member

    Joined:
    Dec 22, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    very useful to my interview sir
     
  4. wrecker

    wrecker New Member

    Joined:
    Mar 12, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    hry guys, i have solved almost all ques. m attaching file. please check if any answer is not correct...
    will surely post remaining ques later...

    Code:
    1.	a
    2.	d
    3.	c
    4.	a
    5.	b
    6.	a
    7.	d
    8.
    9.	a
    10.	c
    11.	a
    12.	a
    13.	b
    14.
    15.	a
    16.	a
    17.	b
    18.	b
    19.	c
    20.	b
    21.	b
    22.	b
    23.	d
    24.	b
    25.
    26.
    27.	d
    28.
    29.	c
    30.	b
    31.	b
    32.	c
    33.	d
    34.	a
    35.	d
    36.	c
    37.
    38.	
    39.	
    40.	d
    41.	c  (Unable to figure out)
    42. 	d
    43.	b
    44.
    45.	a
    46.	c
    47.	b
    48.	a
    49.
    50.	c
    51.	c
    57.	b
    58.	d
    60.	c
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Don't you think that would be a spoiler.
     
  6. sibu

    sibu New Member

    Joined:
    Mar 27, 2005
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    I dont want to say whether answers are correct or not. Few questions are implementation dependant.Always you could execute and see and then try to find out reason behind the anwer. I feel that would be best way to learn
     
  7. wrecker

    wrecker New Member

    Joined:
    Mar 12, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    Why to be a spoiler. I thought that would just test my knowledge in C and would provide answers that are a bit confusing to those who do not know it? So to me it lot more useable than to those whom its spoiler.
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I dont doubt on this.
     
  9. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    Could you please explain to me the questions #10, #17 and #20?

    #10 why does the loop ends?

    #17 why does 3+big(a,b) is different than big(a,b)+3 ?

    #20 The line x=new int; gives me 4 errors and 1 warning in my compiler.

    Thank you
     
  10. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Because the value of i becomes -1 at some point in the loop and so ++1 becomes 0 and so it breaks.

    Because of order of precedence of the operators involved.

    It should not. I have tried compiling it. What compiler you are using and what are the errors / warnings.
     
  11. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    The compiler i use is LCC-WIN 32
    This is how i have written the program and the warnings.

    1 #include<stdio.h>
    2 void afunction(int *x)
    3 {
    4 x=new int;
    5 *x=12;
    6 }
    7 int main()
    8 {
    9 int v=10;
    10 afunction(&v);
    11 printf("%d",v);
    12 }

    Error c:\lcc\test.c: 4 undeclared identifier 'new'
    Error c:\lcc\test.c: 4 operands of = have illegal types 'pointer to int' and 'int'
    Warning c:\lcc\test.c: 4 possible usage of new before definition
    Error c:\lcc\test.c: 4 Syntax error; missing semicolon before `int'
    Error c:\lcc\test.c: 4 empty declaration
    Compilation + link time:0.7 sec, Return code: 1


    As for the other questions i haven't yet understand the following:
    #10 why does the loop stop when i=0?

    #17 i don't understand why the precedence affects the value of b
    Thanks
     
  12. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am not sure about the error but I can explain about the other 2.

    When anything becomes zero its equal to false or else its true. In C there is nothing bool but everything is with respect to 0 and Non zero. 0 being false and Non Zero is true.

    Say if you have something like if(1) will always be true.

    Regarding precedence try expanding the macro on pen and paper and you will see both evaluation does not come out to be same.
     
  13. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    OK, i understand this. So I used the postfix i++ instead of ++i (in the same programme) and though i became 0 the loop never ended. Why is that?
     
  14. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I should become -1 in ++i for the expression to become 0 and if it becomes 0 then ++i becomes 1 and the same logic goes for i++ but its the increment that is done after the loop breaking condition check.
     
  15. JamC

    JamC New Member

    Joined:
    Jun 23, 2007
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    0
    Code:
    1 #include<stdio.h>
    2 void afunction(int *x)
    3 {
    4 x=new int;
    5 *x=12;
    6 }
    7 int main()
    8 {
    9 int v=10;
    10 afunction(&v);
    11 printf("%d",v);
    12 }
    
    Error c:\lcc\test.c: 4 undeclared identifier 'new'
    Error c:\lcc\test.c: 4 operands of = have illegal types 'pointer to int' and 'int'
    Warning c:\lcc\test.c: 4 possible usage of new before definition
    Error c:\lcc\test.c: 4 Syntax error; missing semicolon before `int'
    Error c:\lcc\test.c: 4 empty declaration
    Compilation + link time:0.7 sec, Return code: 1
    You do not use new to allocate dynamic memory in C- you use new with C++..
     
  16. seeguna

    seeguna New Member

    Joined:
    Jun 20, 2007
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Technical Consultant
    Location:
    Chennai
    Try this coding in the manner...........u got answer
    Code:
    #include <stdio.h>
    void afunction(int *x)
    
    {
        x=new int;
        *x=12;
    }
    int main()
    {
        int v=10;
        afunction(&v);
        printf("%d",v);
    	return 0;
    }
     
    Last edited by a moderator: Aug 4, 2007
  17. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
    This also not working :(
     
  18. seeguna

    seeguna New Member

    Joined:
    Jun 20, 2007
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Technical Consultant
    Location:
    Chennai
    Run it in Microsoft Vc++ compiler ...
    U will get an answer of value "10"
     
  19. psapikas

    psapikas New Member

    Joined:
    Aug 1, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Mathematician
    Location:
    Athens
  20. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It looks like you are getting the error in the new statement and so would like to know what si the file name you are compiling your code in. It should be a .cpp file and not a .c file or else your C compiler will not understand the new syntax.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice