• No results found

N O OF TIMES THE LOOP IS EXECUTED ?

In document c_test (Page 64-96)

(A) 127

(B) 128

(C) 256

(D) INFINITELY

490. For the following C program Struct(s) {int a; long b; } Union (u) {int a; long b; }

Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4 491. For the following C program

Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i;

Output of i after executing the program

492. For the following C program char S;

char S[6]= " HELLO"; printf("%s ",S[6]);

output of the above program ? (a) 0

(b) ASCII 0 (c) I

(d) unpredictable

493. For the following C program Unsigned char c;

for(c=0;c!=256;c++2) printf("%d",c);

(a) 127 (b) 128 (c) 256 (d) infinitely

494. For the following program int i; i=2; i++; if(i==4) {printf(i=4); } else {printf(i=3); }

Output of the program ? a) 4 b) 3 c) unpredictable d) none Ans. (b) 495. What is FAT?. a) File Allocation Table b) File Access Table c) FDD Allocation Table d) None of the above Ans. (a) 496. Struct(s) { int a; long b; } Union (u) {int a; long b; }

Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4 497.Switch (i) i=1; case 1 i++; case 2 ++i;

break; ( ans : 1,2,3,none) case 3

--i;

Output of i after executing the program 498. char S;

char S[6]= " HELLO"; printf("%s ",S[6]);

output of the above program ? (0, ASCII 0, I,unpredictable) 499. Unsigned char c;

for ( c=0;c!=256;c++2) printf("%d",c);

No. of times the loop is executed ? (127,128,256,infinitely) 500 union endian { unsigned int i; char c; }; void main() {

printf("%d", sizeof(union endian) ); }

:2 :3 :4 :8

Q501. What will be the output of the following program: class mox { public: mox() { cout << "constructor " ; } void foo() { cout << "foo() " ; } ~mox() { cout << "destructor " ; } }; void main() { mox *m; m=(mox *) malloc(sizeof(mox)); m->foo(); free(m); } :foo()

:constructor foo() destructor :constructor destructor :No output

Q502. Which statement is not true:

:You can legally & explicitely call destructors in C++ :You can define virtual destructors

:You can sucessfully make polymorphic calls in a destructor :You cannot overload destructors

Q503. In the following class, the compiler will automatically add the following functions to the class class foo{}

:The default constructor & destructor :The overloaded = operator

:The copy constructor :All of the above

Q504. What is the output of the followng program: void foo(char *p)

{

p = (char *) 0xFFFF; }

void main() { char *p = 0x0000; foo(p); printf("%X", p); } :0x0000 :0xFFFF :0xffff

:Will crash when run

Q505. What will be the output of the following program: void main(void) { int i=0; int &iref=i; int j=10; iref=j; i++; j++; iref++; cout << i << " " << iref << " " << j; } :0 12 12 :12 12 11 :13 13 13 :2 2 11

Q506. What will be the output of the following program int i = 50; void foo(int i) { i *= 2; } void main() { int i=1; foo(i); printf("%d", i); } :1 :2 :50 :100

Q507. Consider the function declaration and choose the correct statement

void foo( int &i ) const;

:The function foo is a valid declaration, and foo can not change the value of i

:The function foo is a valid declaration, and foo can not change the value of the member variables of the class to which it belongs

:The function foo is a valid declaration, and foo can not be overriden in the derived class :The function foo is a valid declaration and foo can not be overloaded

Q508. What will be the output of the following program int foo()

{

static int i=0; i++;

return i; }

{ printf("%d ", foo()); printf("%d ", foo()); printf("%d ", foo()); } :Compilation Error :0 0 0 :1 1 1 :1 2 3 Q509. In C you can, :Define local static variables :Define global static variables :Define static functions :Define all of the above

Q510. Consider the following code snippet: class foo() { foo() {} } void main() { foo fArr[100]; }

In what sequence are the destructors called: :None : because arrays are not an Object in C++ :None : because it is a local array

:fArr[0] .. fArr[1] ... fArr[99] :fArr[99] .. fArr[1] ... fArr[0]

Q511. What will be the output of the following program /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ void main() { char *cp; int *ip; float *fp;

printf("%d %d %d", sizeof(*cp), sizeof(*ip), sizeof(*fp)); }

:Compilation Error :1 2 4

:2 2 2 :4 4 4

