- C All Exercises & Assignments
Write a C program to check whether a number is even or odd
Description:
Write a C program to check whether a number is even or odd.
Note: Even number is divided by 2 and give the remainder 0 but odd number is not divisible by 2 for eg. 4 is divisible by 2 and 9 is not divisible by 2.
Conditions:
- Create a variable with name of number.
- Take value from user for number variable.
Enter the Number=9 Number is Odd.
Write a C program to swap value of two variables using the third variable.
You need to create a C program to swap values of two variables using the third variable.
You can use a temp variable as a blank variable to swap the value of x and y.
- Take three variables for eg. x, y and temp.
- Swap the value of x and y variable.
Write a C program to check whether a user is eligible to vote or not.
You need to create a C program to check whether a user is eligible to vote or not.
- Minimum age required for voting is 18.
- You can use decision making statement.
Enter your age=28 User is eligible to vote
Write a C program to check whether an alphabet is Vowel or Consonant
You need to create a C program to check whether an alphabet is Vowel or Consonant.
- Create a character type variable with name of alphabet and take the value from the user.
- You can use conditional statements.
Enter an alphabet: O O is a vowel.
Write a C program to find the maximum number between three numbers
You need to write a C program to find the maximum number between three numbers.
- Create three variables in c with name of number1, number2 and number3
- Find out the maximum number using the nested if-else statement
Enter three numbers: 10 20 30 Number3 is max with value of 30
Write a C program to check whether number is positive, negative or zero
You need to write a C program to check whether number is positive, negative or zero
- Create variable with name of number and the value will taken by user or console
- Create this c program code using else if ladder statement
Enter a number : 10 10 is positive
Write a C program to calculate Electricity bill.
You need to write a C program to calculate electricity bill using if-else statements.
- For first 50 units – Rs. 3.50/unit
- For next 100 units – Rs. 4.00/unit
- For next 100 units – Rs. 5.20/unit
- For units above 250 – Rs. 6.50/unit
- You can use conditional statements.
Enter the units consumed=278.90 Electricity Bill=1282.84 Rupees
Write a C program to print 1 to 10 numbers using the while loop
You need to create a C program to print 1 to 10 numbers using the while loop
- Create a variable for the loop iteration
- Use increment operator in while loop
1 2 3 4 5 6 7 8 9 10
- C Exercises Categories
- C Top Exercises
- C Decision Making
Browse Course Material
Course info, instructors.
- Daniel Weller
- Sharat Chikkerur
Departments
- Electrical Engineering and Computer Science
As Taught In
- Programming Languages
- Software Design and Engineering
Learning Resource Types
Practical programming in c, course description.
You are leaving MIT OpenCourseWare
- C Data Types
- C Operators
- C Input and Output
- C Control Flow
- C Functions
- C Preprocessors
- C File Handling
- C Cheatsheet
- C Interview Questions
To learn anything effectively, practicing and solving problems is essential. To help you master C programming, we have compiled over 100 C programming examples across various categories, including basic C programs, Fibonacci series, strings, arrays, base conversions, pattern printing, pointers, and more. These C Examples cover a range of questions, from fundamental concepts to advanced topics, and are frequently asked in C-based programming interviews .
C Program Topics :
- Basic C Program
- Control Flow
- Pattern Printing
- Conversions
- Structures and Unions
- Date and Time
- More C Programs
Prerequisite : Before you start with these C programs, take a look at our C tutorial to get a good understanding of the basics. Bascally, C programming is a versatile language that powers many foundational systems. For those looking to strengthen their skills in C and master data structures, the C Programming Course Online with Data Structures offers a variety of example programs and deep dives into practical applications.
C Program – Basic
- C Hello World Program
- C Program to Print Your Own Name
- C Program to Print an Integer Entered By the User
- C Program to Add Two Numbers
- C Program to Check Whether a Number is Prime or Not
- C Program to Multiply two Floating-Point Numbers
- C Program to Print the ASCII Value of a Character
- C Program to Swap Two Numbers
- C Program to Calculate Fahrenheit to Celsius
- C Program to Find the Size of int, float, double, and char
- C Program to Add Two Complex Numbers
- C Program to Print Prime Numbers From 1 to N
- C Program to Find Simple Interest
- C Program to Find Compound Interest
- C Program for Area And Perimeter Of Rectangle
C Program – Control Flow
- C Program to Check Whether a Number is Positive, Negative, or Zero
- C Program to Check Whether Number is Even or Odd
- C Program to Check Whether a Character is Vowel or Consonant
- C Program to Find Largest Number Among Three Numbers
- C Program to Calculate Sum of Natural Numbers
- C Program to Print Alphabets From A to Z Using Loop
- C Program to Check Leap Year
- C Program to Find Factorial of a Number
- C Program to Make a Simple Calculator
- C Program to Generate Multiplication Table
- C Program to Print Fibonacci Series
- C Program to Find LCM of Two Numbers
- C Program to Check Armstrong Number
- C Program to Display Armstrong Numbers Between 1 to 1000
- C Program to Display Armstrong Number Between Two Intervals
- C Program to Reverse a Number
- C Program to Check Whether a Number is a Palindrome or Not
- C Program to Display Prime Numbers Between Intervals
- C Program to Check whether the input number is a Neon Number
- C Program to Find All Factors of a Natural Number
- C program to Sum of Fibonacci Numbers at Even Indexes up to N Terms
C Program – Pattern Printing
- C Program to Print Simple Pyramid Pattern
- C Program to Print Given Triangle
- C Program to Print 180 0 Rotation of Simple Pyramid
- C Program to Print Inverted Pyramid
- C Program to Print Number Pattern
- C Program to Print Character Pattern
- C Program to Print Continuous Character Pattern
- C Program to Print Hollow Star Pyramid
- C Program to Print Inverted Hollow Star pyramid
- C Program to Print Hollow Star Pyramid in a Diamond Shape
- C Program to Print Full Diamond Shape Pyramid
- C Program to Print Pascal’s Pattern Triangle Pyramid
- C Program to Print Floyd’s Pattern Triangle Pyramid
- C Program to Print Reverse Floyd pattern Triangle Pyramid
C Program – Functions
- C Program to Check Prime Number By Creating a Function
- C Program to Display Prime Numbers Between Two Intervals Using Functions
- C Program to Find All Roots of a Quadratic Equation
- C Program to Check Whether a Number can be Express as Sum of Two Prime Numbers
- C Program to Find the Sum of Natural Numbers using Recursion
- C Program to Calculate the Factorial of a Number Using Recursion
- C Program to Find G.C.D Using Recursion
- C Program to Reverse a Stack using Recursion
- C Program to Calculate Power Using Recursion
C Program – Arrays
- C Program to Print a 2D Array
- C Program to Find the Largest Element in an Array
- C Program to Find the Maximum and Minimum in an Array
- C Program to Search an Element in an Array (Binary search)
- C Program to Calculate the Average of All the Elements Present in an Array
- C Program to Sort an Array using Bubble Sort
- C Program to Sort an Array using Merge Sort
- C Program to Sort an Array Using Selection Sort
- C Program to Sort an Array Using Insertion Sort
- C Program to Sort the Elements of an Array in Descending Order
- C Program to Sort the Elements of an Array in Ascending Order
- C Program to Remove Duplicate Elements From a Sorted Array
- C Program to Merge Two Arrays
- C Program to Remove All Occurrences of an Element in an Array
- C Program to Find Common Array Elements
- C Program to Copy All the Elements of One Array to Another Array
- C Program For Array Rotation
- C Program to Sort the 2D Array Across Rows
- C Program to Check Whether Two Matrices Are Equal or Not
- C Program to Find the Transpose
- C Program to Find the Determinant of a Matrix
- C Program to Find the Normal and Trace
- C Program to Add Two Matrices
- C Program to Multiply Two Matrices
- C Program to Print Boundary Elements of a Matrix
- C Program to Rotate Matrix Elements
- C Program to Compute the Sum of Diagonals of a Matrix
- C Program to Interchange Elements of First and Last in a Matrix Across Rows
- C Program to Interchange Elements of First and Last in a Matrix Across Columns
C Program – Strings
- C Program to Add or Concatenate Two Strings
- C Program to Add 2 Binary Strings
- C Program to Get a Non-Repeating Character From the Given String
- C Program to check if the string is palindrome or not
- C Program to Reverse an Array or String
- C program to Reverse a String Using Recursion
- C Program to Find the Length of a String
- C Program to Sort a String
- C Program to Check For Pangram String
- C Program to Print the First Letter of Each Word
- C Program to Determine the Unicode Code Point at a Given Index
- C Program to Remove Leading Zeros
- C Program to Compare Two Strings
- C Program to Compare Two Strings Lexicographically
- C Program to Insert a String into Another String
- C Program to Split a String into a Number of Sub-Strings
C Program – Conversions
- C Program For Boolean to String Conversion
- C Program For Float to String Conversion
- C Program For Double to String Conversion
- C Program For String to Long Conversion
- C Program For Long to String Conversion
- C Program For Int to Char Conversion
- C Program For Char to Int Conversion
- C Program For Octal to Decimal Conversion
- C Program For Decimal to Octal Conversion
- C Program For Hexadecimal to Decimal Conversion
- C Program For Decimal to Hexadecimal Conversion
- C Program For Decimal to Binary Conversion
- C Program For Binary to Decimal Conversion
C Program – Pointers
- How to Return a Pointer from a Function in C
- How to Declare a Two-Dimensional Array of Pointers in C?
- C Program to Find the Largest Element in an Array using Pointers
- C Program to Sort an Array using Pointers
- C Program to Sort a 2D Array of Strings
- C Program to Check if a String is a Palindrome using Pointers
- C Program to Create a Copy of a Singly Linked List using Recursion
C Program – Structures and Unions
- C Program to Store Information of Students Using Structure
- C Program to Store Student Records as Structures and Sort them by Name
- C Program to Add N Distances Given in inch-feet System using Structures
- C Program to Add Two Complex Numbers by Passing Structure to a Function
- C Program to Store Student Records as Structures and Sort them by Age or ID
- Read/Write Structure to a File in C
- Flexible Array Members in a Structure in C
C Program – File IO
- C Program to Create a Temporary File
- C Program to Read/Write Structure to a File
- C Program to Rename a file
- C Program to Make a File Read-Only
- C program to Compare Two Files and Report Mismatches
- C Program to Copy One File into Another File
- C Program to Print all the Patterns that Match Given Pattern From a File
- C Program to Append the Content of One Text File to Another
- C Program to Read Content From One File and Write it Into Another File
- C Program to Read and Print all Files From a Zip File
C Program – Date and Time
- C Program to Format time in AM-PM format
- C program to Print Digital Clock with the Current Time
- C Program to Display Dates of Calendar Year in Different Formats
- C Program to Display Current Date and Time
- C Program to Maximize Time by Replacing ‘_’ in a Given 24-Hour Format Time
- C Program to Convert the Local Time to GMT
- C Program to Convert Hours into Minutes and Seconds
C Program – More C Programs
- C Program to Show Runtime exceptions
- C Program to Show Types of errors
- C Program to Show Unreachable Code Error
- C Program to Find Quotient and Remainder
- C Program to Find the Initials of a Name
- C Program to Draw a Circle in Graphics
- Printing Source Code of a C Program Itself
FAQs on C Program
What is c programming.
C is a structured, high-level, and general-purpose programming language, developed in the early 1970s by Dennis Ritchie at Bell Labs. C language is considered as the mother language of all modern programming languages, widely used for developing system software, embedded software, and application software.
How do I write a “Hello, World!” program in C?
To write a “Hello, World!” program in C, you can use the following code: #include <stdio.h> int main() { printf(“Hello, World!\n”); return 0; } This code uses the printf function to display the “Hello, World!” message on the screen.
Why should you learn C Programming?
There are many reasons why you should learn C programming: Versatility Efficiency Portability Widely used Foundation for other languages Employment opportunities and more.
Similar Reads
Improve your coding skills with practice.
What kind of Experience do you want to share?
C Functions
C structures, c reference, c exercises.
Test your C skills with exercises from all categories:
Format Specifiers
Change values, multiple variables, variable names, character data types, numeric data types, decimal precision, the sizeof operator, type conversion, short hand if else, do while loop, nested loops, break and continue, multidimensional arrays, special characters, string functions, memory address, pointers and arrays, function parameters, function declaration, create files, write to files, memory management, allocate memory, access memory, reallocate memory, deallocate memory, log in to track your progress.
If you haven't already, sign up to become a W3Schooler, and get points for every exercise you complete.
As a logged on W3Schools user you will have access to many features like having your own web page , track your learning progress , receive personal guided paths , and more .
The Exercise
The exercises are a mix of "multiple choice" and "fill in the blanks" questions. There are between 3 and 9 questions in each category. The answer can be found in the corresponding tutorial chapter. If you're stuck, or answer wrong, you can try again or hit the "Show Answer" button to see the correct answer.
If you don't know C, we suggest that you read our C Tutorial from scratch.
COLOR PICKER
Contact Sales
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]
Report Error
If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]
Top Tutorials
Top references, top examples, get certified.
IMAGES
VIDEO
COMMENTS
This section provides the course assignments, supporting files, and solutions.
Write a C program to check whether a number is even or odd. Note: Even number is divided by 2 and give the remainder 0 but odd number is not divisible by 2 for eg. 4 is divisible by 2 and 9 is not divisible by 2.
C Exercises for Beginners and Advances: Level up your C programming skills step-by-step with hands-on practice questions. Practice and learn syntax, loops, functions, and more through rewarding C programming exercises.
C programming Exercises, Practice, Solution: C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations.
Use the C++ Coding Standards and Best Practices provided to guide your review. This section includes the homework assignments, supporting files, and sample solutions that were given in the course.
This course provides a thorough introduction to the C programming language, the workhorse of the UNIX operating system and lingua franca of embedded processors and micro-controllers. The first two weeks will cover basic syntax and grammar, and expose students to practical programming techniques.
Write a program in C to store elements in an array and print them. ....... 2. Write a program in C to read n number of values in an array and display them in reverse order. 3. Write a program in C to find the sum of all elements of the array. 4. Write a program in C to copy the elements of one array into another array. 5.
Write a C program to find the type of progression (arithmetic progression/geometric progression) and the next successive member of the three successive members of a sequence. Sample Data: 2, 6, 18, 54, ..
To help you master C programming, we have compiled over 100 C programming examples across various categories, including basic C programs, Fibonacci series, strings, arrays, base conversions, pattern printing, pointers, and more.
If you don't know C, we suggest that you read our C Tutorial from scratch. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.