0% found this document useful (0 votes)
4 views

C_progr_Exercises

The document outlines several programming exercises in C, including determining leap years, a grading system based on student scores, generating the Fibonacci series, performing basic arithmetic operations, calculating factorials using recursion, and using switch cases for day names. Each exercise specifies the required input and output, as well as the logic to be implemented. The exercises aim to enhance programming skills through practical applications of conditional statements, loops, and functions.

Uploaded by

Edisthon Nshuti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C_progr_Exercises

The document outlines several programming exercises in C, including determining leap years, a grading system based on student scores, generating the Fibonacci series, performing basic arithmetic operations, calculating factorials using recursion, and using switch cases for day names. Each exercise specifies the required input and output, as well as the logic to be implemented. The exercises aim to enhance programming skills through practical applications of conditional statements, loops, and functions.

Uploaded by

Edisthon Nshuti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercises:

1. Using the if condition in C programming. Write a program that determines if a given year is a
leap year or not.

Project Overview

The program will:

 Prompt the user to enter a year.


 Determine if the year is a leap year based on the following rules:

 A year is a leap year if it is divisible by 4.


 However, if the year is divisible by 100, it is not a leap year, unless it is also
divisible by 400.
2. Uses if-else statements in C programming: a Basic Student Grading System. This program
will take the student's score as input and determine the corresponding grade based on
predefined ranges. The student’ score should be between 0 and 100. Grading is starting from
A To D, any other case the student Fails.

 Input the student's score.


 Output the corresponding grade.
 Display messages based on the score.
2. Write a program to generate the Fibonacci series, which is a sequence of numbers where each
number is the sum of the two preceding ones.

The program will:

 Prompt the user to enter the number of terms they want in the Fibonacci series.
 Use a for loop to calculate and display the Fibonacci series up to the specified number
of terms.

3. Write a program to allow the user to perform basic arithmetic operations (addition,
subtraction, multiplication, division, and modulus), where the results of two operands will be
stores to a chosen variable.

4.  Factorial Calculation: Write a recursive function to calculate the factorial of a


given number.
5.  Fibonacci Series: Write a program to generate the Fibonacci series up to n terms.
6. Switch Case: Write a program that takes a day number (1-7) as input and outputs the
corresponding day name (e.g., 1 for Monday).
7. Write a program to find the sum of elements in an array.

You might also like