Sei sulla pagina 1di 118

Give the output of the programs in each case unless mentioned otherwise

1. void main()
{
  int d=5;
  printf("%f",d);
}Ans: Undefined
2. void main()
{
  int i;
  for(i=1;i<4,i++)                                                                                 
  switch(i)
  case 1: printf("%d",i);break;
{
 case 2:printf("%d",i);break;
 case 3:printf("%d",i);break;
}
 switch(i) case 4:printf("%d",i);
}Ans: 1,2,3,4
3. void main()
{
 char *s="\12345s\n";
 printf("%d",sizeof(s));
}Ans: 6
4. void main()
{
  unsigned i=1; /* unsigned char k= -1 => k=255; */
  signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */                                  
if(i<j)
  printf("less");
else
if(i>j)
  printf("greater");
else
if(i==j)
  printf("equal");
}Ans: less
5. void main()
{
  float j;
  j=1000*1000;
  printf("%f",j);
}

1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
6. How do you declare an array of N pointers to functions returning  pointers to
functions returning pointers to characters?     Ans: The first part of this question can
be answered in at least        three ways:
7. Build the declaration up incrementally, using typedefs:
        typedef char *pc;    /* pointer to char */
        typedef pc fpc();    /* function returning pointer to char */
        typedef fpc *pfpc;    /* pointer to above */
        typedef pfpc fpfpc();    /* function returning... */
        typedef fpfpc *pfpfpc;    /* pointer to... */
        pfpfpc a[N];         /* array of... */
8. Use the cdecl program, which turns English into C and vice versa:          
        cdecl> declare a as array of pointer to function returning   pointer to function
returning pointer to char        char *(*(*a[])())()
cdecl can also explain complicated declarations, help with  casts, and indicate which
set of parentheses the arguments   go in (for complicated function definitions, like the
one   above).  Any good book on C should explain how to read these complicated   C
declarations "inside out" to understand them ("declaration mimics use"). The pointer-
to-function declarations in the examples above have not included parameter type
information. When the parameters have complicated types, declarations can *really*
get messy. (Modern versions of cdecl can help here, too.)
9. A structure pointer is defined of the type time . With 3 fields min,sec hours
having pointers to intergers.
    Write the way to initialize the 2nd element to 10.
10. In the above question an array of pointers is declared. Write the statement to
initialize the 3rd element of the 2 element to 10
11. int f()
void main()
{
  f(1);
  f(1,2);
  f(1,2,3);
}
f(int i,int j,int k)
{
  printf("%d %d %d",i,j,k);
}What are the number of syntax errors in the above?                     
Ans: None.
12. void main()
{
  int i=7;
  printf("%d",i++*i++);
}Ans: 56
13. #define one 0
#ifdef one 
printf("one is defined ");
#ifndef one
printf("one is not defined ");
Ans: "one is defined"
14. void main()
{
  intcount=10,*temp,sum=0;
  temp=&count;
  *temp=20;
  temp=&sum;
  *temp=count;
  printf("%d %d %d ",count,*temp,sum);
}
Ans: 20 20 20
15. There was question in c working only on unix machine with pattern matching.
16. what is alloca()   Ans : It allocates and frees memory after use/after getting
out of scope
17. main()
{
  static i=3;
  printf("%d",i--);
  return i>0 ? main():0;
}
Ans: 321
18. char *foo()
{
  char result[100]);
  strcpy(result,"anything is good");                                        
  return(result);
}
void main()
{
  char *j;
  j=foo()
  printf("%s",j);
}
Ans: anything is good.
19. void main()
{
  char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
  char **p;
  p=s;
  printf("%s",++*p);
  printf("%s",*p++);
  printf("%s",++*p);
}Ans: "harma" (p->add(dharma) && (*p)->harma)
"harma" (after printing, p->add(hewlett-packard) &&(*p)->harma)
"ewlett-packard"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

T
e
s
t

P
a
p
e
r

:
1
 
P
a
p
e
r

T
y
p
e
  
:
 
T
e
c
h
n
i
c
a
l

&

C
+
+

 
P
o
s
t
e
d

B
y
 
 
 
 
 
 
 

:
 
a
d
m
i
n
p
a
r
t

o
f

p
a
p
e
r
 

f
i
r
s
t

a
p
t
i
t
u
d
e

h
a
v
i
n
g

f
i
v
e

s
e
c
t
i
o
n
s

(
5
0
q
u
e
s
t
i
o
n
s

a
n
d

4
5

m
i
n
u
t
e
s
)
 

p
a
r
t

2
 

s
e
c
o
n
d

d
e
b
u
g
g
i
n
g

