Topic — Add New » Posts Last Poster Freshness
Infinite Bit Stream and divisibility by n 1 2 years

Given an infinite stream of bits and a number 'N' find if the decimal equivalent of infinite stream of bits is divisible by 'N' or not?

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;
}
[closed] Examine the pairs and orders of "{","}","(",")","[&quot 4 geeksforgeeks 2 years

Given a string, how to write a C++ program to examine whether the pairs and the orders of "{","}","(",")","[","]" are correct?

C++ 2 2 years

C struct can't have any const or enum varibles, as varible can't be initialized in struct.
then Why can C++ class contain const members and enums?

What is wrong with the code? 2 2 years
#include<iostream.h>
class test
{
  public:
	bool operator == (test temp);
};

bool test::operator == (test temp)
{
      if(*this  == temp )
      {
	  cout<<" both are same objects\n";
	  return true;
	}
	else
       {
	  cout<<"The both are different\n";
           return false;
	}
}

int main()
{
	test t1,  t2;
	if(t1 == t2)
           printf("Equal");

	getchar();
}
What is output of the C program? 4 Shekhu 2 years
#include<stdio.h>
int main()
{
   int a;
   char *x;
   x = (char *) &a;
   a = 512;
   x[0] = 1;
   x[1] = 2;
   printf("%d\n",a);
}
What is the output of the program? 2 2 years
class base
{
    public:
      int bval;
      base(){ bval=0;}
};

class deri:public base
{
    public:
      int dval;
      deri(){ dval=1;}
};

void SomeFunc(base *arr,int size)
{
    for(int i = 0; i < size; i++,arr++)
       cout<<arr->bval;
    cout<<endl;
}

int main()
{
    base BaseArr[5];
    SomeFunc(BaseArr,5);
    deri DeriArr[5];
    SomeFunc(DeriArr,5);
    getchar();
}
What does the given program do 2 2 years
IntQueue q = new IntQueue();
q.enqueue(0);
q.enqueue(1);
for (int i = 0; i < 10; i++) {
    int a = q.dequeue();
    int b = q.dequeue();
    q.enqueue(b);
    q.enqueue(a + b);
    ptint(a);
}
Double Trouble Numbers 3 Nasam 2 years

Hi,

I have some what complex problem and i hope i get some suggestions here on how to solve the problem.

Need to find out the smallest double trouble numbers for base starting from 0 to 200.

a double trouble number is a number when you right rotate the number( take away the last digit and put it in front of the number ) you will get double the original number

in case of binary sys ( base 2) the smallest double trouble number is 01.
when you right rotate 01...

find and print the first longest ascending or descending contiguous subsequence 2 2 years

Write a C++ program that would find and print the first longest ascending or descending contiguous subsequence for a vector of integers. For example, given a vector with
4, 2, 1, 2, 3, 4, 3, 5, 1, 2, 4, 6, 5
The program would find the underlined subsequence and print it.

Sort the letters 3 kartik 2 years

Given a list of letters, such as "aDECdjA", how to write a C program to sort the list and output as
"aACdDEj"?

You have an array of 1 million integers, there is at most one 5 in the array. 1 geek4u 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.