You are on page 1of 5

Top 50 Questions of Basic C programming Here I am discussing top 50 questions of

basic C programming asked in the techni cal interview. Prepare these question
before appearing in the interview. 1. Write a program to print numbers from 1 to
100 without using loops 2. Write a C program to swap two variables without using a
temporary variable . 3. What is the 8 queens problem? Write a C program to solve
it? 4. Write a C program to print a square matrix helically. 5. Write a C program
to reverse a string. 6. Write a C program to reverse the words in a sentence in
place. 7. Write a C program generate permutations. 8. Write a C program for
calculating the factorial of a number. 9. Write a C program to calculate pow(x,n)?
10. Write a C program which does wildcard pattern matching algorithm. 11. How do
you calculate the maximum sub array of a list of numbers? 12. How to generate
fibonacci numbers? How to find out if a given number is a Fibonacci number or not?
Write C programs to do both. 13. Solve the Rat In A Maze problem using
backtracking. 14. What Little-Endian and Big-Endian? How can I determine whether a
machine s b yte order is big-endian or little endian? How can we convert from one
to another ? 15. Write C code to solve the Tower of Hanoi problem. 16. Write C code
to return a string from a function. 17. Write a C program which produces its own
source code as its output. 18. Write a C program to convert from decimal to any
base (binary, hex, oct et c ). 19. Write C code to check if an integer is a power
of 2 or not in a single lin e? 20. Write a C program to find the GCD of two
numbers. 21. Write code to remove duplicates in a sorted array. 22. Find the
maximum of three integers using the ternary operator. 23. How do you initialize a
pointer inside a function? 24. Write C code to dynamically allocate one, two and
three dimensional arrays (using malloc()). 25. How would you find the size of
structure without using sizeof()? 26. Write a C program to multiply two matrices.
27. Write a C program to check for palindromes. 28. Write a C program to convert a
decimal number into a binary number. 29. Write C code to implement the Binary
Search algorithm. 30. Write code to evaluate a polynomial. 31. Write code to add
two polynomials. 32. Write a program to add two long positive numbers (each
represented by link ed lists). 33. How do you compare floating point numbers? 34.
What s a good way to implement complex numbers in C? 35. How can I display a
percentage-done indication on the screen? 36. Write a program to check if a given
year is a leap year or not? 37. Is there something we can do in C but not in C++?
38. How to swap the two nibbles in a byte ? How to generate the next prime aft er a
given prime? 39. How to scan a string till we hit a new line using scanf()? 40.
Write pseudocode to compare versions (like 115.10.1 vs 115.11.5). 41. How do you
get the line numbers in C? 42. Write your own sqrt() function in C. 43. Write a
simple piece of code to split a string at equal intervals. 44. Is there a way to
multiply matrices in lesser than o(n^3) time complexity? 45. How do you find out if
a machine is 32 bit or 64 bit? 46. Write a program to have the output go two places
at once (to the screen an
d to a file also). 47. How can we sum the digits of a given number in single
statement? 48. Given two strings A and B, how would you find out if the characters
in B w ere a subset of the characters in A? 49. Write a program to merge two arrays
in sorted order, so that if an integer is in both the arrays, it gets added into
the final array only once. 50. Write your own trim() or squeeze() function to
remove the spaces from a st ring. Important Interview Questions (Network, Testing,
Technical and C, C++) * * * * * * * * * * * * * * * * Why paging is used ? Which is
the best page replacement algo and Why ? WHat is software life cycle ? How much
time is spent usually in each phases and why ? What is testing ? Which are the
different types of testing ? Which are the different phases in Software life cycle
(asked again) Why is analysis and testing phases very important ? Why networks are
layered ? What is the advantage of that ? How many layers are there in OSI ? Why is
it called OSI model ? Network topologies ? Which are the different network
toplogies ? An example of bus type network. What is the Bandwidth of ethernet ?
Explain the advantage and disadvantage of ethernet ? Which is the protocol used in
ethernet. (CSMA/CD) Why is it called so ?

* What is the advantage of Ring network ? Compare it with ethernet. * * * * * * * *


eck * Which one is not related to Data link layer? * Which one is not suitable for
clientserver application? tcp/ip,message pas sing,rpc,none of the above. * Term
stickily bit is related to a)kernel b)undeletable file c)deletable file d)none What
is inheritance, encapsulation etc. If there are too many page faults what is the
problem? To ensure one pgm. doesnt corrupt other pgm. in a Multipgm. enviornment
What you should do? Which one you will use to implement critical section? Binary
Semaphore Which one is not needed for Multipgm. enviornment? Options are: virtual
memory,security,time sharing,none of the above. Which one is not done by Data link
layer ? bit stuffing, LRC,CRC,parity ch

* Semaphore variable is different from ordinary variable by ? * Unix system is


a)multi processing b)multi processing ,multiuser c)multi processing
,multiuser,multitasking d)multiuser,multitasking * x.25 protocol encapsulates the
follwing layers a)network b)datalink c)physical d)all of the above
e)none of the above * TCP/IP can work on a)ethernet b)tokenring c)a&b d)none * A
node has the ip address 138.50.10.7 and 138.50.10.9.But it is transmitti ng data
from node1 to node2only. The reason may be a)a node cannot have more than one
address b)class A should have second octet different c)classB " " " " " d)a,b,c *
The OSI layer from bottom to top for an application which exceeds 64k the memory
model should be a)medium b)huge c)large d)none * The condition required for dead
lock in unix sustem is Setuserid is related to (in unix) * Wrong statement about c+
+ a)code removably b)encapsulation of data and code c)program easy maintenance
d)program runs faster * Which is true a)bridge connects dissimiler LAN and protocol
insensitive b)router " " " " " c)gateway " " " " " d)none of the above * const char
* char * const What is the differnce between the above two?. * * * * * * * About
fork()? About send message and post message Message to limit the size of window
System call executable binary file intoa process About GDI object?. API used to
hide window Initialize contents of a dialog?.

C SKILL SET:* How do you write a program which produces its own source code as its
outp ut? * How can I find the day of the week given the date? * Why doesn't C have
nested functions? * What is the most efficient way to count the number of bits
which are set in a value? * How can I convert integers to binary or hexadecimal? *
How can I call a function, given its name as a string? * How do I access
commandline arguments?
* * * * * * * *

How can I return multiple values from a function? How can I invoke another program
from within a C program? How can I access memory located at a certain address? How
can I allocate arrays or structures bigger than 64K? How can I find out how much
memory is available? How can I read a directory in a C program? How can I increase
the allowable number of simultaneously open files? What's wrong with the call
"fopen("c:\newdir\file.dat", "r")"?

You might also like