(
t
e
s
t

u
r

s
k
i
l
l
s

y
a
s
h
w
a
n
t

k
a
n
i
t
k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
d

h
r

q
u
e
s
t
i
o
n
s

l
i
k
e

h
o
b
b
i
e
s

a
n
d

i
n
t
e
r
e
t
s

m
a
k
e

u
r

c
u
r
r
i
c
u
l
a
m

v
i
t
e

a
n
d

b
r
i
n
g

i
t

w
i
t
h

u
r

f
i
l
e
 

t
h
e
y

w
a
n
t

p
e
o
p
l
e
w
i
t
h

g
o
o
d

a
p
t
i
t
u
d
e

i
n

i
n
t
e
r
v
i
e
w

r
o
u
n
d
s

u
r

a
p
t
i
t
u
d
e

a
n
d

a
p
p
r
o
a
c
h

m
a
t
t
e
r
s

s
o

s
o
l
v
e

p
u
z
z
l
e
s
.
 
 
 
 
E
n
t
e
r

Y
o
u
r

C
o
m
m
e
n
t
s

Test Paper :1
 Paper Type     : Technical - C & C++
 Test Date        : 7  July  2003 
 Posted By        : admin
Ubinetics Test Pattern- July 2003

20 c objective Qs to be answered in 30 minutes 


All questions  are related to basic c concepts like expression, arrays, loops ,structure , pointers
around 3 or 4 qs on array with loops 
 Since paper is very easy cutoff is very high.
They will select 20% of the student for the interview after written test. Freshersworld.com
 point to remember.
Each correct ans 1 marks
Each wrong answer 1 -ve mark  
Sample Paper         
  
Some of the questions will not have answers .Please forgive us.
  
1. Difference b/n scanf("%s",msg);and scanf("%[\^n]",msg); where msg is a char array. 
2. What is ure of comma operator in for loop.
3. int shw(int *a){
 *a = 10;
 /* return stmt is missing */
}        
  
 main(){
  
int p=3,q=4;
  
q = shw(&p);
  
printf("%d %d",p,q);            
}
  
4. which is true  
 a. all automatic variables are declared with in the function  
 b. all variables are automatic   
 c. all not declared variables are automatic   
 d. none   
5. What is recursion. Recursive prog to generate Fibonacci series . Is it a best method?   
6. write 7*a interms of +,-,<<   
7. count number of 1's in a 32 bit integer.(i had not remembered whether array or integer). 
8. main(){
char *s1 = "hello",*s2 ="abce";
strcpy(s1,"");
             s2[0] = s1[0];   
printf("%d%d",strlen(s1),strlen(s2));
 }
 9. regarding memset   
10.Algorithm to delete a node in Double linked list.   
11. Difference b/n fgets,fscanf which u will prefer.   
      Unix
11.What is creon and whats diff b/n 'at' command.   
12. what is system call and lib function. whats diff b/n them. abt execve - expalin.   
13.some thing abt makeall   
14. write abt TCP,IP,ICMP 
  Enter Your Comments
                                 

Test Paper :2
 Paper Type     : Technical - C & C++
 Posted By        : Madhav
 TRIAD 

mostly triad is only for mech guys only 

TRIAD PAPER 

C - language: 

1. write a program to calculate ncr 

2. write a program to exchange the values of two variables 


using 
pointers 

3. write program to open one file input some numbers and find 
smallest,largest, avg. and store them in another file. 

4. write a structure node using linked list 

5. write a program to reverse a string 


co-ordinate geometry 

1. find the perpendicular distance from a point P(a,b) to a 


line lx+my+n=0; 

2. y=x^3+2x^2+5x+2 find the slope of this eqn when x=12; 

( Hint :find dy/dx and substitute x=12) 

3. circle is x^2+y^2=a^2 . if the centre is shifted to (25,16) 


what 
is the eqn of new cirlce. 

4. pt rotation P(x,y) about origin in anticlockwise direction 


by an 
angle theta. find new coordinates.
before this there will be some question on puzzles(gre 
barrons). 

prepare co-ordinate geometry and fundamental of c. 

  

regarding interview : 

1.they will ask whether u r interseted to go 


 aborad, 

ans:say no, not interested. 

2. tell some project works that r done and or 


going 
 to 
be do in c , c++, 

3. personal interview. 

4. be perfect in c, they r asking that how u done 


 this 
 in test  paper. 

5.they ask u do be agree to the company bond. bond 


 is 
for 3 years , breaking is at cost of 50,000. 

  

apptitude ; 

  some puzzles r given around 9, study well it is 


 easy, 
 for it they provide 20 min00110

 
                                

Test Paper :2
 Paper Type     : Technical - C & C++

 Posted By        : Mrudul


 Elico Questions

*16 ppl can do a work in 3 hrs?, how much time vil 5 ppl take?

* 185 miles. travelled in bus for 2 hrs a dist of 85. in how much time, he need to travel the
ramaining 100 miles, if he need to get an average of 50 miles per hr.

*efface=? : similer word

* a 6 mtrs wide road is laid around a garden. rad area is 564sq mtsr. if the length of the
garden is 20 mtrs?, wat is the width of it.

*Woman said pointing to a guy " his mother is the only daughter of my mother"

* a 2 digit no, the diff of its digits is one twelth of it. Find sum of the 2 digits
-data insufficient
-6
-8
-10
-none

Cpp

* #include
main()
{
int x=20, t;
&t=x;
x=50;
cout<<x<<" "<<t;
}
o/p?

50 20
t

-----
*include<iostream.h>

int sum(int a, int b=5, int c=10);

main()
{
cout<<sum(5)<<endl<<sum(10,5)<<endl<<sum(5,10,10);
}

int sum(int a, int b, int c)


{ return a+b+c;}

ans?
20 25 25

------
* #include
main()
{
int x=20, &t;
&t=x;
int &tt;
cout<<x<<" "<<t;
}
o/p?

compile time error, as all references must b initialisded.


------

what vil deleter operator vill do?


- invoke delete operator, n then destructor
- search if any destructor, n then invoke delete operasor
.....
-------
What vil new operator vil do?

-invoke comnstructor, then new operator, then do typecasting


-invoke new operator and then constructor
-invoke constructor n do typecast
....
------
which is violating data encapsulation?
-friend
-public
-private
-protected
-virtual
-------
Friend fns are useful but r controversy bcoz,
-they violate data encapsulation
-they access private fdata of a class
-both
-none of the above
-------
which of the following is true?
//there are 4/5 q's in these format.

-a const member can't b changed


...........
-------

which of the following is false? in case of destructors, constructors


............
-------

what key word is used to off overload.


- extern "C"
-register "C"
-static "C"
-off "C"

------
A,B,C,D,E,F are 6 members, facing the center of a circle.

A is btn B , E
C btn D, f
E is immediate right to D

q's on it 
  Enter Your Comments

1]. The following variable is available in file1.c 


static int average_float; 
all the functions in the file1.c can access the variable 

[2]. extern int x; 


Check the answer

[3]. Another Problem with  


# define TRUE 0 
some code 
while(TRUE)
{
some code  

This won't go into the loop as TRUE is defined as 0 
[4]. A question in structures where the memebers are dd,mm,yy. 
mm:dd:yy
09:07:97

[5]. Another structure question  


1 Rajiv System Analyst

[6]. INFILE.DAT is copied to OUTFILE.DAT 

[7]. A question with argc and argv .  


Input will be

main()
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);

----------------------------------------------------------------------

int x;
main()
{
int x=0;
{
int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value();
printf("Third Output : %d\n",x);
}

Modify_value()
{
return (x+=10);
}

change_value()
{
return(x+=1);
}

----------------------------------------------------------------------------

main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}

----------------------------------------------------------------------- 

main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
---------------------------------------------------------------------- 
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}

--------------------------------------------------------------------

#define swap1(a,b) a=a+b;b=a-b;a=a-b;


main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}

int swap2(int a,int b)


{
int temp;
temp=a;
b=a;
a=temp;
return;
}
----------------------------------------------------------------------

main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}

---------------------------------------------------------------------

#include<stdio.h>
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}

----------------------------------------------------------------- 

#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);

                                 

Test Paper :2
 Paper Type     : Technical - C & C++
 Test Date        : 8  September  2005 
 Posted By        : Jai

TEXAS INSTRUMENTS PAPER - 08 SEP 2005


Test Paper   01

1. Can we declare a static function as virtual?


Ans: No. The virtual function mechanism is used on the specific object that determines which
virtual function to call. Since the static functions are not any way related to objects, they
cannot be declared as virtual.

2. Can user-defined object be declared as static data member of another class?


Ans: Yes. The following code shows how to initialize a user-defined object.
      #include
      class test
      {
      int i ;
      public :
      test ( int ii = 0 )
      {
      i = ii ;
      }
      } ;
      class sample
      {
      static test s ;
      } ;
      test sample::s ( 26 ) ;
Here we have initialized the object s by calling the one-argument constructor. We
can use the same convention to initialize the object by calling multiple-argument constructor.

3. What is forward referencing and when should it be used?


Ans: Consider the following program:
     class test
      {
      public :
      friend void fun ( sample, test ) ;
      } ;
      class sample
      {
      public :
      friend void fun ( sample, test ) ;
      } ;
      void fun ( sample s, test t )
      {
      // code
      }
      void main( )
      {
      sample s ;
      test t ;
      fun ( s, t ) ;
      }
This program would not compile. It gives an error that sample is undeclared identifier in the
statement friend void fun ( sample, test ) ; of the class test. This is so because the class
sample is defined below the class test and we are using it before its definition. To overcome
this error we need to give forward reference of the class sample before the definition of class
test. The following statement is the forward reference of class sample. Forward referencing is
generally required when we make a class or a function as a friend.

4. The istream_withassign class has been derived from the istream class and overloaded
assignment operator has been added to it. The _withassign classes are much like their base
classes except that they include overloaded assignment operators. Using these operators the
objects of the _withassign classes can be copied. The istream, ostream, and iostream classes
are made uncopyable by making their overloaded copy constructor and assignment operators
private.

5. How do I write my own zero-argument manipulator that should work same as hex?
Ans: This is shown in following program.
      #include
      ostream& myhex ( ostream &o )
      {
      o.setf ( ios::hex) ;
      return o ;
      }
      void main( )
      {
      cout << endl << myhex << 2000 ;
      }

6.We all know that a const variable needs to be initialized at the time of declaration. Then
how come the program given below runs properly even when we have not initialized p?
      #include
      void main( )
      {
      const char *p ;
      p = "A const pointer" ;
      cout << p ;
      }
Ans: The output of the above program is 'A const pointer'. This is because in this program p
is declared as 'const char*' which means that value stored at p will be constant and not p
and so the program works properly

7. How do I refer to a name of class or function that is defined within a namespace?


Ans: There are two ways in which we can refer to a name of class or function that is defined
within a namespace: Using scope resolution operator through the using keyword. This is
shown in following example:

      namespace name1


     {
      class sample1
      {
      // code
      } ;
      }
      namespace name2
      {
      class sample2
      {
      // code
      } ;
      }
      using namespace name2 ;
      void main( )
      {
      name1::sample1 s1 ;
      sample2 s2 ;
      }
