Monday, 17 August 2026

Introduction to Programming Laboratory (C-Programming Lab Manual)

Write C Programs for the Following Problems:

Follow these steps to compile and execute a C program on a Linux operating system. By default, Linux provides a C compiler.

->    Open a text editor from the Applications menu.

->    Write your C program according to the given problem.

->    Save the program file with a .c extension, for example,  abx.c .

->    Open the Terminal from the Applications menu.

->    Type the following command in the terminal to compile the program:

        gcc abx.c -lm

->    If the compilation generates any error messages, correct the errors in the program and compile it again.

->    If the compilation is successful, a binary executable file named a.out will be generated in the current directory.

->    Execute the binary file by typing the following command in the terminal:

        ./a.out

->    After execution, the successful output of the program will be displayed in the terminal.


Programming Manual-I

1.    Write the smallest C program that does not take any input and does not produce any output, i.e., without using any header files.

2.    Write a C program to display "Hello".

3.    Write a C program to display your Name, Stream, Department, and Institution Address in the following format using multiple printf() functions and newline characters (\n):

Example:
Name:                ABC
Stream:              EIE/ECE/IT/CSE
Department:       ABC
Institution:          ABC

4.    Write a C program to display your Name, Stream, Department, and Institution Address in the following format using a single printf() function and newline characters (\n):

Example:
Name:                 ABC
Stream:               EIE/ECE/IT/CSE
Department:        ABC
Institution:           ABC

5.    Write a C program to display the following patterns using the printf() functions and newline characters (\n):

(i)                                    (ii)

* * * * *                            1
* * * *                               2 2
* * *                                 3 3 3
* *                                   4 4 4 4
*                                      5 5 5 5 5

(iii) Hip-Hop Pattern  (iv) Pascal’s Triangle

      * * * * * * * * *                   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
        * * * * * * *    1  7   21  35   35   21  7  1
     * * * * * * * * *
     * * * * * * * * *
       * * * * * * *
          * * * * *
             * * *
               *
             * * *
           * * * * *
         * * * * * * *
      * * * * * * * * *


Programming Manual-II

1.    Write a C Program to Count the Number of Digits in a Given Integer Input by the User.

2.    Write a C Program to Reverse an Integer Entered by the User.

3.    Write a C Program to Find the Sum of the Digits of a Number Entered by the User Using a for Loop.

4.    Write a C Program to Check Whether a Number Entered by the User Is a Palindrome or Not.

5.    Write a C Program to Generate the Fibonacci Series for the Number of Terms Entered by the User.

6.    If a Four-Digit Number Is Entered Through the Keyboard, Write a C Program to Find the Sum of the First and Last Digits of the Number.

7.    Write a C Program to Find the GCD (Greatest Common Divisor or HCF) and LCM (Least Common Multiple) of Two Numbers Entered by the User.

8.    Write C programs to display each of the following patterns:

(i)                                    (ii)

* * * * *                        1
* * * *                           2 2
* * *                              3 3 3
* *                                 4 4 4 4
*                                    5 5 5 5 5

(iii)                                    (iv)

1                                      A 
1 2                                   A B
1 2 3                                A B C
1 2 3 4                             A B C D
1 2 3 4 5                          A B C D E

(v)                                            (vi)

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

(vii)                                                (viii)

1                                                  A B C D E F
1 2 1                                            A B C D E
1 2 3 2 1                                      A B C D
1 2 3 4 3 2 1                                A B C
1 2 3 4 5 4 3 2 1                          A B
                                                    A
        

(ix)                                               (x)

1                                              * * * * * * *
1 2 3                                        * * * * * *
1 2 3 4 5                                  * * * * *
1 2 3                                        * * * * 
1                                              * * * 
                                                * *
                                                *




Programming Manual-III

1.    Write a C Program to Search for an Element in an Array.

2.    Write a C Program to Find the Sum of All Elements in an Array.

3.    Write a C Program to Find the Largest and Smallest Elements in an Array.

4.    Write a C Program to Reverse the Elements of an Array.

5.    Write a C Program to Delete an Element from a Specified Position in an Array.

6.    Write a C Program to Display the Elements of a Two-Dimensional Array.

7.    Write a C Program to Add Two Matrices of User-Defined Order.

8.    Write a C Program to Multiply Two 3×3 Matrices.

9.    Write a C Program to Read a String and Check Whether It Is a Palindrome Without Using String-Handling Functions. (A string is a palindrome if it reads the same forward and backward. For example: abcdcba.)

10.    Write a C Program to Accept a String and Count the Number of Vowels Present in the String.

Programming Manual-IV

1.    Write a C Program to Add, Subtract, Multiply, and Divide Two Integers Using User-Defined Functions with Return Values.

2.    Write a C Program to Calculate the Sum of the First 20 Natural Numbers Using a Recursive Function.

3.    Write a C Program to Generate the Fibonacci Series Using a Recursive Function.

4.    Write a C Program to Swap Two Integers Using the Call-by-Value and Call-by-Reference Methods of Passing Arguments to a Function.

5.    Write a C Program to Find the Sum of the Digits of a Number Using a Recursive Function.

6.    Write a C Program to Read an Integer and Print Its Reverse Using Recursion.

7.    Write a C Program to Find the Maximum and Minimum of Two Numbers Using Functions.

8.    Write a C Program to Check Whether a Number Is Even or Odd Using a Function.

9.    Write a C Program to Check Whether a Number Is Prime, an Armstrong Number, or a Perfect Number Using Functions.

10.    Write a C Program to Find the Power of a Number Using Recursion.












AI - Soft Computing, ML, DL - Previous Year's UGC-NET Questions

UGC-NET-JUNE-2024 (Cancel) 1.     For the fuzzy sets A = { (x 1 , 0.3), (x 2 , 0.7), (x 3 , 0.4) } and B =  { (x 1 , 0.5), (x 2 , 0.2), (x 3...