You are on page 1of 17

                                                       

                                     C   PROGRAMING QUESTIONS
                                                                                                              BY  G. VEERA SHEKAR
                                           (PROGRAMS FOR LEARNERS)
                                              
                                (FUNDAMENTALS  AND CALCULATIONS)
              
1. Write a program to get the output as
                           HELLO  WORLD   WELCOME
2. Write a program to get the output as
                           He said, “ I'm   the  king ” 
3. Write a program to find the decimal,octal,hexadecimal  for a number.
4. Write a program to find the ASCII character of a number.
5. Write a program to find the ASCII code of a character.
6. Write a program to find addition,subtraction,multiplication and division of two 
numbers.
7. Write a program to swap(interchange) the values of two variables.
8. Write a program to swap(interchange) the values of two memory variables 
without using any temporary varibles.
9. Write a program to find the velocity if displacement and time are given.
                            
                            VELOCITY =  DISPLACEMENT  /  TIME
10.Write a program to find the volume of box
            
                              VOLUME  = LENGTH * BREADTH * HEIGHT
11. Write a program to calculate the area and volume of sphere
 
                    AREA =  (4     R2 ) / 3            VOLUME = (4      R3 )  / 3
12.Write a program to convert the days to months and years
13.Write a program to find the sum of  first N natural numbers .
 
                          S =  (N * (N + 1) ) / 2      OR     Sn =  n(n+1)/2
14. Write a program to find sum of cubes of first N natural numbers.
      
 S =  ( ( ( N * (N+1) ) / 2) * ( ( N * (N+1) ) / 2) )   OR  Sn=nn1/22
15.Write a program to find sum of squares of first N natural numbers.
 
   S =( N * (N+1) * ( (2*N)+1) ) / 6     OR    Sn=nn12n1/6

                                                                                                                      G.VEERA SHEKAR 
  
                                   ( FUNDAMENTAL CALCULATIONS)

16. Write a program to accept the three subject marks of  a student . calculate 
total,average and   display all.

17. Write a program to calculate the area and perimeter of a rectangle.
  
               AREA = LENGTH * BREADTH           PERIMETER = 2 * (LENGTH + BREADTH)
18. Write a program to calculate the area and circumference of circle.
  
                 A =   R2      C =  2  R
19.Write a program to calculate the area of triangle 
1
                  A =   B  H
2
20.Write a program to calculate the area of scalene  triangle.
           
                    A =   ss−as−bs−c           where s = ( a + b + c ) / 2
21.  Write a program to convert the temperature from farhenheit  to centigrade
                           
5
                                     C = (F – 32)          
9
22. Write a program  to convert the temperature from centigrade to farhenheit  

9C
                        F  =   + 32
5
23. Write a program  to calculate the simple interest  using the formula
       
                                      SI = P T R / 100
24. Write a program to find the distance between  two points

                  d =    X 2−X 1 2Y 2−Y 12 


25. Write a program to calculate an employee's  da,hra,pf,net   by giving the basic 
salary and  display all
                     
                   da 20%  hra 30%   pf 5%
26. Write a program  to calculate commision (20 % of sales amount ), net salary by 
giving   basic salary and sales amount
27.  Write a program  to read  the previous and present meter reading.  calculate the 
number of  units,bill amount (2.50 per unit) and display all    
28. Write a program to find the real roots of a quadratic equation
    
                                          ( CONDITIONAL STATEMENTS )

1. Write a program to check whether the given number is zero or not.
2. Write a program to check whether the given  is even or odd.
3. Write a program to check whether the given number is positive  or negative or not 
4. Write a program to find the biggest of two numbers.
5. Write a program to find the smallest of two numbers.
6. Write a program to find the smallest of three numbers
7. Write a program to find the biggest of five numbers.
8. Write a program to find the biggest and smallest of the given five numbers.
9. Write a program to find the quadratic equation roots.
10.Write a program to check whether the given character is one of alphabets or not
11. Write a program to check whether the given character is in uppercase or lowercase 
or a digit.
12.Write a program to find the total,average,result and division of a student by giving 
his three subject marks.
13.A company offers the HRA,DA,PF as  follows

               if  BASIC<5000 ==>  HRA=10%     DA=37%     PF=20%
     5000<=BASIC<10000 ==>  HRA=8%       DA=38%     PF=12%
    10000<=BASIC<15000==>  HRA=7%       DA=39.5%  PF=10%
 
 calculate the gross and net salary by giving the basic salary.