Here, class sample1 is referred using the scope resolution operator. On the other hand we
can directly refer to class sample2 because of the statement using namespace name2 ; the
using keyword declares all the names in the namespace to be in the current scope. So we
can use the names without any qualifiers.

8. While overloading a binary operator can we provide default values?


Ans: No!. This is because even if we provide the default arguments to the parameters of the
overloaded operator function we would end up using the binary operator incorrectly. This is
explained in the following example:

      sample operator + ( sample a, sample b = sample (2, 3.5f ) )


      {
      }
      void main( )
      {
      sample s1, s2, s3 ;
      s3 = s1 + ; // error
      }

9. How do I carry out conversion of one object of user-defined type to another?


Ans: To perform conversion from one user-defined type to another we need to provide
conversion function. Following program demonstrates how to provide such conversion
function.
      class circle
      {
      private :
      int radius ;
      public:
      circle ( int r = 0 )
      {
      radius = r ;
      }
      } ;
      class rectangle
      {
      private :
      int length, breadth ;
      public :
      rectangle( int l, int b )
      {
      length = l ;
      breadth = b ;
      }
      operator circle( )
      {
      return circle ( length ) ;
      }
      } ;
      void main( )
      {
      rectangle r ( 20, 10 ) ;
      circle c;
      c = r ;
      }
Here, when the statement c = r ; is executed the compiler searches for an overloaded
assignment operator in the class circle which accepts the object of type rectangle. Since
there is no such overloaded assignment operator, the conversion operator function that
converts the rectangle object to the circle object is searched in the rectangle class. We have
provided such a conversion function in the rectangle class. This conversion operator function
returns a circle object. By default conversion operators have the name and return type same
as the object type to which it converts to. Here the type of the object is circle and hence the
name of the operator function as well as the return type is circle.

10. How do I write code that allows to create only one instance of a class?
Ans: This is shown in following code snippet.

      #include
      class sample
      {
      static sample *ptr ;
      private:
      sample( )
      {
      }
      public:
      static sample* create( )
      {
      if ( ptr == NULL )
      ptr = new sample ;
      return ptr ;
      }
      } ;
      sample *sample::ptr = NULL ;
      void main( )
      {
      sample *a = sample::create( ) ;
      sample *b = sample::create( ) ;
      }
Here, the class sample contains a static data member ptr, which is a pointer
to the object of same class. The constructor is private which avoids us from creating objects
outside the class. A static member function called create( ) is used to create an object of the
class. In this function the condition is checked whether or not ptr is NULL, if it is then an
object is created dynamically and its address collected in ptr is returned. If ptr is not NULL,
then the same address is returned. Thus, in main( ) on execution of the first statement one
object of sample gets created whereas on execution of second statement, b holds the
address of the first object. Thus, whatever number of times you call create( ) function, only
one object of sample class will be available.

11. How do I write code to add functions, which would work as get and put properties of a
class?
Ans: This is shown in following code.
      #include
      class sample
      {
      int data ;
      public:
      __declspec ( property ( put = fun1, get = fun2 ) )
      int x ;
      void fun1 ( int i )
      {
      if ( i < 0 )
      data = 0 ;
      else
      data = i ;
      }
      int fun2( )
      {
      return data ;
      }
      } ;
      void main( )
      {
      sample a ;
      a.x = -99 ;
      cout << a.x ;
      }
Here, the function fun1( ) of class sample is used to set the given integer value into data,
whereas fun2( ) returns the current value of data. To set these functions as properties of a
class we have given the statement as shown below:
__declspec ( property ( put = fun1, get = fun2 )) int x ;

As a result, the statement a.x = -99 ; would cause fun1( ) to get called to set the value in
data. On the other hand, the last statement would cause fun2( ) to get called to return the
value of data.

12. How do I write code to make an object work like a 2-D array?
Ans: Take a look at the following program.
      #include
      class emp
      {
      public :
      int a[3][3] ;
      emp( )
      {
      int c = 1 ;
      for ( int i = 0 ; i <= 2 ; i++ )
      {
      for ( int j = 0 ; j <= 2 ; j++ )
      {
      a[i][j] = c ;
      c++ ;
      }
      }
      }
      int* operator[] ( int i )
      {
      return a[i] ;
      }
      } ;
      void main( )
      {
      emp e ;
      cout << e[0][1] ;
      }
The class emp has an overloaded operator [ ] function. It takes one argument an integer
representing an array index and returns an int pointer. The statement cout << e[0][1] ;
would get converted into a call to the overloaded [ ] function as e.operator[ ] ( 0 ). 0 would
get collected in i. The function would return a[i] that represents the base address of the
zeroeth row. Next the statement would get expanded as base address of zeroeth row[1] that
can be further expanded as *( base address + 1 ). This gives us a value in zeroth row and
first column.

13. What are formatting flags in ios class?


Ans: The ios class contains formatting flags that help users to format the stream data.
Formatting flags are a set of enum definitions. There are two types of formatting flags:
      On/Off flags
      Flags that work in-group
The On/Off flags are turned on using the setf( ) function and are turned off using the
unsetf( ) function. To set the On/Off flags, the one argument setf( ) function is used. The
flags working in groups are set through the two-argument setf( ) function. For example, to
left justify a string we can set the flag as,
      cout.setf ( ios::left ) ;
      cout << "KICIT Nagpur" ;
      To remove the left justification for subsequent output we can say,
      cout.unsetf ( ios::left ) ;
The flags that can be set/unset include skipws, showbase, showpoint,
uppercase, showpos, unitbuf and stdio. The flags that work in a group can have only one of
these flags set at a time.

14. What is the purpose of ios::basefield in the following statement?


      cout.setf ( ios::hex, ios::basefield ) ;
Ans: This is an example of formatting flags that work in a group. There is a flag for each
numbering system (base) like decimal, octal and hexadecimal. Collectively, these flags are
referred to as basefield and are specified by ios::basefield flag. We can have only one of
these flags on at a time. If we set the hex flag as setf ( ios::hex ) then we will set the hex bit
but we won't clear the dec bit resulting in undefined behavior. The solution is to call setf( ) as
setf ( ios::hex, ios::basefield ). This call first clears all the bits and then sets the hex bit.

15. Can we get the value of ios format flags?


Ans: Yes! The ios::flags( ) member function gives the value format flags. This function takes
no arguments and returns a long ( typedefed to fmtflags) that contains the current format
flags.

16. Is there any function that can skip certain number of characters present in the input
stream?
Ans: Yes! This can be done using cin::ignore( ) function. The prototype of this function is as
shown below:
      istream& ignore ( int n = 1, int d =EOF ) ;
Sometimes it happens that some extra characters are left in the input stream while taking
the input such as, the ?\n? (Enter) character. This extra character is then passed to the next
input and may pose problem.

To get rid of such extra characters the cin::ignore( ) function is used. This is equivalent to
fflush ( stdin ) used in C language. This function ignores the first n characters (if present) in
the input stream, stops if delimiter d is encountered.

17. Write a program that implements a date class containing day, month and year as data
members. Implement assignment operator and copy constructor in this class.
Ans: This is shown in following program:
      #include
      class date
      {
      private :
      int day ;
      int month ;
      int year ;
      public :
      date ( int d = 0, int m = 0, int y = 0 )
      {
      day = d ;
      month = m ;
      year = y ;
      }
      // copy constructor
      date ( date &d )
      {
      day = d.day ;
      month = d.month ;
      year = d.year ;
      }
      // an overloaded assignment operator
      date operator = ( date d )
      {
      day = d.day ;
      month = d.month ;
      year = d.year ;
      return d ;
      }
      void display( )
      {
      cout << day << "/" << month << "/" << year ;
      }
      } ;
      void main( )
      {
      date d1 ( 25, 9, 1979 ) ;
      date d2 = d1 ;
      date d3 ;
      d3 = d2 ;
      d3.display( ) ;
      }
