Programming Language in C Practical List

Section – 1 (Introduction, Constant, Variables, Data Types, Operators, Expressions, Decisions Making, Branching and Looping)       (Answer any two)                                        15 ´ 2 = 30


(a)   Write a program to find the area of a circle. (Use p as a symbolic constant).

(b)   Write a program to convert the given temperature in Fahrenheit to Celsius and vice versa.

(c)   Write a program to find the all-possible roots of a quadratic equation.

(d)   Write a program that takes a floating-point number as input and display the floating point and integer part separately.

(e)   Write a program to find the factorial of an integer.

(f)   Write a program that takes an integer as input and display it in reverse order.

(g)   Write a program to convert any integer to its binary equivalent.

(h)   Write a program in C to determine and print the sum of the following harmonic series for a given value of n : s = 1 + 1/22 + 1/33 …….. + 1/nn.

(i)    Given an integer number, write a program that displays the number as follows :

First Line       : all digits

Second Line   : all excepts first digits

Third Line      : all excepts first two digits


Last Line        : the last digit.

For example, the number 5678 will be displayed as :

5         6          7          8

6         7          8

7         8


(j)    Write a program in C that prints the smallest of the three numbers.

(k)   Write a program in C to compute the sum of the digits of a given integer number. For example, if the input number is 123 then output should be 6.



Section – 2 (Arrays, Character Arrays, Strings, User-Defined Functions and Structures) (Answer any one)                                                                                                                15 ´ 1 = 15


(a)   Write a program to multiply two matrices.

(b)   Write a program to initialize all the diagonal elements of a two-dimensional array to 1 and others to 0.

(c)   Write a program that reads a string from keyboard and determines whether it is a palindrome or not.

(d)   Write a program to evaluate the expression using user defined function:

f(x) = x-x3/3! + x5/5!-x7/7!+…..

(e)   Write a program to find the first n Fibonacci numbers.

(f)   Write a program using an array of structure to read the number of three subjects for n students and sort them according to their position. (1st, 2nd, 3rd ……)

(g)   Given two one-dimensional arrays A and B which are sorted in ascending order. Write a program to merge them into a single sorted array C that contains every item from arrays A and B, in ascending order.

(h)   Write a program to copy one string into another and count the number of characters copied.

(i)    Write a program in C to concatenate the three arrays namely first-name, second-name, third-name into one string to be called name.


Section – 3 (Pointers and File Management) (Answer any one)                                  15 ´ 1 = 15


(a)   Write a program using pointers to read  an array of integers and print its elements in reverse order.

(b)   Write a program using pointers to compute the sum of all elements stored in an array.

(c)   Write a program to copy the contents of one file into another.

(d)   Write a program to read data from keyboard, write it to a file called, INPUT, again read the same data from the INPUT file and display it on the screen.

(e)   Write a program that appends one file at the end of another.

(f)   Write a program to open a file named INVENTORY and store in it the following data :

Item Name                  Number                    Price                   Quantity

AAA-1                        123                       15.55                       150

BBB-2                        125                       36.12                       175

CCC-3                        527                       32.15                       115

Extend the program to read this data from the file INVENTORY and display the inventory table with the value of each item.

CodeBlocks – C and C++ Compiler Software

  1. Download and install Compiler software (CodeBlocks). your  version compatible with your system. Notice ‘mingw’ word in the file name. Because ‘mingw’ is the compiler included in CodeBlocks software.
    Ex: codeblocks-20.03mingw-setup.exe
  2. Open New file ( File >> New >> Empty file )
  3. Save the file ‘welcome.c’ or ‘welcome.cpp’
  4. Write the sample code given below:
    C Program File Name: welcome.c
    void main()
    printf("Welcome to C Programming!");

    C++ Program File Name: welcome.cpp
    using namespace std;
    int main()
    cout << "Welcome to C++ Programming!";
    return 0;
  5. Compile/Build the file ( Build Menu >> Build ) or keyboard Shortcut ‘Ctrl+F9’
  6. Run/Execute the file (Build Menu >> Run ) or keyboard Shortcut ‘Ctrl + Shift + F9’
  7. Success! Your are ready for programming.