C,C++ Questions

March 17, 2017 | Author: khanjukh | Category: N/A
Share Embed Donate


Short Description

Download C,C++ Questions...

Description

Sample Test Paper :Alter Engineering 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 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?

View Comments Enter Your Comments ........... 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 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-tofunction 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 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 memory 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 int sum,count; void main(void) {< BR> for(count=5;sum+=--count;) printf("%d",sum); } a. The pgm goes to an infinite loop b. Prints 4791010974 c. Prints 4791001974 d. Prints 5802112085 e. Not sure 2. What is the output of the following program? #include void main(void) { int i;< BR> for(i=2;i Defect Rechecked -> Defect Closed Which group does Winrunner ,Load Runner ,SQA Suite fall under ? a) Databases

b) Automated Test Tools c) Operating Systems d) Rapid Application Development Tool i = 0; j = 0; for(j=1;j
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF