Find the Number

Find the smallest number with the given properties

When I divide it by 2, the remainder is 1.
When I divide it by 3, the remainder is 2.
When I divide it by 4, the remainder is 3.
When I divide it by 5, the remainder is 4.
When I divide it by 6, the remainder is 5.
When I divide it by 7, the remainder is 6.
When I divide it by 8, the remainder is 7.
When I divide it by 9, the remainder is 8.
When I divide it by 10, the remainder is 9.

Got the answer??
Find Answer here

Two Cords

You are given two cords that both burn exactly one hour, not necessarily with constant speed.
How should you light the cords in order to determine a time interval of exactly 15 minutes?

Source: Raphael Reischuk

Find Answer here

Buffer Overflow

Rewrite the program shown below so that it is no longer vulnerable to a buffer overflow.

int main (int argc, char *argv[]) {
    bool valid = false;
    char str1[8];
    char str2[8];

/* This is some function that assigns some string to str1 */
    next_tag(str1);    

/* Read a string from standard input device (eg. keyboard) */

    gets(str2); 
    if ( strncmp(str1, str2, 8) == 0 )

        valid = true;
    printf (“buffer1: str1(%s), str2(%s), valid(%d)n”, 
                                          str1, str2, valid);
}
Find Solution here

Subtle Bug

The variable d is less than the Total elements, but still the if condition did not evaluate to true. Find the Bug.

Code:
#include <stdio.h>
int array_one[]={1,2,3,4,5,6};
#define TOTAL_ELEMENTS (sizeof(array_one)/sizeof(array_one[0]))

int main()
{
  int d=-1;
  if(d<=TOTAL_ELEMENTS)
    printf(“d is less than Total no. of elemnts in the array”); //execution never comes her
  else
    printf(“d is greater than total elements in the array”); //this will get printed
  return 0;
}

Find Answer here

Chess Board Puzzle

You’ve got an 8×8 chess Board and a bunch of dominoes that each fit nicely on two squares of the chess Board.  You can easily tile the entire checkerboard with these dominoes. Now say that you remove two squares, one at one corner and the other at the opposite corner. You’re left with 62 squares.
Can you tile this with the dominoes?
If so, show how. If not, prove why not.

Source: www.careercup.com

Find Answer here

Swap two Variables

Swap two Variables (integers) without using a temporary variable

How to swap two integer values without using another variable?

Find Answer here