Topic — Add New » Posts Last Poster Freshness
New to Object Oriented Approach 2 2 years

I have been doing C programming in my previous semesters, but never did C++ or any other OO language. Can somebody please guide me how to start C++ and how to start thinking OO way?

Pointers vs References in C++ 2 kartik 2 years

What are the differences between pointer and reference variables? How to choose one?

[closed] Given some characters and a long string text, find the shortest substring coveri 2 Sandeep 2 years

Given some characters and a long string text, find the shortest substring covering all given characters.

Give a string, find all the substrings that are palindrome. The lengthes of thes 1 2 years

Give a string, find all the substrings that are palindrome. The lengthes of these substrings have to be odd.

Interview Question 2 Onkar Rajopadhye 2 years

In the header file you see the following declaration:

class Foo {
void Bar( void ) const ;
};
Tell me all you know about the Bar() function.

[closed] points combination 2 geeksforgeeks 2 years

You can win three kinds of basketball points, 1 point, 2 points, and 3 points. Given a total score X, print out all the combination to compose X.

What is the output of program and why? 2 kartik 2 years
#include<iostream>

using namespace std;

class test
{
  static int x;
  int *ptr;
};

int main()
{
  test t;
  cout<<"\n"<<sizeof(t);
  cout<<"\n"<<sizeof(test);
}
Find the index of a value from a large array 3 2 years

You have an array of 1 million integers, there is at most one 5 in the array. write code to find the index of 5, or return -1 if there is no 5. The array can be put into main memory.

Given two sorted arrays, i.e., A and B, output the union and intersection of A 4 2 years

Given two sorted arrays, i.e., A and B, output the union and intersection of A and B.

An interview question on C 2 kartik 2 years

What's the output of the following code? and why?
main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);

printf("%d %d" , *(a+1), *(ptr-1) );

}

Given a set of N number, find the one whose occurences are big than N/2. 2 Shekhu 2 years

Given a set of N number, find the one whose occurences are big than N/2.

phone number 5 2 years

The input is phone #, and the output should be the corresponding string, e.g., input: 23, output:[ad, ae, af, bd, be, bf, cd, ce, cf]

What is the output of the following program? 2 2 years

What is the output of the following program?

int main()
{const char* p = "12345";
const char **q = &p;
*q = "abcde";
const char *s = ++p;
p = "XYZWVU";
printf("%c\n", *++s);
}

There is an array of integers 2 2 years

There is an array of integers, where every element is repeated exactly once except one element, e.g. 3 in {1,1,2,2,3,5,5}, how do you find the outlier?

A constructor problem 2 2 years

If there are multiple functions in a constructor, and the destructor also contains a set of corresponding functions, how to guarantee that the destructor will be called?

Is there anything wrong with the following program? 2 kartik 2 years

Is there anything wrong with the following program?

void my_malloc (void * ptr, int size) {
    ptr = malloc(size);
}

int main () {
    int * ptr;
    int i;

    my_malloc(ptr, 10);

    for (i=0; i<10; i++) {
        ptr[i] = i*10;
        ...
    }
    free(ptr);
    return;
}
Output of C++ program 2 2 years

Is there anything wrong with below C++ code?

int main()
{
   int a, *pa, &ra;
   pa = &a;
   ra = a;
   cout<<"a="<<a<<"*pa="<<*pa<<"ra"<<ra ;

   getchar();
   return 0;
}