Q512. What is the output of the following program: /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ class base { private: int i; }

class derived : private base {

int i; } void main() { base b; derived d;

cout << sizeof(base) << " " << sizeof(b) << " " << sizeof(derived) << " " << sizeof(d); }

:2 2 2 2 :2 2 4 4 :2 4 4 4 :2 4 2 4

Q513. What is the output of the following program: /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ struct employee { char* name; float sal; }; void main() {

struct employee e1; e1.sal = 50.0;

e1.name = (char *) malloc(30);

strcpy(e1.name, "Sachin 10 the great."); printf("%d %d", sizeof(employee), sizeof(e1)); }

:8 8 :8 30 :8 34 :8 38

Q514. Consider the following pointer _expression: --*p++;

In what order are the operators executed, state them from the first executed to the last executed. :-- * ++

:* -- ++ :++ -- * :* ++ --

Q515. What is the output of the following program: struct employee { char* name; float sal; }; void main() {

struct employee e1, e2; e1.sal = 50.0;

e2.sal = 150.0;

e1.name = (char *) malloc(20); e2.name = (char *) malloc(20);

e1 = e2;

strcpy(e1.name, "Kapil Dev"); strcpy(e2.name, "Sunil Gavaskar"); printf("%s %f", e1.name. e1.sal); }

:Kapil Dev 50.0 :Sunil Gavaskar 150.0 :Kapil Dev 150.0 :Sunil Gavaskar 50.0

Q516. What will be the output of the following program #define SQUARE(x) x * x void main() { printf("%d ", SQUARE(3+2)); } :5 :10 :11 :25

Q517. How do you catch all exceptions in C++? :catch( all )

:catch(Exception) :catch( void* ) :catch(...)

Q518 delete NULL; :will crash the system

:will through a Memory Exception :will do nothing

:will give a compile time error

Q519. What will be the output of the following program /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ void main() { char *cp; int *ip; float *fp;

printf("%d %d %d", sizeof(cp), sizeof(ip), sizeof(fp)); }

:Compilation Error :1 2 4

:2 2 2 :4 4 4

Q520. What will be the output of the following: class Base

{ public :

virutal int Show( ) { printf( "Base" ); } ; }

class Derived : public Base {

public :

}

class Derived2 : public Derived {

public :

int Show( ) { printf( "Dervied1" ); } ; }

main() {

Derived2 obj2; Base *pBase = NULL; pBase = &obj2; pBase->Show(); } :Base :Dervied :Dervied1 :A Compilation error Q521. A vtable contains :

:pointers to virtual functions of a class :pointers to virtual base classes

:references to virtual functions of a class :references to virtual base classes

Q522. What will be the output of the following program: class foobar { static int i; public: foobar() { i++; } void foo(void) { i++; } void show() { cout << i << " "; } };

static int foobar::i; void main() { foobar f1,f2,f3 ; f1.foo(); f2.foo(); f2.foo(); f1.show(); f3.show() getch(); } :0 0 :2 1 :2 0 :6 6

Q523. What happens when you increment a void* ? :Compilation error.

:It goes up by the size of a pointer.

:It goes up by the size of the type it is pointing to. :Run Time error

Q524. What happens when you increment a void** ? :Compilation error

:It goes up by the size of a pointer

:It goes up by the size of the type it is pointing to :Run Time error

Q526. What will be the output of the following program void main()

{ int i; printf("%d", i); } :0 :-1 :0xFFFF :Garbage

Q527. What will be the output of the following program: class base { public: void foo() { cout << "base::foo()"; } };

class derived : private base { public: void foo() { cout << "deived::foo()"; } }; void main() { derived d = new d(); d->foo(); } :base::foo() :deived::foo()

:Error: Cannot access private member foo in main() :Error: Ambigous call to foo()

Q528. We cannot have a private destructor because :

:The compiler cannot access the destructor when destroying the class :The operating system cannot access the destructor when destroying the class :We can have a private destructor provided it is a virtual destructor

:We canot have private destructor

Q529. For a class Circle, the protortype of the copy constructor is: :Circle()

:Circle(Circle&) :Circle(Circle*) :Circle Circle()

Q530. Consider the following code snippet and choose the correct statement class Base

{

int Show( ) { printf( "Base" ); } ; }

class Derived : public Base {

virutal int Show( ) { printf( "Derived" ); } ; }

