You are on page 1of 6

Technical Interview Questions:

What is your strongest and favorite programming language?


Difference b/w C and Java?
What are the different storage classes in C?
o ***Extern, register , auto and static****
How do you print an address? Ans: %p in printf to print the address.
What are macros ? what are its advantages and disadvantages?
o Ans: Macros are processor directive which will be replaces at compile
time.
The disadvantages with macros is that they just replace the code they are not
function calls.
Similarly the advantage is they can reduce time for replacing the same
values.
Difference b/w call by reference and pass by value?
Ans: Paas by value just passes the value from caller to calling function
so the called function cannot modify the values in caller function.
o But pass by reference will pass the address to the caller function
instead of value if called function requires to modify any value it can
directly modify.
Write syntax of switch? Can I write the syntax without default?
What is the benefit of using an enum rather than a #define constant?

The use of an enumeration constant (enum) has many advantages over using the
traditional symbolic constant style of #define. These advantages include a lower
maintenance requirement, improved program readability, and better debugging
capability. The first advantage is that enumerated constants are generated
automati- cally by the compiler. Conversely, symbolic constants must be manually
assigned values by the programmer. For instance, if you had an enumerated
constant type for error codes that could occur in your program, your enum definition
could look something like this:
What is the difference between array_name and &array_name?
One is a pointer to the first element in the array; the other is a pointer to the array
as a whole.
An array is a type. It has a base type (what it's an array of ), a size (unless it's an
"incomplete" array), and a value (the value of the whole array). You can get a
pointer to this value:
What is pointer?
o Ans: Pointer is a variable in a program is something with a name, the
value of which can vary.
o The way compiler and linker handles this is that it assigns.
o A specific block of memory within the computer to hold the values of
that variable.

What is the diff b/w null and void pointer?


Ans: Null pointer has the value 0. Void is generic pointer introduced by ANSI.
Generic pointer can hold the address of any data type.
Diff b/w Arrays and structures?
What is Data structures and why we are learn and where we can use those?
What are the sorting techniques are available?
Advantages of macros over function?

Write a c program to print Hello world without using any semicolon.


Ans: Solution: 1
void main(){
if(printf("Hello world")){
}
}
Solution: 2
void main(){
while(!printf("Hello world")){
}
}
Solution: 3
void main(){
switch(printf("Hello world")){
}
}
Swap two variables without using third variable.

#include<stdio.h>
int main(){

int a=5,b=10;
//process one
a=b+a;
b=a-b;
a=a-b;
printf("a= %d

b=

//process two
a=5;
b=10;
a=a+b-(b=a);
printf("\na= %d
//process three
a=5;
b=10;
a=a^b;
b=a^b;
a=b^a;
printf("\na= %d

%d",a,b);

b=

%d",a,b);

b=

%d",a,b);

b=

%d",a,b);

//process five
a=5,
b=10;
a=b+a,b=a-b,a=a-b;
printf("\na= %d b=

%d",a,b);

//process four
a=5;
b=10;
a=b-~a-1;
b=a+~b+1;
a=a+~b+1;
printf("\na= %d

return 0;
}
Why we use do-while loop in c? Also tell any properties which you know?
What is the meaning of prototype of a function?

Prototype of a function
Declaration of function is known as prototype
function. Prototype of a function means

of

(1) What is return type of function?


(2) What parameters are we passing?
(3) For example prototype of printf function is:
int printf(const char *, );
I.e. its return type is int data type, its first
parameter
constant
character
pointer
and
second
parameter
is
ellipsis
i.e.
variable
number
of
arguments.
Write a c program to find size of
structure without using sizeof operator?

Explanation:
struct ABC{
int a;
float b;
char c;
};
int main(){
struct ABC *ptr=(struct ABC *)0;

ptr++;
printf("Size of structure is: %d",*ptr);
return 0;
}
1. Write a program to find factorial of the given number...
2. Write a program to check whether the given number is even or odd.
3. Write a program to swap two numbers using a temporary variable.
4. Write a program to swap two numbers without using a temporary variable.
5. Write a program to swap two numbers using bitwise operators.
6. Write a program to find the greatest of three numbers.
7. Write a program to find the greatest among ten numbers.
8. Write a program to check whether the given number is a prime.
9. Write a program to check whether the given number is a palindrome c number.
10.Write a program to check whether the given string is a palindrome .
11.Write a program to generate the Fibonacci series.
12.Write a program to print"Hello World"without using semicolon anywhere in the code.
13.Write a program to print a semicolon without using a semicolon anywhere in the code.
14.Write a program to compare two strings without using strcmp() function.
15.Write a program to concatenat e two strings without using strcat() function.
16.Write a program to delete a specified line from a text file.
17.Write a program to replace a specified line in a text file.
18.Write a program to find the number of lines in a text file..
19.Write a C program which asks the user for a number between 1 to 9 and shows the number. If the
user
inputs a number out of the specified range, the program should show an error and prompt the user
for a
valid input.
20.Write a program to display the multiplica tion table of a given number..
21.WAP to check a string is Caliondrom e or not. // Maventic question.
22.WAP to print DONE,witho ut using any loop. // asked to my frnd in any company.
23.WAP to print DONE,witho ut using any loop and any conditonal clause or operators. // asked to
me as a cross question of 22th question by the person i asked 22th ques.

24. WAP to find out the longest word in a string.


25.Prog of WORLD MAP. // this code was written by someone,i forgot his name,he won award for
this code as short and best c code. JUST FOR FUN //
26.WAP to print the triangle of letters in increasing order of lines..
27.WAP to print'xay'in place of every'a'in a string.// DOC Update on 24-jan-12.
28.Count the Total Number of 7 comming between 1 to 100.
/* I made this code in a way that u can give Upper limit i.e. 100,Lower limit i.e. 1 and the specific
number u wants to count in between i.e. 7 */ // asked by: Vishwa Pratap Rana..
29. Code for duplicate' s removal,by Amit Aru.. // Similar question was asked in Maventic 2nd round
to me,,
30. WAP to find out if a given number is a power series of 2 or not,withou t any loop and without
using % modulo operator..