18. When should I use unitbuf flag?
Ans: The unit buffering (unitbuf) flag should be turned on when we want to ensure that each
character is output as soon as it is inserted into an output stream. The same can be done
using unbuffered output but unit buffering provides a better performance than the
unbuffered output.

19.What are manipulators?


Ans: Manipulators are the instructions to the output stream to modify the output in various
ways. The manipulators provide a clean and easy way for formatted output in comparison to
the formatting flags of the ios class. When manipulators are used, the formatting instructions
are inserted directly into the stream. Manipulators are of two types, those that take an
argument and those that don?t.

20. What is the difference between the manipulator and setf( ) function?
Ans: The difference between the manipulator and setf( ) function are as follows:

The setf( ) function is used to set the flags of the ios but manipulators directly insert the
formatting instructions into the stream. We can create user-defined manipulators but setf( )
function uses data members of ios class only. The flags put on through the setf( ) function
can be put off through unsetf( ) function. Such flexibility is not available with manipulators.

21. How do I get the current position of the file pointer?


Ans: We can get the current position of the file pointer by using the tellp( ) member function
of ostream class or tellg( ) member function of istream class. These functions return (in
bytes) positions of put pointer and get pointer respectively.

22. What are put and get pointers?


Ans: These are the long integers associated with the streams. The value present in the put
pointer specifies the byte number in the file from where next write would take place in the
file. The get pointer specifies the byte number in the file from where the next reading should
take place.

23. What do the nocreate and noreplace flag ensure when they are used for opening a file?
Ans: nocreate and noreplace are file-opening modes. A bit in the ios class defines these
modes. The flag nocreate ensures that the file must exist before opening it. On the other
hand the flag noreplace ensures that while opening a file for output it does not get
overwritten with new one unless ate or app is set. When the app flag is set then whatever we
write gets appended to the existing file. When ate flag is set we can start reading or writing
at the end of existing file.

24. What is the limitation of cin while taking input for character array?
Ans: To understand this consider following statements,
      char str[5] ;
      cin >> str ;
While entering the value for str if we enter more than 5 characters then there is no provision
in cin to check the array bounds. If the array overflows, it may be dangerous. This can be
avoided by using get( ) function. For example, consider following statement,
      cin.get ( str, 5 ) ;
On executing this statement if we enter more than 5 characters, then get( ) takes only first
five characters and ignores rest of the characters. Some more variations of get( ) are
available, such as shown below:
      get ( ch ) ? Extracts one character only
      get ( str, n ) ? Extracts up to n characters into str
      get ( str, DELIM ) ? Extracts characters into array str until specified delimiter (such as
'\n'). Leaves delimiting character in stream.
      get ( str, n, DELIM ) ? Extracts characters into array str until n characters or DELIM
character, leaving delimiting character in stream.

25. What is the purpose of istream class? 


Ans: The istream class performs activities specific to input. It is derived from the ios class.
The most commonly used member function of this class is the overloaded >> operator which
can extract values of all basic types. We can extract even a string using this operator.

26. Would the following code work?


      #include
      void main( )
      {
      ostream o ;
      o << "Dream. Then make it happen!" ;
      }
Ans: No! This is because we cannot create an object of the ostream class since its
constructor and copy constructor are declared private.

27. Can we use this pointer inside static member function?


Ans: No! The this pointer cannot be used inside a static member function. This is because a
static member function is never called through an object.

28. What is strstream?


Ans: strstream is a type of input/output stream that works with the memory. It allows using
section of the memory as a stream object. These streams provide the classes that can be
used for storing the stream of bytes into memory. For example, we can store integers, floats
and strings as a stream of bytes. There are several classes that implement this in-memory
formatting. The class ostrstream derived from ostream is used when output is to be sent to
memory, the class istrstream derived from istream is used when input is taken from memory
and strstream class derived from iostream is used for memory objects that do both input and
output.  Ans: When we want to retrieve the streams of bytes from memory we can use
istrestream. The following example shows the use of istrstream class.
      #include
      void main( )
      {
      int age ;
      float salary ;
      char name[50] ;
      char str[] = "22 12004.50 K. Vishwanatth" ;
      istrstream s ( str ) ;
      s >> age >> salary >> name ;
      cout << age << endl << salary << endl << name ;
      cout << endl << s.rdbuf( ) ;
      }
Here, s is the object of the class istrstream. When we are creating the object s, the
constructor of istrstream gets called that receives a pointer to the zero terminated character
array str. The statement s >> age >> salary >> name ; extracts the age, salary and the
name from the istrstream object s. However, while extracting the name, only the first word
of name gets extracted. The balance is extracted using rdbuf( ).

29. When the constructor of a base class calls a virtual function, why doesn't the override
function of the derived class gets called?
Ans: While building an object of a derived class first the constructor of the base class and
then the constructor of the derived class gets called. The object is said an immature object at
the stage when the constructor of base class is called. This object will be called a matured
object after the execution of the constructor of the derived class. Thus, if we call a virtual
function when an object is still immature, obviously, the virtual function of the base class
would get called. This is illustrated in the following example.
      #include
      class base
      {
      protected :
      int i ;
      public :
      base ( int ii = 0 )
      {
      i = ii ;
      show( ) ;
      }
      virtual void show( )
      {
      cout << "base's show( )" << endl ;
      }
      } ;
      class derived : public base
      {
      private :
      int j ;
      public :
      derived ( int ii, int jj = 0 ) : base ( ii )
      {
      j = jj ;
      show( ) ;
      }
      void show( )
      {
      cout << "derived's show( )" << endl ;
      }
      } ;

      void main( )


      {
      derived dobj ( 20, 5 ) ;
      }
      The output of this program would be:
      base's show( )
      derived's show( )

30. Can I have a reference as a data member of a class? If yes, then how do I initialise it?
Ans: Yes, we can have a reference as a data member of a class. A reference as a data
member of a class is initialized in the initialization list of the constructor. This is shown in
following program.
      #include
      class sample
      {
      private :
      int& i ;
      public :
      sample ( int& ii ) : i ( ii )
      {
      }
      void show( )
      {
      cout << i << endl ;
      }
      } ;
      void main( )
      {
      int j = 10 ;
      sample s ( j ) ;
      s.show( ) ;
      }
Here, i refers to a variable j allocated on the stack. A point to note here is that we cannot
bind a reference to an object passed to the constructor as a value. If we do so, then the
reference i would refer to the function parameter (i.e. parameter ii in the constructor), which
would disappear as soon as the function returns, thereby creating a situation of dangling
reference.

31. Why does the following code fail?


      #include
      class sample
      {
      private :
      char *str ;
      public :
      sample ( char *s )
      {
      strcpy ( str, s ) ;
      }
      ~sample( )
      {
      delete str ;
      }
      } ;
      void main( )
      {
      sample s1 ( "abc" ) ;
      }
Ans: Here, through the destructor we are trying to deal locate memory, which has been
allocated statically. To remove an exception, add following statement to the constructor.
      sample ( char *s )
      {
      str = new char[strlen(s) + 1] ;
      strcpy ( str, s ) ;
      }
Here, first we have allocated memory of required size, which then would get deal located
through the destructor.

32. assert( ) macro...


We can use a macro called assert( ) to test for conditions that should not occur in a code.
This macro expands to an if statement. If test evaluates to 0, assert prints an error message
and calls abort to abort the program.
      #include
      #include
      void main( )
      {
      int i ;
      cout << "\nEnter an integer: " ;
      cin >> i ;
      assert ( i >= 0 ) ;
      cout << i << endl ;
      }

