-
int b=10;
int *p=&b;
*p++;
printf(“%d”,*p);
what is the output? -
What is the difference between malloc, calloc and realloc?
-
What does malloc return in C and C++?
-
main()
{
char *a=”hello”;
char *b=”bye”;
char *c=”hai”;
int x=10,y=100;
c=(x)?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? -
Declare a pointer to a function that takes a char pointer
as argument and returns a void pointer. -
How do we open a binary file in Read/Write mode in C?
C++
-
class A
{
public:
A()
{
}
~A();
};
class derived:public A
{
derived();
};
what is wrong with this type of declaration? -
what do you mean by exception handling?
-
What are “pure virtual” functions?
-
What is the difference between member functions and
static member functions? -
What is the4 difference between delete[] and delete?
-
Question on Copy constructor.
-
What are namespaces?
-
One question on namespace.
-
What are pass by valu and pass by reference?
what is the disadvantage of pass by value?
I didnt get this. if you have the answer plz tell me. -
How to invoke a C function using a C++ program?
-
char *str;
char *str1=”Hello World”;
sscanf(str1,”%s”,str);
what is the output? -
Difference between function overloading and function overriding.
-
There is a base class, 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?
SET-2
-
void main()
{
int d=5;
printf(“%f”,d);
}Ans: Undefined -
void main()
{
int i;
for(i=1;iAns: 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(ij)
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 -
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:
-
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… */ -
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 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 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”
SET-3
Q1.Convert 0.9375 to binary
a) 0.0111
b) 0.1011
c) 0.1111
d) none
Ans. (c)
Q2.( 1a00 * 10b )/ 1010 = 100
a) a=0, b=0
b)a=0, b=1
c) none
Ans. (b)
Q3. In 32 bit machine 24 bits for mantissa and 8 bits for exponent. To increase the range of floating point.
a) more than 32 bit is to be there.
b) increase 1 bit for mantissa and decrease 1 bit for exponent
c) increase 1 bit for exponent and decrease one bit for mantissa
Q4.In C, “X ? Y : Z ” is equal to
a) if (X==0) Y ;else Z
b) if (X!=0) Y ;else Z
c) if (X==0) Y ; Z
Ans. (b)
Q5. From the following program
foo()
int foo(int a, int b)
{
if (a&b) return 1;
return 0;
}
a) if either a or b are zero returns always 0
b) if both a & b are non zero returns always 1
c) if both a and b are negative returns 0
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
Q7. Which of the following is incorrect
a) if a and b are defined as int arrays then (a==b) can never be true
b) parameters are passed to functions only by values
c) defining functions in nested loops
Q8. include
void swap(int*,int*);
main()
{
int arr[8]={36,8,97,0,161,164,3,9}
for (int i=0; i
Q9. int main()
{
FILE *fp;
fp=fopen(“test.dat”,”w”);
fprintf(fp,’hello\n”);
fclose(fp);
fp=fopen (“test.dat”,”w”);
fprintf (fp, “world”);
fclose(fp);
return 0;
}
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);
}
What is the output?
a) 8 8 8
b) 5 8 8
c) 8 5 8
d) none of these
SET-4
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 ———-
7. What’ll be the output:
main()
{char *a,*f();
a=f();
printf(“%s”,a);
}
char *f()
{return(“Hello World”);
8.What’ll be the output:
main()
{char*a,*f();
a=char*malloc(20*sizeof(char));
a=f();
printf(“%s”,a);
}
char *f()
{char n[20];
strcpy(n,”Hello World”);
return(n);
}
9.What is the error :
main()
{int j=10;
switch(j)
{ case 20:
pritnf(“Less than 20″);
break;
case 30:
printf(“Less than 30″);
break;
default:
printf(“hello”);
}
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);
}
12. How many times main is get called :
main()
{
printf(“Jumboree”);
main();
}
ans: till stack overflow.
13. Which statement is true about main :
(i) Varible no. of Arguments can be passed main.
(ii) Main can be called from main();
(iii) We can’t pass arguments are passed in main
(iv) main always returns an int
14. Output ?
main()
{
int i,j;
for(i=0,j=0;i<5,j
printf(“%d %d”,i,j);
}
SET-5
#include
main()
{
int x=20, t;
&t=x;
x=50;
cout<<
}
o/p?
50 20
t
—–
*include
int sum(int a, int b=5, int c=10);
main()
{
cout<<<<<
}
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<<
}
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 based on it