Cute FTP Pro

More questions (chapters 4 to 6)

Interview and Viva questions 

  1. Explain the following data structures and distinguish between them:
    a.) Structure
    b.) Union
    c.) Array
  2. Why do we need/use functions?
  3. What’s the advantage of using a do-while loop?
  4. Is it possible to implement a ‘for’ loop as a ‘while’ loop and vice-versa?
  5. When do we use a ‘for’ loop and when do we use a ‘while’ loop?
  6. What does scope of a variable mean? Distinguish between local and global variables.
  7. Explain the following storage types:
    b.) extern
    c.) register
    d.) static
  8. What does contiguous memory location mean?
  9. Give an example of an enumerated data type.
  10. How does a ‘const’ variable differ from a macro? Which one is preferable?
  11. Give a simple example of recursion. Is an iterative alternative possible for all recursion uses?



Q.) Write a menu-based calculator to perform simple arithmetic operations. (Menu-based means that the user should be presented with a menu from which he/she can choose the operation they want to perform. After an operation is completed the menu should be redisplayed unless the user wishes to exit the program. Hint: use switch-case statement).

Q.) Write a program to display whether a given year is a leap year or not. If it is a leap year check whether it is a century leap year (i.e. the year is divisible by 4 as well as by 100). 

Q.) Write a program to display the following pyramid of stars on the screen (using loops): 

                 * * *
              * * * * *
           * * * * * * *
        * * * * * * * * *
     * * * * * * * * * * *  

Q.) Write a program to display the following numerical pyramid on the screen: (similar to the program on pyramid of stars. Instead of stars you will have to print the numbers in proper sequence). 

                 2 3 2
              3 4 5 4 3
           4 5 6 7 6 5 4
        5 6 7 8 9 8 7 6 5
     6 7 8 9 0 1 0 9 8 7 6 

Q.) Write a program to get the marks obtained in 6 subjects by a student and calculate his average percentage (remember to obtain the maximum marks possible in each subject also). 

Q.) Obtain a positive integer input from the user and display all the perfect numbers existing less than the number entered by the user. A perfect number is one whose sum of divisors will equal the number itself. For example 6 is a perfect number because 6 has the divisors 1,2 and 3. 1+2+3=6. 

Q.) Write a function that can be used to check whether a number is prime or not. 

Q.) Use loops to obtain the result of the series:

            x/1! + x2/2! + x3/3! + x4/4! + … + xn/n!

where the value of ‘n’ and ‘x’ has to be entered as command line arguments. 

Q.) Write a program to obtain a string as input and identify whether the string is a palindrome. (For example: a string ‘malayalam’ is a palindrome because the word remains the same if reversed). 

Q.) Write a program to obtain a word (in a character array) and then display the word backwards. The reversed word should be stored in another character array. 

Q.) Use a function to rotate an array of numbers. The number of positions to be rotated will be provided by the user. A positive number means that the array should be rotated to the right and a negative number means a left side rotation. For example if the user inputs an array as: 1 2 3 4 and specifies a value of +3 then the resultant display should be: 2 3 4 1. (When rotating to the right the last value should come to the first place in case we exceed the last element). 

Q.) Write a program to print the numbers from 100 to 1 without using any type of loop statement. Hint: use recursion. 

Q.) Write a program to obtain the date (as three integer values for date, month and year). The output should display the date, name of the month and the year. The output should also state the number of days in that particular month and whether the year is a leap year or not.

For example: if the user inputs the date as 11 10 1980, the output should be:

October 11,1980.This month has 31 days. This is a leap year.

(Use switch-case to display the name of the month and enclose the switch case within a function so that it can be called whenever needed). 

Q.) In the above program, provide an option such that the user can enter a certain number of days and the program should calculate and display the corresponding date. 

Q.) Use looping technique to print the alphabets from ‘a’ to ‘z’ on the screen. (Hint: use ASCII values and type conversion). 

Q.) Write a program to convert a decimal number into a binary number (keep dividing by two and the remainders will form the binary number). 

Q.) Using recursion write a program to convert a decimal number into its binary equivalent.

Q.) Write a program to store a set of names using arrays (you have to use 2-Dimension character arrays) and display the names. 

Q.) Write a program to find the greatest among ‘n’ numbers (value of ‘n’ is provided by the user). Use ternary operator. 

Q.) Create a function which will calculate the number of days between two dates present in the same year (you have to take care of leap years as well). 

Q.) Modify the above function such that you can find the number of days between two dates in different years. 

Q.) Create a simple game of Tick-Tac-Toe (also called as ‘X and 0’) made for a user to challenge the computer. The user should have a display similar to the diagram below:





             The user will choose a particular square by specifying the corresponding row and column. After the user enters his/her choice, the program should display the new diagram with the corresponding square marked. Once the user makes a move, the computer should make its move.

            The logic of the game can be improved such that the computer cannot be defeated. Also you could provide an option wherein the user can choose whether the computer should play first or not.

            (hint: use separate functions for each of the tasks like computer’s move, user’s move, checking for a win after every move, checking for a draw, displaying the diagram after every move etc. These functions can be called from within the main( ) function using looping technique. You could also use global variables).

Go back to the Contents Page

Copyright © 2004 Sethu Subramanian All rights reserved. Sign my guestbook.