33. Why it is unsafe to deal locate the memory using free( ) if it has been
allocated using new?
Ans: This can be explained with the following example:
      #include
      class sample
      {
      int *p ;
      public :
      sample( )
      {
      p = new int ;
      }
      ~sample( )
      {
      delete p ;
      }
      } ;
      void main( )
      {
      sample *s1 = new sample ;
      free ( s1 ) ;
      sample *s2 = ( sample * ) malloc ( sizeof ( sample ) ) ;
      delete s2 ;
      }
The new operator allocates memory and calls the constructor. In the constructor we have
allocated memory on heap, which is pointed to by p. If we release the object using the
free( ) function the object would die but the memory allocated in the constructor would leak.
This is because free( ) being a C library function does not call the destructor where we have
deal located the memory.

As against this, if we allocate memory by calling malloc( ) the constructor would not get
called. Hence p holds a garbage address. Now if the memory is deal located using delete, the
destructor would get called where we have tried to release the memory pointed to by p.
Since p contains garbage this may result in a runtime error.

34. Can we distribute function templates and class templates in object libraries?
Ans: No! We can compile a function template or a class template into object code (.obj file).
The code that contains a call to the function template or the code that creates an object from
a class template can get compiled. This is because the compiler merely checks whether the
call matches the declaration (in case of function template) and whether the object definition
matches class declaration (in case of class template). Since the function template and the
class template definitions are not found, the compiler leaves it to the linker to restore this.
However, during linking, linker doesn't find the matching definitions for the function call or a
matching definition for object creation. In short the expanded versions of templates are not
found in the object library. Hence the linker reports error.

35. What is the difference between an inspector and a mutator ?


Ans: An inspector is a member function that returns information about an object's state
(information stored in object's data members) without changing the object's state. A mutator
is a member function that changes the state of an object. In the class Stack given below we
have defined a mutator and an inspector.
      class Stack
      {
      public :
      int pop( ) ;
      int getcount( ) ;
      }
In the above example, the function pop( ) removes top element of stack thereby changing
the state of an object. So, the function pop( ) is a mutator. The function getcount( ) is an
inspector because it simply counts the number of elements in the stack without changing the
stack.

36. Namespaces:
The C++ language provides a single global namespace. This can cause problems with global
name clashes. For instance, consider these two C++ header files:
      // file1.h
      float f ( float, int ) ;
      class sample { ... } ;
      // file2.h
      class sample { ... } ;
With these definitions, it is impossible to use both header files in a single program; the
sample classes will clash. A namespace is a declarative region that attaches an additional
identifier to any names declared inside it. The additional identifier thus avoids the possibility
that a name will conflict with names declared elsewhere in the program. It is possible to use
the same name in separate namespaces without conflict even if the names appear in the
same translation unit. As long as they appear in separate namespaces, each name will be
unique because of the addition of the namespace identifier. For example:
     // file1.h
      namespace file1
      {
      float f ( float, int ) ;
      class sample { ... } ;
      }
      // file2.h
      namespace file2
      {
      class sample { ... } ;
      }

Now the class names will not clash because they become file1::sample and file2::sample,
respectively.

37. What would be the output of the following program?


      #include
      class user
      {
      int i ;
      float f ;
      char c ;
      public :
      void displaydata( )
      {
      cout << endl << i << endl << f << endl << c ;
      }
      } ;
      void main( )
      {
      cout << sizeof ( user ) ;
      user u1 ;
      cout << endl << sizeof ( u1 ) ;
      u1.displaydata( ) ;
      }
Ans: The output of this program would be,
      9 or 7
      9 or 7
      Garbage
      Garbage
      Garbage
Since the user class contains three elements, int, float and char its size would be 9 bytes
(int-4, float-4, char-1) under Windows and 7 bytes (int-2, float-4, char-1) under DOS.
Second output is again the same because u1 is an object of the class user. Finally three
garbage values are printed out because i, f and c are not initialized anywhere in the program.

Note that if you run this program you may not get the answer shown here. This is because
packing is done for an object in memory to increase the access efficiency. For example,
under DOS, the object would be aligned on a 2-byte boundary. As a result, the size of the
object would be reported as 6 bytes. Unlike this, Windows being a 32-bit OS the object would
be aligned on a 4-byte boundary. Hence the size of the object would be reported as 12 bytes.
To force the alignment on a 1-byte boundary, write the following statement before the class
declaration.
     #pragma pack ( 1 )

38. Write a program that will convert an integer pointer to an integer and vice-versa. 
Ans: The following program demonstrates this.
      #include
      void main( )
      {
      int i = 65000 ;
      int *iptr = reinterpret_cast ( i ) ;
      cout << endl << iptr ;
      iptr++ ;
      cout << endl << iptr ;
      i = reinterpret_cast ( iptr ) ;
      cout << endl << i ;
      i++ ;
      cout << endl << i ;
      }

39. What is a const_cast?


Ans. The const_cast is used to convert a const to a non-const. This is shown in the following
      program:
      #include
      void main( )
      {
      const int a = 0 ;
      int *ptr = ( int * ) &a ; //one way
      ptr = const_cast_ ( &a ) ; //better way
      }
Here, the address of the const variable a is assigned to the pointer to a non-const variable.
The const_cast is also used when we want to change the data members of a class inside the
const member functions. The following code snippet shows this:
      class sample
      {
      private:
      int data;
      public:
      void func( ) const
      {
      (const_cast (this))->data = 70 ;
      }
      };

40. What is forward referencing and when should it be used?


Ans: Forward referencing is generally required when we make a class or a function as a
friend.
Consider following program:
      class test
      {
      public:
      friend void fun ( sample, test ) ;
      } ;
      class sample
      {
      public:
      friend void fun ( sample, test ) ;
      } ;
      void fun ( sample s, test t )
      {
      // code
      }
      void main( )
      {
      sample s ;
      test t ;
      fun ( s, t ) ;
      }
On compiling this program it gives error on the following statement of test class. It gives an
error that sample is undeclared identifier. friend void fun ( sample, test );
This is so because the class sample is defined below the class test and we are using it before
its definition. To overcome this error we need to give forward reference of the class sample
before the definition of class test. The following statement is the forward reference of class
sample.
      class sample ;

41. How would you give an alternate name to a namespace?


Ans: An alternate name given to namespace is called a namespace-alias. namespace-alias is
generally used to save the typing effort when the names of namespaces are very long or
complex. The following syntax is used to give an alias to a namespace.
      namespace myname = my_old_very_long_name ;

42. Using a smart pointer can we iterate through a container?


Ans: Yes. A container is a collection of elements or objects. It helps to properly organize and
store the data. Stacks, linked lists, arrays are examples of containers. Following program
shows how to iterate through a container using a smart pointer.
      #include
      class smartpointer
      {
      private :
      int *p ; // ordinary pointer
      public :
      smartpointer ( int n )
      {
      p = new int [ n ] ;
      int *t = p ;
      for ( int i = 0 ; i <= 9 ; i++ )
      *t++ = i * i ;
      }
      int* operator ++ ( int )
      {
      return p++ ;
      }
      int operator * ( )
      {
      return *p ;
      }
      } ;
      void main( )
      {
      smartpointer sp ( 10 ) ;
      for ( int i = 0 ; i <= 9 ; i++ )
      cout << *sp++ << endl ;
      }
Here, sp is a smart pointer. When we say *sp, the operator * ( ) function gets called. It
returns the integer being pointed to by p. When we say sp++ the operator ++ ( ) function
gets called. It increments p to point to The next element in the array and then returns the
address of this new location.

43. Can objects read and write themselves?


Ans: Yes! This can be explained with the help of following example:
      #include
      #include
      class employee
      {
      private :
      char name [ 20 ] ;
      int age ;
      float salary ;
      public :
      void getdata( )
      {
      cout << "Enter name, age and salary of employee : " ;
      cin >> name >> age >> salary ;
      }
      void store( )
      {
      ofstream file ;
      file.open ( "EMPLOYEE.DAT", ios::app | ios::binary ) ;
      file.write ( ( char * ) this, sizeof ( *this ) ) ;
      file.close( ) ;
      }
      void retrieve ( int n )
      {
      ifstream file ;
      file.open ( "EMPLOYEE.DAT", ios:

 
1. Which of the following best explains life cycle of Defect ?

 a) Defect Found -> Defect Logged -> Defect Debugged -> Defect Closed -> Defect
Rechecked 

 b) Defect Found -> Defect Debugged -> Defect Reported -> Defect Rechecked ->
DefectClosed

 c) Defect Debugged -> Defect Found -> Defect Closed -> Defect Reported ->
DefectRechecked

 d) Defect Found -> Defect Logged -> Defect Debugged -> Defect Rechecked ->
Defect Closed

2. Which group does Winrunner ,Load Runner ,SQA Suite fall under ?

  a) Databases

  b) Automated Test Tools

  c) Operating Systems

  d) Rapid Application Development Tool


3.  i = 0;

j = 0;

for(j=1;j<10;j++)

i=i+1; 
In the (generic) code segment above what will be the value of the variable i at
completion ?

    a) 0

    b) 1

    c) 3

    d) 9
4. Which of the following statements is true when a derivation inherits both a virtual and
non-virtual instance of a base class ?

    a) Each derived class object has base objects only from the non virtual instance

    b) Each base class object has derived objects only from the non-virtual instance 

    c) Each derived class object has base objects only from the virtual instance

    d) Each derived class object has a base object from the virtual instance and a base
object from non-virtual instance.
5.  class Word

    {

     public: 

     Word(const char*,int = 0);


  };

Referring to the sample code above what is the minimum number of arguments
required to call the constructor ?

    a) 0

    b) 1

    c) 2

    d) 3
6. Which one of the following represents a correct and safe declaration of NULL ?

a) typedef((void *)0) NULL;

b) typedef NULL(char *)0;

c) #define NULL((void *)0)

d) #define NULL((char*)0)
7. #include <iostraem>

Referring to the sample code above ,which of the following could you use to make the
standars I/O Stream classes accessible without requiring the scope resolution operator
?

  a) using namespace std::iostream

  b) using namespace std;

  c) using namespace iostream ;

  d) using iostream;
8. Which one of the following statements allocates enough space to hold an array of 10
integers that are initialized to 0 ?

  a) int *ptr = (int *) calloc(10,sizeof(int));

  b) int *ptr = (int *) alloc( 10*sizeof(int));

  c) int *ptr = (int *) malloc( 10*sizeof(int));

  d) int *ptr = (int *)calloc(10*sizeof(int));


9. What function will read a specified number of elements from a file ?

  a) fread()

  b) readfile()

  c) fileread()

  d) gets()
10. What is the largest value an integer can hold in a Standard C compiler ?

  a) 32767
  b) 65536

  c) 2147483647

  d) INT_MAX
11. With every use of memory allocation function should be used to release allocated
memory which is no longer needed ?

  a) dropmem()

  b) dealloc()

  c) release()

  d) free()
12.  int a=1;

 int ab=4;

 int main()

    {

     int b=3,a=2;

     printf("%i*/%i*/%*/i",a,b,ab); 

   }
13.  kernal execute the first process when system is start---

 ans :- init();
14. process id of kernal

  (a) 1

  (b) 0

  (c) 2

  (d) none
15.  Which one of the following represents a correct and safe declaration of NULL ?

  a) typedef((void *)0) NULL;

  b) typedef NULL(char *)0;

  c) #define NULL((void *)0)

  d) #define NULL((char*)0)
16. Which one of the following statements allocates enough space to hold an array of 10
integers that are initialized to 0 ?

  a) int *ptr = (int *) calloc(10,sizeof(int));

  b) int *ptr = (int *) alloc( 10*sizeof(int));

  c) int *ptr = (int *) malloc( 10*sizeof(int));

  d) int *ptr = (int *)calloc(10*sizeof(int));.


After written ,group discussion and interview will be there

Topics for group discussion:

1. Is IT sector made a difference to rural India.


2. Does the world need army?
3. are there stars in the sky?
4. capital punishment should be avoided .
5. Is India really shining ?

 Directions: Each of the following question has a question and two statements labelled as (i)
and (ii). Use the data/information given in (i) and (ii) to decide whether the data are sufficient
to answer the question record your answer as

A) If you can get the answer from (1)alone but not from (2)
B) If you can get the answer from (2)alone but not from (1)
C) If can get the answer from (1)and (2)together ,although neither statement by
itself suffice
D) If statement (1)alone suffices and statement (2) alone also suffice.
E) If can't get the answer from statements (1) and (2) together and you need more
data.

1. What will be the population of city X in 1991?


1) Population of the city has 55% annual growth rate
2) in 1991,the population of city X was 8 million
Ans:C
2. Was it Rani's birthday yesterday?
1)Lata spends Rs.100 on Rani's birthday
2)Lata spent Rs.100 yesterdayAns: E

3. Is 3*5 or is 4*6 greater ?


1) a*b =b*a 
2) a*b is the remainder of ab%(a+b)
Ans:B

4. Will the graph X-Y pass through the origin?


1) x proportional to the Y
2)increment in y per units rise of x is fixed.
Ans:E

5. What was the value of the machine 2 years ago?

1) the deprecition of the value of the machine per year is 10%


2)present value of the machine is rs 8000/

Ans:C

6. What will be the area of a square that can be inscribed in a circle?


1) Radius of the circle is T
2) Length of a diagonal of the square is 2r
Ans:D
7. There are two figures viz., a circle and a square. Which having greater area?
1) Perimeter of the circle is the same as the perimeter of the square.
2) Eleven times the radius is equal to seven times the length of one side of the square.
Ans: D

8. A candidate who was found to be under weightin medical test had been selected
provisionally subject to his attainment of 60Kg weight within one year. What should be
the percentage increase of his weightso that selection is confirmed after one year.
1) Weight (Kg)=16+8 Height (ft) is standard equation for the Indian population. The
candidates height is 5.5
2) His present weight is 55Kg.
Ans: D

9. Is angle µ=90
1) sin**2(µ)+cos**2(µ)=1
2) sin**2(µ)-+cos**2(µ)=1
Ans: E

10. What will be the average age of workers of an Institution after two years?
1) Present average age is 35 years
2) There are total 20 workers in the Institution                                     
 Ans: A

11. Is AB>AM ( A Triangle is given )


1) AB<AC
2) M is any point other than B and C on BC
Ans: E

12. Is X^2+Y^2<X+Y?
1) 0<X<1
2) 0<Y<1 and X!=Y (X not equal to Y)
Ans: C

13. Can it be concluded that angle ABO = angle ODC


1) ABCD is a Parallelogram and O is the point of intersection of the diagonals.
2) Angle DOC =75deg. and angle DAO =35deg.
Ans: A

14. What is the value of x+y?


1) 2y=x+6
2) 5x=10y-30
Ans: E

15. How many students are there in the class?


1) 30 students play foot ball and 40 play cricket .
2)Each student plays either foot ball or cricket or both.
Ans: E

16. What is the value of a:b?


1) a=x+10%ofx
2) b=a+10%ofa
Ans: B

17. What is the maximum value of the expression 5+8x-8x^2?


1) x is real
2) x is not positive
Ans: C

18. What will be the value of the greatest angle of the triangle ABC?
1) Angles of the triangle are in the ration 2:5:3
2) The side opposite to the greatest angle is the longest side.
Ans: A

19. What is the range of values of x?


1)( x-2 ) / ( 2x + 5 ) < 1/3
2)2x /3 + 17/3 > 3x - 20
Ans: D

