collabera company ( call based 2017, 2018 batch )

collabera company ( call based 2017, 2018 batch )

software developer

18 may and `19 may

Triton, 3rd floor, 13th cross Road, Anepalya, Anepalya circle, Bengaluru, Karnataka 560030

Given an array A[] and a number x, check for pair in A[] with sum as x
Write a C program that, given an array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x.

C++ Programs to Check Even and Odd Number
C++ Programs to Swap two numbers
C++ Programs to Check Given number is Prime or not
C++ Programs to Find Factorial of Number
C++ Programs to Print Table of any Number
C++ Programs to Reverse any Number
C++ Programs to Find Number Of Digits
C++ Programs to Generate Fibonacci Series
C++ Programs to Check Armstrong Number
C++ Programs to Find Greatest Number

Check give number is Even or Odd
#include
#include

void main()
{
int no;
clrscr();
cout<<"Enter any num: "; cin>>no;
if(no%2==0)
{
cout<<"Even num"; } else { cout<<"Odd num"; } getch(); }Download Code Output Enter any num : 5 Odd num Check give number is Even or Odd Using ternary or conditional Operator Example #include
#include

void main()
{
int no;
clrscr();
cout<<"Enter any num : "; cin>>no;
(no%2==0) ? cout<<"Even num"; : cout<<"Odd num"; getch(); } Output Enter any num : 6 Even num Download Code Check give number is Even or Odd Using Bitwise Operator Example #include
#include

int main()
{
int num;
clrscr();
cout<<"Enter any num: "; cin>>num;
if(num & 1)
{
cout<
#include

void main()
{
int i,no,table=1;
clrscr();
cout<<"Enter any num : "; cin>>no;
clrscr();
cout<<"Table of "<
#include

void main()
{
int a=1,no,table=1;
clrscr();
cout<<"Enter any num: "; cin>>no;
while(a< =10) { table=a*no; cout<
#include

void main()
{
int i,j,len,flag=1;
char a[20];

cout<<"Enter a string:"; cin>>a;

for(len=0;a[len]!=’\0′;++len);

for(i=0,j=len-1;i
#include
#include
#include

void main()
{
char str[10];
int i,j,n,flag=0;
cout<<"Enter any string:"<
#include
#include

int main(void)
{
int number, result;
clrscr();
cout<<"Enter any Character/Symbol/Digits: "; number = getch(); result = toascii(number); cout<<"Ascii value: "<
#include
void main()
{
int value;
clrscr();
cout<<"Enter any Character/Symbol/Digits: "; value=getch(); cout<<"Ascii value: "<) is needed to access members.

What are virtual functions – Write an example?
Virtual functions are used with inheritance, they are called according to the type of object pointed or referred, not according to the type of pointer or reference. In other words, virtual functions are resolved late, at runtime. Virtual keyword is used to make a function virtual.

Following things are necessary to write a C++ program with runtime polymorphism (use of virtual functions)
1) A base class and a derived class.
2) A function with same name in base class and derived class.
3) A pointer or reference of base class type pointing or referring to an object of derived class.

For example, in the following program bp is a pointer of type Base, but a call to bp->show() calls show() function of Derived class, because bp points to an object of Derived class.

#include
using namespace std;

class Base {
public:
virtual void show() { cout<<" In Base \n"; } }; class Derived: public Base { public: void show() { cout<<"In Derived \n"; } }; int main(void) { Base *bp = new Derived; bp->show(); // RUN-TIME POLYMORPHISM
return 0;
}
Output:

In Derived
What is this pointer?
The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions. ‘this’ pointer is a constant pointer that holds the memory address of the current object. ‘this’ pointer is not available in static member functions as static member functions can be called without any object (with class name).

Can we do “delete this”?
See https://www.geeksforgeeks.org/delete-this-in-c/

What are VTABLE and VPTR?
vtable is a table of function pointers. It is maintained per class.
vptr is a pointer to vtable. It is maintained per object (See this for an example).
Compiler adds additional code at two places to maintain and use vtable and vptr.
1) Code in every constructor. This code sets vptr of the object being created. This code sets vptr to point to vtable of the class.
2) Code with polymorphic function call (e.g. bp->show() in above code). Wherever a polymorphic call is made, compiler inserts code to first look for vptr using base class pointer or reference (In the above example, since pointed or referred object is of derived type, vptr of derived class is accessed). Once vptr is fetched, vtable of derived class can be accessed. Using vtable, address of derived derived class function show() is accessed and called.