class Derived2 : public Derived {

int Show( ) { printf( "Dervied1" ); } ; }

main() {

Derived2 obj2; Base *pBase = NULL; pBase = &obj2; pBase->Show(); }

:Base :Dervied :Dervied1

:A Compilation error

Q531. What is the output of the following program: /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ class foo { public: char *c; float f; } void main() { foo f;

cout << sizeof(foo) << " " << sizeof(f); }

:Compilation Error - sizeof() cannot be applied to a class name :8 8

:4 4

:Garbage Garbage

Q532. Consider the following code: struct node

{

char *firstname; char *lastname; char node* next; };

void main() {

struct node *nPtr = (struct node *) malloc( sizeof(struct node) ); nPtr->firstname = (char*) malloc(10);

nPtr->lastname = (char*) malloc(10); nPtr->next = NULL;

// deallocating allocated memory??? }

What is the correct way the deallocate memory in the above program.

:free(nPtr);

:free( nPtr->firstname ); free( nPtr->lastname ); nPtr=NULL; :free( nPtr->firstname ); free( nPtr->lastname ); free(nPtr); :free(nPtr); free( nPtr->firstname ); free( nPtr->lastname );

Q533. You have to write a program where that implements a doubly linklist. Each node will store a float. The node declaration will have how many entries?

:2 :3 :4 :5

Q534. You have to write a program where that implements a cirlular linklist. Each node will store a char*. The node declaration will have how many entries?

:2 :3 :4 :5

Q535. What is the output of the following program: class base

{ public: base()

{ cout << "In base()";} base(int i)

{ cout << "In base(int)";}

}

class derived : private base {

public: derived()

{ cout << "In derived()";} derived(int i)

{ cout << "In derived(int)";} } void main() { dreived d(100); }

:In base() In derived() :In base(int) In derived(int) :In derived(int)

:In base() In derived(int)

Q536. Difference between Encapsulation and Data abstraction is that : :Both are same

:Encapsulation means putting a wrapper over data and functions, Data abstraction means hiding unnecessary information

:Encapsulation means hiding unnecessary information, Data abstraction means putting a wrapper over data and functions

:Encapsulation and Data abstraction cannot be compared

Q537. What should be the prototype of a function that swaps two float pointers? :void swap(float, float);

:void swap(float *, float *); :void swap(float **, float **); :void swap(float ***, float ***);

Q538. What will be the output of the following program /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/

void main() {

char *cp = (char *) 0x0000; int *ip = (int *) 0x0000; float *fp = (float *) 0x0000; cp++; ip++; fp++; printf("%d %d %d", cp, ip, fp); } :1 1 1 :1 2 4 :2 2 2 :4 4 4

Q539. What is the output of the followng program: void main()

{

char *p = (char*) malloc( strlen("Keep the faith") ); strcpy(p,"Keep the faith" );

printf("%s", p); }

:Compilation error :Keep the faith :Keep the faith :Garbage

Q540. What will be the output of the folowing: class Base

{ public :

virtual int Show( ) { printf( "Base" ); } ; }

class Derived : public Base {

public :

int Show( ) { printf( "Derived" ); } ; }

class Derived2 : public Derived {

public :

int Show( int i ) { printf( "Dervied1 %d", i ); } ; }

main() {

Derived2 obj2; Base *pBase = NULL; pBase = &obj2; pBase->Show(); } :Base :Dervied :Dervied1 :A Compilation error

Q541. How do you catch all exceptions in C++? :catch( all )

:catch(Exception) :catch( void* ) :catch(...)

Q542. Which statement is not true:

:You can legally & explicitely call destructors in C++ :You can define virtual destructors

:You can sucessfully make polymorphic calls in a destructor :You cannot overload destructors

Q543. What will be the output of the following program: class base { public: void foo() { cout << "base::foo()"; } };

class derived : private base {

public: void foo() { cout << "deived::foo()"; } }; void main() { derived d = new d(); d->foo(); } :base::foo() :deived::foo()

:Error: Cannot access private member foo in main() :Error: Ambigous call to foo()

Q544. In C you can, :Define local static variables :Define global static variables :Define static functions :Define all of the above

Q545. What will be the output of the following program

int foo() {

static int i=0; i++; return i; } void main() { printf("%d ", foo()); printf("%d ", foo()); printf("%d ", foo()); } :Compilation Error :0 0 0 :1 1 1 :1 2 3

Q546. What is the output of the followng program: void foo(char *p) { p = (char *) 0xFFFF; } void main() { char *p = 0x0000; foo(p); printf("%X", p); } :0x0000 :0xFFFF :0xffff

:Will crash when run

Q547. When a class is derived from the base class with protected access specifier eg class A : protected B

:Only the protected members of class B are accessible in class A

:Only the protected and public members of class B are accessible in class A :Only the public members of class B are accessible in class A

:None of the members of class B are accessible in class A Q548. What will be the output of the following program /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ void main() { char *cp; int *ip; float *fp;

printf("%d %d %d", sizeof(cp), sizeof(ip), sizeof(fp)); } :Compilation Error :1 2 4 :2 2 2 :4 4 4 Question :

Q549. What is the output of the following program: class base

{

public: base()

{ cout << "In base()";} base(int i)

{ cout << "In base(int)";} }

class derived : private base {

public:

derived()

{ cout << "In derived()";} derived(int i)

{ cout << "In derived(int)";} }

void main() {

dreived d(100); }

:In base() In derived() :In base(int) In derived(int) :In derived(int)

:In base() In derived(int)

Q550. Consider the following pointer expression: --*p++;

In what order are the operators executed, state them from the first executed to the last executed.

:-- * ++ :* -- ++

:++ -- * :* ++ --

Q551. You have to write a program where that implements a cirlular linklist. Each node will store a char*. The node declaration will have how many entries?

:2 :3 :4 :5

Q552. A vtable contains :

:pointers to virtual functions of a class :pointers to virtual base classes

:references to virtual functions of a class :references to virtual base classes

Q553. What will be the output of the following program

void main() { int i; printf("%d", i); } :0 :-1 :0xFFFF :Garbage

Q554. What is the output of the following program: struct employee { char* name; float sal; }; void main() {

struct employee e1, e2; e1.sal = 50.0;

e2.sal = 150.0;

e1.name = (char *) malloc(20); e2.name = (char *) malloc(20); e1 = e2;

strcpy(e1.name, "Kapil Dev"); strcpy(e2.name, "Sunil Gavaskar"); printf("%s %f", e1.name. e1.sal); }

:Kapil Dev 50.0 :Sunil Gavaskar 150.0 :Kapil Dev 150.0 :Sunil Gavaskar 50.0

Q15. In the following class, the compiler will automatically add the following functions to the class class foo{}

:The default constructor & destructor :The overloaded = operator

:The copy constructor :All of the above

Q556. What will be the output of the following program

/*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ class employee { char *name; public: employee() {} virtual void foo() { cout << "In foo()"; } virtual ~employee() {} } void main() { employee e; cout << sizeof(e); } :0 :4 :8 :Garbage

Q557. What will be the output of the following program: /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ union endian { unsigned int i; char c; }; void main() {

printf("%d", sizeof(union endian) ); }

:2 :3 :4 :8

Q558. What happens when you increment a void* ?

:Compilation error.

:It goes up by the size of a pointer.

:It goes up by the size of the type it is pointing to. :Run Time error

int i = 50; void foo(int i) { i *= 2; } void main() { int i=1; foo(i); printf("%d", i); } :1 :2 :50 :100

Q560. We cannot have a private destructor because :

:The compiler cannot access the destructor when destroying the class :The operating system cannot access the destructor when destroying the class :We can have a private destructor provided it is a virtual destructor

:We canot have private destructor

Q561. What should be the prototype of a function that swaps two float pointers?

:void swap(float, float); :void swap(float *, float *); :void swap(float **, float **); :void swap(float ***, float ***);

Q562. What will be the output of the following program: void main(void) { int i=0; int &iref=i; int j=10; iref=j; i++; j++; iref++; cout << i << " " << iref << " " << j; } :0 12 12 :12 12 11 :13 13 13 :2 2 11

Q563. Consider the following code snippet: class foo() { foo() {} } void main() { foo fArr[100]; }

In what sequence are the destructors called:

:None : because arrays are not an Object in C++ :None : because it is a local array

:fArr[0] .. fArr[1] ... fArr[99] :fArr[99] .. fArr[1] ... fArr[0]

Q564. What is the output of the followng program: void main()

{

char *p = (char*) malloc( strlen("Keep the faith") ); strcpy(p,"Keep the faith" );

printf("%s", p); }

:Compilation error :Keep the faith

:Keep the faith <followed by garbage> :Garbage

Q565. You have to write a program where that implements a doubly linklist. Each node will store a float. The node declaration will have how many entries?

:2 :3 :4 :5

Q566. What will be the output of the following program: class mox { public: mox() { cout << "constructor " ; } void foo() { cout << "foo() " ; } ~mox() { cout << "destructor " ; } }; void main() { mox *m; m=(mox *) malloc(sizeof(mox)); m->foo(); free(m); } :foo()

:constructor foo() destructor :constructor destructor :No output

Q567. What is the output of the following program: class foo

int i; public: foo() : i(10) {} void show() { cout << i; } } void main() { foo f; f.show(); } :Compilation error :Gabage :0 :10

Q557. What is the output of the following program: /*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ class foo { public: char *c; float f; } void main() { foo f;

cout << sizeof(foo) << " " << sizeof(f); }

:Compilation Error - sizeof() cannot be applied to a class name :8 8

:4 4

:Garbage Garbage

Q558. Consider the function declaration and choose the correct statement

void foo( int &i ) const;

:The function foo is a valid declaration, and foo can not change the value of i

:The function foo is a valid declaration, and foo can not change the value of the member variables of the class to which it belongs

:The function foo is a valid declaration, and foo can not be overriden in the derived class :The function foo is a valid declaration and foo can not be overloaded

Q559. In C++ you cannot do which of the following:

:Define a class in a class :Define a function in a funciton :Define a class in a function :You can do all of the above

class Base {

int Show( ) { printf( "Base" ); } ; }

class Derived : public Base {

virutal int Show( ) { printf( "Derived" ); } ; }

class Derived2 : public Derived {

int Show( ) { printf( "Dervied1" ); } ; }

main() {

Derived2 obj2; Base *pBase = NULL; pBase = &obj2; pBase->Show(); } :Base :Dervied :Dervied1 :A Compilation error

Q561. What happens when you increment a void** ?

:Compilation error

:It goes up by the size of a pointer

:It goes up by the size of the type it is pointing to :Run Time error

Q562. delete NULL;

:will crash the system

:will through a Memory Exception :will do nothing

:will give a compile time error

Q563. What will be the output of the following program

/*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/

void main() {

char *cp = (char *) 0x0000; int *ip = (int *) 0x0000; float *fp = (float *) 0x0000; cp++; ip++; fp++; printf("%d %d %d", cp, ip, fp); } :1 1 1 :1 2 4 :2 2 2 :4 4 4

struct node {

char *firstname; char *lastname; char node* next; };

void main() {

struct node *nPtr = (struct node *) malloc( sizeof(struct node) ); nPtr->firstname = (char*) malloc(10);

nPtr->lastname = (char*) malloc(10); nPtr->next = NULL;

// deallocating allocated memory??? }

What is the correct way the deallocate memory in the above program. :free(nPtr);

:free( nPtr->firstname ); free( nPtr->lastname ); nPtr=NULL; :free( nPtr->firstname ); free( nPtr->lastname ); free(nPtr); :free(nPtr); free( nPtr->firstname ); free( nPtr->lastname ); Q565. What is the output of the following program:

/*

Assume sizeof char=1, int=2, float=4 Assume sizeof a pointer =4

*/ class base { private: int i; }

class derived : private base { public: int i; } void main() { base b; derived d;

cout << sizeof(base) << " " << sizeof(b) << " " << sizeof(derived) << " " << sizeof(d); }

:2 2 2 2 :2 2 4 4 :2 4 4 4 :2 4 2 4

Q37. What will be the output of the following program #define SQUARE(x) x * x

void main() {

printf("%d ", SQUARE(3+2)); }

:5 :10 :11 :25

Q566. What will be the output of the following: class Base

{

public :

virutal int Show( ) { printf( "Base" ); } ; }

class Derived : public Base {

public :

int Show( ) { printf( "Derived" ); } ; }

class Derived2 : public Derived {

public :

int Show( ) { printf( "Dervied1" ); } ; }

main() {

Derived2 obj2; Base *pBase = NULL; pBase = &obj2; pBase->Show(); } :Base :Dervied :Dervied1 :A Compilation error

Q567. For a class Circle, the protortype of the copy constructor is:

:Circle() :Circle(Circle&) :Circle(Circle*) :Circle Circle()

Q568. Difference between Encapsulation and Data abstraction is that : :Both are same

:Encapsulation means putting a wrapper over data and functions, Data abstraction means hiding unnecessary information

:Encapsulation means hiding unnecessary information, Data abstraction means putting a wrapper over data and functions

:Encapsulation and Data abstraction cannot be compared

569. A long C program is given -- try to be familiar with few of the concepts listed below int *num={10,1,5,22,90};

main() { int *p,*q; int i;

p=num; q=num+2; i=*p++;

print the value of i, and q-p, and some other operations are there. }

how the values will change?

570. One pointer diff is given like this: int *(*p[10])(char *, char*)

Explain the variable assignment

571 char *a[4]={"jaya","mahe","chandra","buchi"}; What is the value of sizeof(a) /sizeof(char *) 572. For the following C program

void fn(int *a, int *b) {int *t; t=a; a=b; b=t; } main() {int a=2; int b=3; fn(&a,&b); printf("%d,%d", a,b); }

What is the output? a) Error at runtime b) Compilation error c) 2 3