20. Of the two which one is the greater -- -3/x , -3/y?


1)      x,y>0 <![endif]>

 Technical Questions

21. Find the output for the following C program

main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
Ans. An empty string

22. Find the output for the following C program


main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}
Ans. 57 94
23. Find the output for the following C program
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
Ans. 5 20 1

24. Find the output for the following C program


#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}

Ans. 10 5

25. Find the output for the following C program


main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
Ans. Samco Systems
26. Find the output for the following C program
#include<stdio.h>
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}

Ans. Compilation error giving it cannot be an modifiable 'lvalue'

27. Find the output for the following C program


#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
Ans. RamcoSystems
28. Find the output for the following C program given that
[1]. The following variable is available in file1.c
static int average_float;
Ans. All the functions in the file1.c can access the variable

29. Find the output for the following C program

# define TRUE 0
some code
while(TRUE)
{
some code 
}

Ans. This won't go into the loop as TRUE is defined as 0

30. Find the output for the following C program


main()
{
int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value(x);
printf("Third Output : %d\n",x);
}
Modify_value()
{
return (x+=10);
}
change_value()
{
return(x+=1);
}
Ans. 12 1 1
31. Find the output for the following C program

main()
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
Ans. 11 16

32. Find the output for the following C programmain()


{
int a=0;
if(a=0) printf("Ramco Systems\n");
printf("Ramco Systems\n");
}
Ans. Ony one time "Ramco Systems" will be printed
33. Find the output for the following C program
#include<stdio.h>
int SumElement(int *,int);
void main(void)
{
int x[10];
int i=10;
for(;i;)
{
i--;
*(x+i)=i;
}
printf("%d",SumElement(x,10));
}
int SumElement(int array[],int size)
{
int i=0;
float sum=0;
for(;i<size;i++)
sum+=array[i];
return sum;
}

34. Find the output for the following C program


#include<stdio.h>
void main(void);
int printf(const char*,...);
void main(void)
{
int i=100,j=10,k=20;
-- int sum;
float ave;
char myformat[]="ave=%.2f";
sum=i+j+k;
ave=sum/3.0;
printf(myformat,ave);
}

35. Find the output for the following C program


#include<stdio.h>
void main(void);
{
int a[10];
printf("%d",((a+9) + (a+1)));
}

36. Find the output for the following C program


#include<stdio.h>
void main(void)
{
struct s{
int x;
float y;
}s1={25,45.00};
union u{
int x;
float y;
} u1;
u1=(union u)s1;
printf("%d and %f",u1.x,u1.y);
}
37. Find the output for the following C program
#include<stdio.h>
void main(void)
{
unsigned int c;
unsigned x=0x3;
scanf("%u",&c);
switch(c&x)
{
case 3: printf("Hello!\t");
case 2: printf("Welcome\t");
case 1: printf("To All\t");
default:printf("\n");
}
}

38. Find the output for the following C program


#include<stdio.h>
int fn(void);
void print(int,int(*)());
int i=10;
void main(void)
{
int i=20;
print(i,fn);
}
void print(int i,int (*fn1)())
{
printf("%d\n",(*fn1)());
}
int fn(void)
{
return(i-=5);
}

39. Find the output for the following C program


#include<stdio.h>
void main(void);
{
char numbers[5][6]={"Zero","One","Two","Three","Four"};
printf("%s is %c",&numbers[4][0],numbers[0][0]);
}

40. Find the output for the following C program


int bags[5]={20,5,20,3,20};
void main(void)
{
int pos=5,*next();
*next()=pos;
printf("%d %d %d",pos,*next(),bags[0]);
}
int *next()
{
int i;
for(i=0;i<5;i++)
if (bags[i]==20)
return(bags+i);
printf("Error!");
exit(0);
}

41. Find the output for the following C program


#include<stdio.h>
void main(void)
{
int y,z;
int x=y=z=10;
int f=x;
float ans=0.0;
f *=x*y;
ans=x/3.0+y/3;
printf("%d %.2f",f,ans);
}

42. Find the output for the following C program


#include<stdio.h>
void main(void);
{
double dbl=20.4530,d=4.5710,dblvar3;
double dbln(void);
dblvar3=dbln();
printf("%.2f\t%.2f\t%.2f\n",dbl,d,dblvar3);
}
double dbln(void)
{
double dblvar3;
dbl=dblvar3=4.5;
return(dbl+d+dblvar3);
}

43. Find the output for the following C program


#include<stdio.h>
static int i=5;
void main(void)
{
int sum=0;
do
{
sum+=(1/i);
}while(0<i--);
}

44. Find the output for the following C program


#include<stdio.h>
void main(void)
{
int oldvar=25,newvar=-25;
int swap(int,int);
swap(oldvar,newvar);
printf("Numbers are %d\t%d",newvar,oldvar);
}
int swap(int oldval,int newval)
{
int tempval=oldval;
oldval=newval;

newval=tempval;
}

45. Find the output for the following C program


#include<stdio.h>
void main(void);
{
int i=100,j=20;
i++=j;
i*=j;
printf("%d\t%d\n",i,j);
}
46. Find the output for the following C program
#include<stdio.h>
void main(void);
int newval(int);
void main(void)
{
int ia[]={12,24,45,0};
int i;
int sum=0;
for(i=0;ia[i];i++)
{
sum+=newval(ia[i]);
}
printf("Sum= %d",sum);
}
int newval(int x)
{
static int div=1;
return(x/div++);
}

47. Find the output for the following C program


#include<stdio.h>
void main(void);
{
int var1,var2,var3,minmax;
var1=5;
var2=5;
var3=6;
minmax=(var1>var2)?(var1>var3)?var1:var3:(var2>var3)?var2:var3;
printf("%d\n",minmax);

48. Find the output for the following C program


#include<stdio.h>
void main(void);
{
void pa(int *a,int n);
int arr[5]={5,4,3,2,1};
pa(arr,5);
}
void pa(int *a,int n)
{
int i;
for(i=0;i<n;i++)
printf("%d\n",*(a++)+i);
}

49. Find the output for the following C program


#include<stdio.h>
void main(void);
void print(void);
{
print();
}
void f1(void)
{
printf("\nf1():");
}
50. Find the output for the following C program
#include "6.c"
void print(void)
{
extern void f1(void);
f1();
}
static void f1(void)
{
printf("\n static f1().");
}

51. Find the output for the following C program


#include<stdio.h>
void main(void);
static int i=50;
int print(int i);
void main(void)
{
static int i=100;
while(print(i))
{
printf("%d\n",i);
i--;
}
}
int print(int x)
{
static int i=2;
return(i--);
}

52. Find the output for the following C program


#include<stdio.h>
void main(void);
typedef struct Ntype
{
int i;
char c;
long x;
} NewType;
void main(void)
{
NewType *c;
c=(NewType *)malloc(sizeof(NewType));
c->i=100;
c->c='C';
(*c).x=100L;
printf("(%d,%c,%4Ld)",c->i,c->c,c->x);
}

53. Find the output for the following C program


#include<stdio.h>
void main(void);
const int k=100;
void main(void)
{
int a[100];
int sum=0;
for(k=0;k<100;k++)
*(a+k)=k;
sum+=a[--k];
printf("%d",sum);
}

                                 

Test Paper :2
 Paper Type     : Technical - C & C++

 Posted By        : admin


DSQ PAPER 

Techanical paper

Questions 1 -5 are reference to the followig psedo code


{
input m,n,z
TEST:if ((m+n)/3&gt;5)z=z+1 else z =z-1
printf m,n,z
{
(m-m+1;n=n-3)
if (m+n+2)&gt;14 then goto test
print m,n,z
end
}
1. what is the final output of the if the input is 2,14,12 (m,n,z)
a)1,8,4 b)1,4,8 c)4,8,1 d)8,4,2
ans=C.

