C, C++ Questions
C, C++ Questions
int b=10;
int *p=&b;
*p++;
printf("%d",*p);
what is the output?
main()
{
char *a="hello";
char *b="bye";
char *c="hai";
int x=10,y=100;
c=(x<y>)?a:b;
printf("%s",c);
}
whats the output?
void main()
{
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
}
int sumdig(int n)
{
static int sum;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
sum=sum+d;
sumdig(n);
}
else
return s;
}
what is the output?
C++
class A
{
public:
A()
{
}
~A();
};
class derived:public A
{
derived();
};
what is wrong with this type of declaration?
char *str;
char *str1="Hello World";
sscanf(str1,"%s",str);
what is the output?
There is a base class sub, with a member function fnsub(). There are
two classes super1 and super2 which are subclasses of the base class sub.
if and pointer object is created of the class sub which points to any
of the two classes super1 and super2, if fnsub() is called which one
will be inoked?
...........
Ads by Google
Satyam Hiring Freshers.
100's of Satyam Jobs
Submit your Resume Free. Now
MonsterIndia.com
C++ Source Codes
C++ Codes, Projects, Examples
Free Download
www.cppfaqs.com
Array
C, C++, and C# Resources.
Find tutorials, tips, and reviews.
www.DevSource.com
Infosys Test
Wanted Experienced Professionals
Post Your Resume Free & Get Placed!
ClickJobs.com/Post-CV
NetApp® and VMware®
Working Together to Deliver Virtual
Solutions to Your Business
www.NetApp.com/IN
TaqMan Low Density Array
Find TaqMan® Low Density Arrays.
Customize & Order Online Today!
www.AppliedBiosystems.com
Test Paper :1
Paper Type : Technical - C & C++
Posted By : admin
Give the output of the programs in each case unless mentioned otherwise
void main()
{
int d=5;
printf("%f",d);
}Ans: Undefined
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
void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));
}Ans: 6
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
void main()
{
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
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.)
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.
In the above question an array of pointers is declared. Write the statement to initialize the
3rd element of the 2 element to 10
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.
void main()
{
int i=7;
printf("%d",i++*i++);
}Ans: 56
#define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
Ans: "one is defined"
void main()
{
intcount=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
Ans: 20 20 20
There was question in c working only on unix machine with pattern matching.
what is alloca() Ans : It allocates and frees memory after use/after getting out of scope
main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
Ans: 321
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.
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"
...........
i2 Technologies
Q6. The following function gives some error. What changes have to be made
void ( int a,int b)
{
int t; t=a; a=b; b=t;
}
a) define void as int and write return t
b) change everywhere a to *a and b to *b
Q8. include<stdio.h>
void swap(int*,int*);
main()
{
int arr[8]={36,8,97,0,161,164,3,9}
for (int i=0; i<7; i++)
{
for (int j=i+1; j<8;j++)
if(arr[i]<arr[j]) swap(&arr[i],&arr[j]);
}
}
void swap(int*x,int*y)
{
int temp; static int cnt=0;
temp= *x;
*x=*y;
*y=temp;
cnt++;
}
What is cnt equal to
a) 7
b) 15
c) 1
d) none of these
If text.dat file is already present after compiling and execution how many bytes does the
file occupy ?
a) 0 bytes
b) 5 bytes
c) 11 bytes
d) data is insufficient
Q10. f1(int*x,intflag)
int *y;
*y=*x+3;
switch(flag)
{
case 0:
*x=*y+1;
break;
case 1:
*x=*y;
break;
case 2:
*x=*y-1;
break;
}
return(*y)
main()
{
*x=5;
i=f1(x,0); j=f1(x,1);
printf("%d %d %d ",i,j,*x);
}
a) 8 8 8
b) 5 8 8
c) 8 5 8
d) none of these
///////////
part 1 of paper
part 2
second c debugging (test ur c skills - yashwant kanitkar)(questions 20 time 30 min.)
paper 1
section one
section three
one hotel has two zones (east and west) not all east zone flats have ocean view but all
weat zone flats have harbour view all ocean view flats has extra charge in harbour view
flats above and on 3rd floor have extra charge west zone flats lower than 3rd floor some
has kitchen so extra charge all other flats of east zone not having ocean view has kitchen
so extra charges
section four
10 questions verbal reasoning four or five sentences are given related to single topic four
options are given which are having order of three sentences(abe or bec) select correct
order
sections five
* total 12 members half are in club a one third in b and one fourth in c how many are not
in any club
ans 5(check)
in question it was written that all five sections carry their cutoffs so attempt all but in
electrical one guy was selected who didnot attempt reading comprehension but attempted
all 45 questions this paper also has negative marking of 50%
paper 2
1.what does p in
const char *p
stands for
p can be changed like this
2.main()
sturct date {
char name[20];
int age ;
float sal;
};
sturct data d ={"rajesh"};
printf("%d%f",d.age,d.sal);
}
tell the output
3.main()
int i=7;
printf("%d"i++*i++);
output
4.void main()
{
int d ;
int i=10;
d =sizeof(++i);
printf("%d");
output
5.difference between
extern int f();
int f();
6.choose correct
(i)stack is automatically cleared
(ii)heap is automatically cleared
(iii)user has to clear stack and heap
(iv)system takes care of ----------
10.which is valid :
(i)char arr[10];
arr="hello";
(ii) char arr[]="hello";
11.
main()
{
char *str;
str=char*malloc(20*sizeof(char));
strcpy(str,"test");
strcat(str,'!');
printf("%s",str);
}
14. Output ?
main()
{
int i,j;
for(i=0,j=0;i<5,j<25;i++,j++);
printf("%d %d",i,j);
}
15.main()
{
int i;
if(i=0) //it's assisnment not logical operator
printf(" Hell ");
else
printf("Heaven");
like this
no negative marking and more than one answers but paper I is cutoff paper i think c paper
will not be checked
Interview
they will give u puzzles in first round which will be from site techinterview.org this site
has 70 puzzles and their answers so go through them
second round has c coding of data structure circular quese,tree etc also questions from c
and c++ like virtual functions
far near huge memory concepts like heap,stack etc
then in third round hr questions like hobbies and interets make ur curriculam vite and
bring it with ur file
they want people with good aptitude in interview rounds ur aptitude and approach matters
so solve puzzles.
Some of the questions will not have answers .Please forgive us.
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
TRIAD PAPER
C - language:
3. write program to open one file input some numbers and find smallest,largest, avg. and
store them in another file.
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 :
3. personal interview.
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
/////////
Prodex Paper
1.x=3
function(++x)...value 4 is passed to the function
2 x=3
function(x++)...value 3 is passed to the function
4.if(!name)...(not exixts)
{
...
} the file cant b opened
7.main()
{
function(x,y);
}
void function(int *x,int *y)
{
.....
}
the function does not work.
8.A d();
a j;
it works well
given an expression tree and asked us to write the in fix of that expression
four choices : 2
size of(int)
a) always 2 bytes
b) depends on compiler that is being used
c) always 32 bits
d) can't tell
main(){
char str[5]="hello";
if(str==NULL) printf("string null");
else printf("string not null");
}
what is out put of the program?
a) string is null b) string is not null c) error in program d) it executes but print nothing
There are 0ne 5 pipe line and another 12 pipe line sates are there and flushed time taken
to execute five instructions a) 10,17
b) 9,16
c)25,144
d)
struck a{
int x;
float y;
char c[10];
}
union b{
int x;
float y;
char c[10];
}
which is true?
a) size of(a)!=sizeof(b);
b)
c)
d)
main()
{
char a[10]="hello";
strcpy(a,'\0');
printf("%s",a);
}
out put of the program?
a) string is null b) string is not null c) program error d)
simplyfy k map
1xx0
1x01
int f(int a)
{
a=+b;
//some stuff
}
main()
{
x=fn(a);
y=&fn;
what are x & y types
a) x is int y is pointer to afunction which takes integer value
char a[5][15];
int b[5][15];
address of a 0x1000 and b is 0x2000 find address of a[3][4] and b[3][4]
assume char is 8 bits and int is 32 bits
a) b) c) d)
there are 20 questions all in techinical paper and 36 questions in appititude test in
appititude thay have given all diagrams and asked to find what comes next thay are quite
easy and i hope if u practice r.s aggraval u can do it easily for tecnical thay have given 1
hr for 20 questions and for not technical thay have given only 40 min and 36 questions
this is the paper i have right now for TI aptitude test consist of all pictorial questions. ie
in each question he will give 8 diagrams and ask to find th 9'th diagram in that
sequence.You go through RS Agarwal. These aptitude questins are
very easy. Just pratice them. In RS Agarwal gothrough SERIES chapter. It is suffient.
There are 35 aptitude
questions. First 25 are very easy. Do these questions in just 15 or 20 minutes. Because
last questions are
very touch.
TECHNICAL TEST:
3 flipflops are connected so that after 0 to 5 count occured next number is zero. So what
is the counter?
Ans: mod 6 counter
Given inorder sequence and preorder sequence and asked to find out postorder sequence.
Given an interger in binary form,find the number of ones in that number without counting
each bit.(This questin is not multiple choice question. This question carries more marks.
So please take care for this question.)
Some page references are given. You are asked to implement it with Least Frequently
Used algorithm.
Some diagram is given. Iam describinmg the diagram. A 2*1 MUX is given. The inputs
are A,B. Output is C. C and A are tied together. What is the diagram.?
Ans:Latch.
This paper is for Electrical & Electronics students. There is separate test for computer
Science Students. There are 20 questions.
1)Some circuit is given. Iam describing the circuit.A resistor R & a capacitor C are
connected in parallel.
To this circuit another circuit which is having a capacitorof capacity 2C & an impedence
Z, is connected in series.
You are asked to find out the value of Z? Note that 2C & Zare connected in series.
a)Z=2C
b)Z=2L
c)Z=L/2
d)Z=2R
Some circuit which consist of only resistors R is given. This is a repetative circuit. U
have to find the effctive
resistance of the entire circuit.
A)Rin=R
B)Rin=(5+sqrt(3))/7
C)Rin=(19+sqrt(3))/8
D)None.
Two wave forms are given. You are asked to write the cirsuit to get B(second wave form)
from A(first wave form).
number(int i)
{
number++;
printf("%d\n",number);
}
main()
{
static int i=0;
number(i);
}
Ans: I don't know.
This Paper is for Computer Science Students. THis paper is very easy. You can definitely
do it in one hour.
The fastest memory is
(i) DRAM, (ii) ROM, (iii) SRAM, (iv) Main memory
Ans : SRAM
int a[10[15];
char b[10[15];
(a) location g a[3][4], if base location g a[0][0] is ox1000
(b) location g b[3][4], if base location g b[0][0] is ox2000
int taken 32 bits and char taken 8 bits.
Ans : (a) ox10C4 (b) ox2031
Count no of 1's in a word without using bit by bit. (This question carries more marks. It is
not a multiple choice
question.
Code 1 :
for(i=0; i<1000; i++)
for(j=0; j<100; j++)
x = y;
Code 2 :
for(i=0; i<100; i++)
for(j=0; j<1000; j++)
x = y;
Which code will execute faster
(i) Code 1 and Code 2 are of same speed,
(ii) Code 1,
(iii) Code 2,
(iv) None.
Ans : Code 2
main()
{
int a[10] = {1, 2, 3, ...., 10}, i, x=10, temp;
for(i=0; itemp = a[i];
a[i] = a[x-i-1];
a[x-i-1] = temp;
}
(i) All contents of array a are reversed
(ii) Only some portions are altered
(iii) Remains same
(iv) None
Ans : (iii)
An array is stored in row major order. The memory capacity is 30 MB. And in unix
system demand paging is used. Which one will give more page faults?
#define V_L_I 10000
int i, j, array[V_L_I][V_L_I];
Code 1 :
array[i][j] = 1;
Code 1 :
for(j=0; jfor(i=0; iarray[i][j] = 1;
Ans : Code 2
A circuit is given with 2 exclusive OR gates whose boolean expression will be y = '(AB)
+ AB (' indicates bar)
(17) main()
{
int i = 1;
fork();
fork();
printf("\ni = %d\n", i+1);
}
Ans : 4 printfs will occur and i = 2
/////////
Ramco
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.
Ans:C
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
Is angle µ=90
1) sin**2(µ)+cos**2(µ)=1
2) sin**2(µ)-+cos**2(µ)=1
Ans: E
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
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
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
Technical Questions
# define TRUE 0
some code
while(TRUE)
{
some code
}
main()
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
Ans. 11 16
newval=tempval;
}
Techanical paper
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
22) main()
{
int i=3,j=5;
while (i--,J--)
{
printf("%d %d".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("%d %d ",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 ("%d %d %d ",++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("%d %d %d " ,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(" %d ",num)
}
what"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("%f %f ",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 ("total number of bounce =%d",bounce ++);
}
The out put of the program is
ans=D (stoP)
29) main()
{
int number =25;
char name ='A'
printf("The addition of the name and the number is %o "name +_number)
}
the output of the program is
a)compiler error
b)run time error
ans= A
30)
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>vn>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.
30. p and q are positiveintegers with their average 5, find how many
different values can p take
ans:9
31. if 0<x<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
1)
int i;
if i=0 then i:=1;
if i=1 then i:=0;
2)
int i;
if i=0 then i:=1;
if i=1 then i:=0;
(given that i can take only two values (1,0))
3)
int i;
if i=0 then i:=1;
else if i=1 then i:=0;
(given that i can take only two values (1,0))
4)
int m,j,i,n;
for i:=1 to n do
m:=m+j*n
a) Array overbound
b) Undeclared identifier
c) stack underflow
d) Accessing an illegal memory location
7) How many page faults will occur for below sequence of pages when LRU
page replacement algorithm is used ( The memory can only have 3pages):
C Section
bubble sorting is
a)two stage sorting
b).....
c)....
d)none of the above
.c++ supports
a) pass by value only
b) pass by name
c) pass by pointer
d) pass by value and by reference
Insertion sort
no of comparisons = _________
no of exchanges = ____________
what is a language?
a) set of alphabets
b)set of strings formed from alphabets
c)............
d)none of the above
Which of the following is not conducive for linked list implementation of array
a)binary search
b)sequential search
c)selection sort
d)bubble sort
char *p="abcdefghijklmno"
then printf("%s",5[p]);
Aptitude
A problem on time and work ,A and b takes 15 days to completer the work,A takes 30
days so how many days B take?
A question on compound interest with 5 sub questions,simple if u know the concept.
A question on finding the speed of boat given the speed of upstream and downstream.
Complexity of hastable
Aquestion on DMA
C programming
main()
{
printf("hello"):
main();
}
what is the output?
ans :stack overflow
Each question had 5 options.There were 25 question in all and all were Objective Type.
4 void main()
{
int x=1;
int y=1;
int i;
for(i=2;i<=100;i++)
{
x=x+i;y=y*(i+1)/(i-1);
}
What are the values of x & y?
5 If we carry out operation (-3)+(-6),then which of the what will be the value of carry
and sign flag?
6 void abc(int a[])
{
int k=0;int j=50;
while(k<j)
{
if(a[i]>a[j])
k++;
else
j--;
}
How many times the loop will occur?
element?
14 s=1-1/4+1/16-1/32...... What is the value of S?(Ans = 0.8 Hint Its a GP)
15 A C++ class has multiple references to base class.Then some options were given?
16 for(i=0;i<20;i++)
{
a[i]=i;
}
for(i=0;i<20;i++)
{
a[i]=a[19-i];
}
What is final value of array a? Options were there.
17 In Java can a variable be initilised inside a loop?
18 Two dices are thrown.What is the probality that the the number on the first dice is
greater or equal to
number on the second dice?
1. How many butes does an array A(1:8,-2:2,1:5) require for storage if each element of
the array is 24 bits long.
200 480 600 800 none
2. begin
i:=0;
j:=0; | block d
loop:
if(i != 0)
i := i-1;
else
i := i+1;
i := i+1; | block a
j := j+1; | block b
if (j <= 25)
goto loop;
end | block c
a) What is the value of i at [c]
2?
b) How many times is the goto executed
25 ?
c) How many times is the loop executed if i is initialized to 1
in [d] 26
d) How many times is the loop entered if the block [b] is changed
to j=j+1 ?
e) What is the value of i at [c] interchanging blocks [a] and [b] ?
2?
Follow the instructions given below [ From 1 to 8 ]
1. A cause B or C but not both
2. F occurs only if B occurs
3. D occurs if B or C occurs
4. E occurs if only c occurs
5. J occurs only if E or F occurs
6. H occurs if E occurs
7. D causes G, H or Both.
8. G occurs if F occurs.
Questions
---------
1. If A occurs which of the following may occur
1. F & G (ii) E & H (iii) D
Ans
(a) 1 only (b) 2 only (c) 3 only (d) 1,2,3 or 2 & 3 but not 1
(e) 1,2 & 3
2. If B occurs which must occur
Ans
(a) F & G (b) D & G (c) D (d) G & H (e) J
3. If J occurs which must occur
Ans
(a) E (b) Both E & F (c) Either B or C (d) B (e) Both B & c
4. Which may occur as a result by a cause not mentioned.
(I) D (II) A (III) F
Ans
(a) I only (b) II (c) I & II (d) II & III (e) I,II,III
5. If E occurs which cannot occur.
(a) F (b) A (c) D (d) C (e) J
abcde
4
----------
edcba
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
Ans. 5 20 1
#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'
7) 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
8) 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
9) 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
10) 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
Technical Questions
main()
{
char **p=="Hello";
printf("%s",**p);
}
Ans: Garbage or nothing
main()
{
printf("%d%c\n");
printf("%d%c\n");
}
Ans: Garbage Value
main()
{
int x==5;
printf("%d%d",x++,++x);
}
Ans==6 6
main()
{
int x==4;
printf("%d",printf(" %d %d ",x,x) );
}
Ans: 4 4 5
main()
{
union
{
int i;
char p;
struct
{
int t;
char e;
char o;
}w;
};
printf("%d\n",sizeof(l) );
}
Ans: 4
main()
{
int i==0,n==6;
while(n--0);
i+==n;
printf("%d\n",i);
}
Ans: -1
ain()
{
char a[]=="Hello";
printf("%c\n",*a++);
}
Ans: Error
a=3,b=2,c=1;
What's the value of k?
k== a< b < c-1;
Ans: 0
main()
{
int a=3;
do
{
printf("%d", a);
a=-1;
} while(a0);
}
Ans: 3
main()
{
int i==0;
for( i==0; i<= ;i++)
{
switch(i)
{
case 0: i+==5;
case 1: i+==2;
case 2: i+==5;
default: i+==4;
break;
}
printf("%d",i);
}
Ans: 16 21
main()
{
int i==4;
switch(i)
{
case 1:
printf("HEllo"):
case default: // "case" should not come with "default"
printf("****");
}
}
Ans: Error
main()
{
int sum==0,count;
for(count==1;sum+==count)
printf("%d\t",sum);
}
Ans: Error
main()
{
static int i==5;
printf("%d\t",i--);
if( i)
main();
}
Ans: 5 4 3 2 1
main()
{
char *a1=="new",*a2=="dictionary",*t;
swap(a1,a2);
printf("(%s%s)",a1,a2);
t=¡;
a1=¢;
a2==t;
printf("-(%s%s)",a1,a2);
}
swap( char *s1,char *s2)
{
char *temp;
s1=s2;
s2=s1;
temp=s1;
}
Ans: (newdictionary)-(dictionarynew)
*p++?
Ans: increments Address
main()
{
int a[]=={ 10,20,30,40,50};
char*p==(char*)a;
printf("%d", * ( (int *) p+4);
}
Ans: 50
one question nothig but calling a function before it has been defined.
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
Which group does Winrunner ,Load Runner ,SQA Suite fall under ?
a) Databases
b) Automated Test Tools
c) Operating Systems
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
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.
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
Which one of the following represents a correct and safe declaration of NULL ?
d) #define NULL((char*)0)
#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 ?
d) using iostream;
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));
a) fread()
b) readfile()
c) fileread()
d) gets()
a) 32767
b) 65536
c) 2147483647
d) INT_MAX
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()
int a=1;
int ab=4;
int main()
int b=3,a=2;
printf("%i*/%i*/%*/i",a,b,ab);
ans :- init();
process id of kernal
(a) 1
(b) 0
(c) 2
(d) none
Which one of the following represents a correct and safe declaration of NULL ?
d) #define NULL((char*)0)
Which one of the following statements allocates enough space to hold an array of 10
integers that are initialized to 0 ?
CITICORP
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);
}
--------------------------------------------------------------------
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);
}