14.  Write a program to calculate the amount payable by an electricity consumer

     TYPE                        MIN                        EXTRA
House Holder               60 units                   2.00 / unit
                                                1.50 / unit 

            Business                     100 units                    3.00 / unit
                                               2.00 / unit   

            Industrial                   300 units                     6.00 / unit 
                                              5.00 / unit 
              

                                                                                                                                   G.VEERA SHEKAR 
                            (LOOPING)
   
1. Write a program to display welcome continuously(using do­while,while,for 
loops).
2. Write a program to display the first 10 natural numbers(using do­while).  
3. Write a program to display the odd numbers below the given number.
4. Write a program to display the Even numbers up to the given number and find the 
sum of them.
5. Write a program to display the ASCII chart.
6. Write a program to display the Multiplication table of the given number.
7. Write a program to display all the multiples of 5 up to the given numbers.
8. Write a program to find the Factorial value of the given numbers.
9. Write a program to display all the odd numbers up to the given number bellow the 
reverse order.
10.Write a program to find the sum of natural,Even and Odd numbers up to the given 
number.
11. Write a program to find the factors of given number.
12.Write a program to check whether the given number is perfect number or not. 

Perfect number:A number which is same as the sum of the factors.

13.Write a program to check whether the given number is Prime number or not. 

Prime number:A number which is divisible by 1 and itself only.

14. Write a program to find the number of digits and the sum of digits of a given 
number.
15.Write a program to find the reverse of a given number and check whether it is 
Palindrome or not.
16. Write a program to check whether the given number is Armstrong number or not.

Armstrong number:A number which is same as the sum of cubes of digits.

17. Write a program to display the table of natural numbers,squares,cubes and square 
roots upto the given numbers.
18. Write a program to  display the Fibonacci series upto the given numbers.

1 1 2 3 5 8 13 21 34 55
19.Write a program to find x^y.
                (NESTING OF LOOPS)

1. Write a program to generate the multiplication tables up to  the given number.

2. Write a program to display the Armstrong numbers below the given number.

3. Write a program to display the perfect numbers up to the given number.

4. Write a program to display the first N Prime numbers.

5. Write a program to display the prime numbers below the given number.

6. Write a program to display the Strong number.(145=>1! + 4! + 5!)

7. Write a program to display the Strong numbers  up to the given number.

8. Write a program to display the Automorphic numbers.

9. Write a program to display the Emicable numbers.

10.Write a program to display the Integer Palindromes below N.

11. Write a program to display the sum of prime numbers below N.

12.Write a program to display the All composite numbers below N.

13.Write a program to display the sum of first N composite numbers

14. Write a program to display the nCr=n! /r!(n­r)!.

15.Write a program to display the all the common factors of A and B.

16. Write a program to print all the twin composite numbers below the given number

17. Write a program to print all the possible numbers of x,y and z that satisfies the 
equation

                                              2 X + Y – 3 Z = 0.
18. Write a program to display all the combinations of 1,2and 3.
                                                          (LOOPS)
Write the  programs  to find the solutions for these series when n is given

1 2 3 4 n−1
1.    .........
2 3 4 5 n

1 2 3
2.   ...........
2−3 3−4 4−5

1 2 3 4
3.   1    ............
x x x x

4. 1 ! + 2 ! + 3 ! + 4 ! + 5 ! ...................... n!.

1 2 3
5. 1  2  3 ...............
x x  x 

3 5 7
x  x  x 
6. Sin x =  x−  − ............
3 ! 5! 7!
2 4 6
 x  x  x 
7. Cos x=    1−  − ............
2! 4! 6!
2 3 n
x  x  x  x 
8. e =1x  ..........
2! 3! n!

                                                                                                                                     G.VEERA SHEKAR 
                                                
                                                   (PYRAMID FORMATS)
     
       Write a program to print these formats
1. 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

2. 1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

3. 1
2 3
4 5 6
7 8 9 10
            11 12 13 14 15

      4.   1
2 1
3 2 1
4 3 2 1
5 4 3 2 1

      5.   5 4 3 2 1
            4 3 2 1
3 2 1
2 1
1

      6.   5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
      
      7.                                                    1
                                    2          1
                        3          2          1
           4           3          2          1
5         4           3          2          1
                                                                                                                                 G.VEERA SHEKAR 
      
        8.                                                 1
                                    1          2
                        1          2          3
           1           2          3          4