d) 3 2

573. For the following C program #define scanf "%s is a string" main()

{printf(scanf,scanf); }

What is the output. Ans. %s is string is string 574. For the following C program {char *p="abc"; char *q="abc123"; while(*p=*q) print("%c %c",*p,*q); } a) aabbcc b) aabbcc123 c) abcabc123 d) infinate loop

575. What is the value of the following: printf("%u",-1)

a) -1 b) 1 c) 65336

576. For the following C program #define void int

int i=300; void main(void) {int i=200;

{int i=100;

print the value of i;} print the value of i;} What is the output?

578. For the following C program int x=2;

x=x<<2; printf("%d ",x); Ans. 8

579. For the following C program

int a[]={0,0X4,4,9}; /*some values are given*/ int i=2;

printf("%d %d",a[i],i[a]); What is the value?

580. Consider the following program: character cName[5] = 'great'

Numeric nNum1,nNum2 =0

For (nNum1 = 0;nNum1=>5;nNum1++) {

if(cName[nNum1] == 'a'| cName[nNum1] != 'e'| cName[nNum1] == 'i'| cName[nNum1] != 'o'| cName[nNum1] == 'u'|) { nNum2 ++ } } display nNum2

What does nNum2 display. a) 2

b) 1 c) 5 d) 3