2. what is the final output if the input is 1,18,2? (m,n,z)


ans) 5,6,2 i.e ans =c.
3. How many times is TEST execute ed if the input is 2,14,1?
ans) twice ans=c.

4) How many times the TEST exected if the input is 1,18,2?


ans)four times 
5) what are the values taken by Z when input being 8,24,1?
a)only 5 b)only 6 c)neither 5 or 6 d)both 5 and 6
ans)D.

6) the function f(x) is defined as follows


if x=0 then f(x) =1
if x&gt;0 then if ((x&gt;10)then f(x) =x-10 else f(x) =x+1))
if x&lt;0 then if (x**2 &lt;100) then f(x) =f(-x+1) else f(x) =f(-(x+1)) 
6) the above of f(2) +f(-3) is
ans=8.
7) the value of f(8)+f(9) is
ans=20
8) the value of f(1)+f(2)+f(3).............+f(10) is
ans=65
9) the value of f(-10)+f(-9)+f(-8) is 
a) 33 b)25 c)-27 d)27

11. 1997 haeadecimal is 


a)7cb b)7cd c)7cf d)7ca 
ans-c

12. the remainder when 9FA (hexa) is divided by 8 is added to the 


12(to base ten) to get x.then x has the binary opertion 
ans=1110

13. the remainder when 1221 (in hexa) is diveded by 17(decimal) in (hexa)is
ans=0
14. The binary number 100010011 will the hexa representation
ans=113

15. The binary number 10011001 will the octal representation


ans=463

16 Find the odd man out


16 a) Intel b)motorola c)nec d)Ibm
ans =nec

17. a)BIt b)byte c)nibble d)field


ans= field

18 a)Tree b)Root c)Log d)leaf


ans=log
19. a)ROM b)PROM c)EPROM d)EEPROM
ans=ROM

20. a)MOVE b)DEL c)COPY d)REN


ans=DEL
21. What's the output of the following program
main()
{
int z=3;
printf(&quot;%d %d &quot;,z,main());
}
a)prints a value 3 b)prints junk value c)error message d)infinite loop

22) main() 
{
int i=3,j=5;
while (i--,J--)
{
printf(&quot;%d %d&quot;.i,j);
}
}
The loop will be executed
a)3 times b)5times c)8times d)infinite times

23) main()
{
int i=3,j=5
If(i--,j--)
printf(&quot;%d %d &quot;,i,j);
}
The output of the program for (i,J)is 
a)3,5 b)3,4 c)2,4 d)2,5
ans=B

24) main()
{
int i=3
printf (&quot;%d %d %d &quot;,++i,i-,i+=5);
}
The the out put of the program is
a)8,8,8 b)4,3,8 c)3,2,7 d)4,4,9
ans=B

25) main()
{
int times =5;
int i=3;
int j=4;
int k=34;
i=j+k;
while(times --)
{
i=times
j=times
k=times
}
printf(&quot;%d %d %d &quot; ,i,j,k)
}
THe output of the praogram is (i,j,k)
a)19,9,35 b)38,42,80 c)43,47,85 d)15,14,41 
ans=C
26) main()
{
int num =32765;
while (num++);
printf(&quot; %d &quot;,num)
}
what&quot;s the out put ofthe program
a)prints all the number above 32765 including the number 32765
b)prints all the number above 32765 excluding the number 32765
ans=B.

27) main()
{
float k=3.4156
printf(&quot;%f %f &quot;,float(k),c(k))
}
The output of the program 
a) 3.4156 ,3.4156 b)4,5 c)3,4 d)3.45 3.40
ans=C.

28) main()
{
int bounce =4;
printf (&quot;total number of bounce =%d&quot;,bounce ++);
}
The out put of the program is
ans=D (stoP)

29) main()
{
int number =25;
char name ='A'
printf(&quot;The addition of the name and the number is %o &quot;name +_number)
}
the output of the program is 
a)compiler error
b)run time error
ans= A

30)

31) ODBC means


ans= open data base connectivity
32) ASCII stands for
ans= american standard for information interchange 
33) 
34) flops stands for 
ans)floating point operation per second
35) by superconductivity
ans)
36) PERT stands for
Program evalution and review techniq
37) IMS is a
ans) data base system
38) HTML is a
ans) Hyper text markup language 
39) The default backend of visual basic is
ans)sybase
40) Client server is based on 
ans) distribution processing

44) computer viruses can spread from one system to anther by means of
a) infected disks b)links to a network
c)downloaded program from a bulletin boardd)all of the program
ans)D
45) A front end processor is usually used in
ans=multi processing.
46) A radio active material of mass 16gms loses in 10 years due to
radiation.How many more years will take for the material to attain a
mass of of 1gm ?
ans=80 years
47) A block of ice floats on water in a beaker as the melts the water
level n the beaker will remain the same
ans=Remains same.
48) if va,vn,vs are velocities of sound in a air ,water ,and steel then
ans)vs&gt;vn&gt;va
49) in usual computer arthimetic the value of the integer expression
22/5*2+8*2/6
ans= 8.
50) an operting system is a
a)file manager b)memory manager
c)i/o manager d)all of the above
ans=D.

1.How many liters of water must be added to 30 liters of alcohol to make a


solution thatis 25%
ans:120
2.How much is 3/7 larger than 20 percent of 2
ans;1/35
3.xyz=120,then which of the following cannot be a value of y
ans:0
4.a number of subsets of a set s is 128, then s has
ans:7
5. xsqrt(0.09)=3 , then x equals
ans:
6.perimeter of rectangle is s and the other sideis x, then the other side
ans:(s-2x)/2 
7.solution of system of equations y-z=0,x+8y=4,3x+4y=7z is
ans:x=1,y=1,z=1

15. f(x,y) =x**2 -y**2 then the value of f(4,(f(1,2) is


ans =7.
16. if the radius of the circle is incresed by 6% then its area incresed
by 
ans=36%
17. the average of seven numbers is 2.5 then their product
asn=17.5
18. the minimum of (2x+1)**2 + (x+2) is at x =
ans = (-4/5)
19. the probability of getting at least in a single through of three
coins is
ans=7/8.
20. atrain covers the distance D beteween two cities in hhours arriving
2 hours late.what rate would permit to train to arrive on schdule? 
ans= (D/H-2)
21. in a single throw of dice ,the chance of throwing a total of 3 is
ans) 1/216.
22. a triangle of sides 3,4,5 then its----is
ans:6
23. Which of the following is next smaller invalue than--- one half
ans:2/5
24. if f(x)=1/x then f(f(f(x))) equals
ans:1/x
25. if f(x)=1/x**2 , then f(f(f(x)))
ans:1/x
26.if 8x+4y=6 and 4x+5y=7, x+y equl\als 
ans:1
27. find the next number in the series 1,2,5,10,17,26
ans:37
28,.sqrt(0.16)+cubic root(0.027) equals
ans:0.7
29.if a,b&gt;0 and a+b=2 then the max value of ab is 
ans:1

30. p and q are positiveintegers with their average 5, find how many
different values can p take
ans:9
31. if 0&lt;x&lt;1 which of the following is the largest
ans:1/x
33. If x,y,z are three consecutive natural numbers, which of the following
numbers should be x+y+z 
ans:2/3
34. two persons run a race of 100m. the winner won by (110/11)m and one
second in time. find the speed of lsoer in met
ans:9.09
35. in a group of 15,7 can speak spanish, 8 can speak french and 3 can
speak neither,. how much of the group can speak both french and spanish
ans:1/5
36. which of the following intefgers is the square of an integer for every integer
ans:a**2+2n+1
37. which of the following has the largest numberical value
ans:0.2/0.000001
38. ifn is odd which of the following statements is true
ans: 3n+1 is even
39. which of the following is the prime
ans:80  

Potrebbero piacerti anche