C Programming Exercises- Practice Questions with Solutions

1. Write a C Program to check two numbers are equal or not.

Solution:

Output:

Numbers are not equal

OR

Output-1:

Enter two numbers: 45 45

Numbers are equal

Output-2:

Enter two numbers: 23 12

Numbers are not equal

2. Write a C program to find the larger number among two numbers.

    OR

    Write a program in C to find the maximum number between two numbers.

    Solution:

    OR

    Output:

    Enter 2 numbers: 23 34

    Larger number :34

    3. Write a program in C to check whether a number is even or odd.

      Solution:

      Output-1:

      Enter a number: 4

      4 is an even number

      Output-2:

      Enter a number: 5

      5 is an odd number

      4. Write a C program to check whether a year is leap year or not.

        Solution:

        Output-1:

        Enter a year: 2020

        2020 is a leap year

        Output-2:

        Enter a year: 2025

        2025 is not a leap year

        5. Write a program in C to check if a number is Positive, Negative or Zero.

          Solution:

          6. Write a C program to input a number between 1-7 and print the corresponding day of a week (day name).

            Solution:

            7. Write a program in C to find the greatest number among three numbers.

            Solution:

            Output:

            Enter three numbers: 12 24 46

            The greatest number is 46

            8. Write a C program to check a character is vowel or not using if-else.

            Solution:

              9. Write a C program to classify a person’s age group and determine if they are eligible to vote. A person under 18 is a minor, between 18 and 60 is an adult and above 60 is a senior. Only adults and seniors are eligible to vote.

              Solution:

              Output-1:

              Enter age: 15

              Category: Minor

              Not eligible to vote

              Output-2:

              Enter age: 50

              Category: Adult

              Eligible to vote

              Output-3:

              Enter age: 70

              Category: Senior

              Eligible to vote

              10. Write a program in C to input marks of three subjects of a student. Calculate total marks and percentage and display grade. The student get grade as per the following conditions:

                Percentage             Grade

                Above 90                 A+

                80-90                        A

                70-79                        B

                60-69                        C

                50-59                        D

                Below 50                  F 

                Solution:

                Leave a Comment