580. How can the word YES be stored in any array. a) array[1] = 'Y' array[2] = 'E' array[3] = 'S' array[4] = '\0' b) array[0] = "Y" array[1] = "E" array[2] = "S" array[3] = "\0" c) array[1] = "Y" array[2] = "E" array[3] = "S" d) array[0] = 'Y' array[1] = 'E' array[2] = 'S' array[3] = '\0'

581. What is true about the following C functions?

(A) Need not return any value. (B) Should always return an integer.

582. enum number { a=-1, b=4, c,d,e,} what is the value of e?

(A) 7 (B) 4 (C) 5 (D) 3 23. Which of the following about automatic variables within a function is correct?

(A) Its type must be declared before using the variable. (B) They are local. (C) They are not initialized to zero. (D) They are global. 583. Consider the following program segment

int n, sum=5; switch(n) { case 2:sum=sum-2; case 3:sum*=5; break; default:sum=0; }

if n=2, what is the value of the sum?

(A) 0 (B) 15 (C) 3 (D) None of these.

584. Which of the following is not an infinite loop? (A) x=0; (B) # define TRUE 0.... do{ While(TRUE){....} /*x unaltered within the loop*/ (C) for(;;) {....} ....}

While(x==0); (D) While(1) {....} 585. Output of the following program is

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; } } }

(A) 5,9,13,17 (B) 12,17,22 (C) 16,21 (D) syntax error. 586. What does the following function print?

func(int i) { if(i%2) return 0; else return 1; } main() { int i=3; i=func(i); i=func(i); printf("%d",i); } (A) 3 (B) 1 (C) 0 (D) 2 587. What will be the result of the following program?

char*g() {

return x; } main() { char*g1="First String"; strcpy(g(),g1); g1=g(); strcpy(g1,"Second String"); printf("Answer is:%s", g()); }

(A) Answer is: First String (B) Answer is: Second String

In document c_test (Page 64-96)

Related documents