1         2           3          4          5

      9.                                                   1
                                                2          2
                                   3           3          3
                     4            4           4          4
           5        5            5           5          5
   
     10. *
           *         *
           *         *          * 
           *         *          *           *
           *         *          *           *           *
      
     11.                        *  

              *             *
     *              *            *
*            *             *            *      
       *         *             *             *            *
    
12.                                             *
                                  *        * 
                         *       *        *
                 *      *       *        *
        *       *      *       *        *  
13. A
A       B
A        B       C  
A        B       C        D
A        B       C        D       E           
     
     14.  A
B        B
            C        C        C
            D        D        D       D
            E         E        E        E        E

                                                                                                                         G.VEERA SHEKAR
     
     
     15.  E         D        C       B        A
E         D        C       B
E         D        C
E         D
E  

    
     16.  1         1        1        1         1
2         2        2        2         
3         3        3         
4         4
5        
  

     17.   A      B     C     D     E     D     C    B    A 
A      B     C     D             D     C    B    A
A      B     C                             C    B    A
A      B                                           B     A 
A                                                           A      

    
     18.  1
0    1
1    0    1 
0    1     0     1
            1    0     1     0      1       
     
     19.  5
4     4
3     3      3
2     2      2      2 
1     1      1      1      1

20. PASCAL'S  TRAINGLE
             
                                         1
                                     1      1
                                 1      2       1
                              1     3      3       1
                          1      4     6      4        1
                      1      5    10     10     5        1
                 1       6    15     20     15    6        1
                                                                                                                                   G.VEERA SHEKAR
                                                        (FUNCTIONS)
     NOTE :
                Calling  a function is 4 types 

         ­­­>  Function calling without arguments and return values.

         ­­­>  Function calling with arguments and without return values.

         ­­­>  Function calling without arguments and with return value. 

         ­­­>  Function calling with arguments and return values.

   Write all the conditional and looping programs using the possible types of functions.
       
                                                     
                                                            (RECURSIONS (do after arrays))    
    
1. Write a program to find the factorial value of the given number.

2. Write a program to find the sum of two non­negative integers.

3. Write a program to find   x y

4. Write a program to find the reverse of a number and sum of digits of given number.

5. write a program to find the binary format of the given decimal number.

6. Towers of Honai

7. G.C.D of two numbers

8. Fibonacci  series

9. Binary search

                                                                                                                                    G.VEERA SHEKAR
                                                                    (ARRAYS)

1. Write a program to create a 5 cells single dimensional array assign 9 to all cells 
and display all.
2. Write a program to create a 10 cells single dimensional array accept the elements 
and didsplay all.
3. Write a program to accept elements for 5 cells single dimensional array add 2 to 
each element 
and  display them in reverse order.
4. Write a program to add two 5 cells single dimensional arrays.
5. Write a program to find the sum and average of a 10 cells single dimensional 
array.
6. Write a program to find maximum and minimum of a 10 cells single dimentional 
array.
7. Write a program to place the sum of 9 cells in a 10 cells single dimensional array 
and  place
the sum in last cell(10 cell) and display all.
8. Write a program to find mean and standard deviation of the elements of a 10 cells 
single dimensional array.


2
m−x i  
                                        S.D =   
x i
9. Write a program to replace an element  with a new one.
10.Write a program to insert a number in the middle of an array.
11. Write a program to delete a number from an array.
12.Write a program to eliminate zero's from an array.
13.Write a program to move all zero's to last position.
14. Write a program to find the first maximum and second maximum.
15.Write a program to align the prime numbers to an array.
16. Write a program to find frequency of number in an array.
17. Write a program to reverse the elements in an array.
18. Write a program to sort elements  in an array using linear sorting  method. 
19.Write a program to sort elements in an array using bubble sort or Exchange sort 
method.
20.Write a program to sort elements in an array using selection sorting method.
21. Write a program to sort elements in an array using insertion sorting method.
22.Write a program to search an element using linear search method.
23.Write a program to search an element using binary search method.
24.Write a program to sort two arrays of 5 cells and after sorting merge them into a 
single array.
25.Write a program to delete the duplicate(redundant elements). elements in an array.
                                                              (STRINGS)

1. Write a program to accept string and display.

2. Write a program to find length of a string.

3. Write a program to change the given string to upper case.

4. Write a program to change the given string to lower case.

5. Write a program to change the given string to sentence case and title case.

6. Write a program to copy a string to another.

