There are a few common questions which may be asked in interviews for your Computer Society in college, or a company! So if have an interview lined up, go through these. All the best!
1. Write a program to print “Hello world!” without using a single semicolon.
void main()
{
if(printf(“Hello world!\n”))
{}
}
Explanation: The printf() function returns the number of characters it has printed. Since that is an integer, it can be used in combination with the if statement to printf the desired result without using a semicolon.
2. Swap 2 integers without using a temporary variable.
A common solution is,
a = a+b
b = a-b
a = a-b
Example: Let a=5 and b=7.
On a=a+b, a=12 and b=7.
On b=a-b, a=12 and b=5.
On a=a-b, a=7 and b=5.
Both the numbers have been swapped.