# Tricky programming questions for interview

Going for an interview and worried? Do not panic. I have brought something useful for you. In most technical interviews candidates are asked to solve programming questions. You are given a short period of time for solving them. Most of the time they will not ask you to solve a lengthy questions having a large LOC (Lines of Code ) instead they will ask you tricky programming questions. By doing so they will check to what extent you know about its domain. You need to revise your logic before going for an interview. I have collected some of the tricky programming questions from my personal experience and from my friends. Please have a review on this and i hope that it will really help you to improve your logics.

Following  are some tricky programming questions

Program to print hello without using semicolumn

void main()

{

switch(printf(“Hello “))

{

}

}

Program to add two numbers without using arithmetic operator

{

int a=3,b=5;

While(b–)

a++;

cout<<” Sum of two numbers is”<<a;

}

Program to swap two mumbers without using a temporary variable

#include<iostream.h>

int a=4,b=5;

a=a+b; //a=9

b=a-b; //b=4

a=a-b; //a=5

cout<<“After swapping”;

cout<< a;

cout<<b;

}

Program to find largest of 2 numbers without using if-else

void main()

{

cin>>a>>b;; //let a=3and b=2

float c=|(a+b)|/2+|(a-b)|/2; //c=2.5+0.5=3.0

cout<<“largest number is”<<c;

}

Program to print the pattern:

*

*  *

*  *  *

*  *  *  *

void main()

{

char st=’*’;

int n=4;

for(int i=1;i<=5;i++)

{

for(int s=n;s>=1;s–)

{

cout<<“”;

}

for(int j=1;j<=i;j++)

cout<<st;

}

cout<<“\n”;

–n;

}