7. Write a program to concatenate two strings.

8. Write a program to reverse a string.

9. Write a program to check whether it is palindrome or not.

10.Write a program to count the number of words,alphabets,digits in a string.

11. Write a program to convert number to words . (123 ==> one two three)

12.Write a program to count no of vowels and consonents of a string.

13.Write a program to remove leading and tailing spaces of a string.

14. Write a program to sort  a list of names alphabetically.

15.Write a program to check whether the a string is substring of another string.

16. define a function to find the substring by giving the string,position,no of 
characters

                 
                                                                                                                                      G.VEERA SHEKAR
                                                          (POINTERS)            
 
1. Simple programs on the operators (*,&).

2. Demo on assigning address of memory variables to pointers

3. Write a program for functions with pointers

4. Write a program for call by value , call by reference

5. Write a program for swapping two memory variables

6. Write a program for functions to change the values of two or more variables

7. Write a program for passing arrays as pointers to functions

8. Write a program for demo to prove arrays are pointers

9. Write a program for maximum & minimum in an array

10.Write a program for dynamic memory allocation

11. Write a program for to compute the and averages of N numbers 

12.Write a program for all the arrays programs using pointers and functions

13.Write a program for VDU  memory  OxB8000000

14. Write a program keyboard memory Ox417  
      

                  
                                                                                                                                    G. VEERA SHEKAR 
                                                            (STRUCTURES)
1. Simple structures and acessing it's elements.

2. Write a program of structures using 'typedef '.

3. Write a program declaring structures as global.

4. Write a program for calling functions with structures

5. Write a program passing address of structure variables of functions.

6. Write a program functions returning structure variables.

7. Write a program structure within structures.

8. Write a program for pointers to structures.

9. Write a program for array of structures.

10.Write a program for processing employee's records.

11. Sort the records using members.

12.Write a program for self referential structures.
                                                            MACROS
1. To calculate factorial.

2. To draw a line.

3. to calculate  x y    

4. Nested MACROs

5. Exercise with programs listed in functions.

     Note:
         
➔ Practice with  other topics like enums,unions,preprocessor
                                                                (FILES)
1. Write a program to create a file and store some characters.

2. Write a program to read characters from file.

3. Write a program to count the no of characters in a file.

4. Write a program to count the no of lines,words in a file.

5. Write a program to count the no of uppercase,lowercase,digits,special characters 
in a file.
6. Write a program to write some strings to a file.

7. Write a program to read string from file.

8. Write a program to copy text from a file to another.

9. Write a program to read text from file ,change case and copy to another.

10.Write a program to write student info to a file .(without using structures)              

11. Write a program to write student info to a file .(using structures)

12.Write a program to read student info to a file .(without using structures

13.Write a program to read student info to a file .(using structures.

14. Write a program to delete a record from a file.

15.Write a program to edit a record in a file.

16. Write a program to add two files and write them to a new file.

17. Write a program to write odd and even numbers to two different files.

18. Write a program to delete a file.

19.Write a program to rename a file.

20.Write a program to search a file in a directory.
                                                       (SCREEN DISPLAY)
  
1. Write a program to display a horizontal line(196).
          hint : printf(“%c”,196);

2. Write a program to display a single vertical line(179).
          hint : printf(“%c”,179);

3. Write a program to draw horiozontal  double line(205).

4. Write a program to draw vertical double line(186).

5. Write a program to fill a rectangular region with the given character.

6. Write a program to clear a rectangular region.

7. Write arrow programs.

8. Write scrolling programs    

9. Write a program to display ASCII chart within a box.

10.Write a program using
 textcolor,textbackground,sound,cprintf,window,random,randomize.

                                                       
        

                                                                                                                                     G.VEERA SHEKAR
                                              (COMMAND LINE ARGUMENTS)                                   

1. Write a program to display the arguments.

2. Write a program to find sum of numbers.

3. Write a program to sort some strings.

4. Write a program to sort some integers.

5. Write a program to execute a valid DOS command.

6. Write a program to show the contents of a file.

7. Write a program to create a file and store  text.

8. Write a program to copy contents of a file to another.

9. Write a program to encode/decode a file.

10.Write a program to display a directory.

11. Write a program to display the attributes of files.

12.Write a program to delete file in directory or subdirectries.

     Note:­
           
         Above programs input should be from command line only.

                                  
                                                                            By
                                                                                   G.VEERA SHEKAR

You might also like