#ifdef & #endif

#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n”, some ,thing); } Answer: Compiler error : undefined symbol some Explanation: This is a very simple example for conditional compilation. The name something is not already known to the compiler making the declaration int some = 0; effectively removed from the source code.  #if something == 0 int some=0; #endif main() { int thing = 0; [Read More]

sizeof operator

**1)** Why is sizeof operator and not function sizeof() is a compile time operator. To calculate the size of an object, we need the type information. This type information is available only at compile time. At the end of the compilation phase, the resulting object code doesn’t have (or not required to have) the type information. Of course, type information can be stored to access it at run-time, but this results in bigger object code and less performance. [Read More]

Using pascal keyword

1) main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(” %d”,i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); } Answer: Compiler error: unknown type integer Compiler error: undeclared function write Explanation: **Pascal keyword doesn’t mean that pascal code can be used. It means that the function follows Pascal argument passing mechanism in calling the functions. ** 2) ** void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); [Read More]

Ratio and proportion difficult questions

1.Three containers A,B and C are having mixtures of milk and water in the ratio of 1:5 and 3:5 and 5:7 respectively. If the capacities of the containers are in the ratio of all the three containers are in the ratio 5:4:5, find the ratio of milk to water, if the mixtures of all the three containers are mixed together. Sol: Assume that there are 500,400 and 500 liters respectively in the 3 containers. [Read More]

Ratio and proportion difficult questions

1.Three containers A,B and C are having mixtures of milk and water in the ratio of 1:5 and 3:5 and 5:7 respectively. If the capacities of the containers are in the ratio of all the three containers are in the ratio 5:4:5, find the ratio of milk to water, if the mixtures of all the three containers are mixed together. Sol: Assume that there are 500,400 and 500 liters respectively in the 3 containers. [Read More]

Problems on partnership

1.When investments of A and B are Rs x and Rs y for a year in a business ,then at the end of the year (A’s share of profit):(B’s share of profit)=x:y 2.When A invests Rs x for p months and B invests Rs y for q months, then A’s share profit:B’s share of profit=xp:yq Short cuts: 1.In case of 3 A,B,C investments then individual share is to be found [Read More]

Time and Distance questions

Problems 1)A person covers a certain distance at 7kmph .How many meters does he cover in 2 minutes. Solution:: speed=72kmph=72*5/18 = 20m/s distance covered in 2min =20*2*60 = 2400m 2)If a man runs at 3m/s. How many km does he run in 1hr 40min Solution:: speed of the man = 3*18/5 kmph = 54/5kmph Distance covered in 5/3 hrs=54/5*5/3 = 18km 3)Walking at the rate of 4knph a man covers certain distance [Read More]

Trains

(1) Time taken by a train x mt long in passing a signal post or a pole or a standing man = time taken by the train to cover x mt (2) Time taken by a train x mt long in passing a stationary object of length y mt = time taken by the train to cover x+y mt (3) Suppose two trains or two bodies are moving in the same [Read More]

Multiplication Tables

1 × 1 = 1 2 × 1 = 2 2 × 2 = 4 3 × 1 = 3 3 × 2 = 6 3 × 3 = 9 4 × 1 = 4 4 × 2 = 8 4 × 3 = 12 4 × 4 = 16 5 × 1 = 5 5 × 2 = 10 5 × 3 = 15 5 × 4 = 20 5 × 5 = 25 6 × 1 = 6 [Read More]

Find all sets of consecutive integers that add up to 1000.

There are total 8 such series: 1. Sum of 2000 numbers starting from -999 i.e. summation of numbers from -999 to 1000. (-999) + (-998) + (-997) + ….. + (-1) + 0 + 1 + 2 + ….. + 997 + 998 + 999 + 1000 = 1000 2. Sum of 400 numbers starting from -197 i.e. summation of numbers from -197 to 202. (-197) + (-196) + (-195) + …. [Read More]