- 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 .
![example of problem solving c C Programs](https://media.geeksforgeeks.org/wp-content/cdn-uploads/20221027121332/C-Programming-Examples.jpg)
![](http://pechenka.online/777/templates/cheerup1/res/banner1.gif)
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.
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.
Please Login to comment...
Similar reads.
- Best Twitch Extensions for 2024: Top Tools for Viewers and Streamers
- Discord Emojis List 2024: Copy and Paste
- Best Adblockers for Twitch TV: Enjoy Ad-Free Streaming in 2024
- PS4 vs. PS5: Which PlayStation Should You Buy in 2024?
- 15 Most Important Aptitude Topics For Placements [2024]
Improve your Coding Skills with Practice
What kind of Experience do you want to share?
"Hello World!" in C Easy C (Basic) Max Score: 5 Success Rate: 85.63%
Playing with characters easy c (basic) max score: 5 success rate: 84.38%, sum and difference of two numbers easy c (basic) max score: 5 success rate: 94.61%, functions in c easy c (basic) max score: 10 success rate: 96.02%, pointers in c easy c (basic) max score: 10 success rate: 96.61%, conditional statements in c easy c (basic) max score: 10 success rate: 96.92%, for loop in c easy c (basic) max score: 10 success rate: 93.80%, sum of digits of a five digit number easy c (basic) max score: 15 success rate: 98.66%, bitwise operators easy c (basic) max score: 15 success rate: 94.99%, printing pattern using loops medium c (basic) max score: 30 success rate: 95.95%, cookie support is required to access hackerrank.
Seems like cookies are disabled on this browser, please enable them to open this website
![example of problem solving c PW Skills | Blog](https://blog.pwskills.com/wp-content/uploads/2023/05/PWSkills-main-4-181x67.png)
C Programming Examples for Beginners With Solutions & Output
C Programming Examples include many programs, from beginner-level examples like "Hello World" and "Sum of Two Numbers" to more advanced programs like the Fibonacci series and Prime Numbers.
![example of problem solving c](https://blog.pwskills.com/wp-content/uploads/2023/12/c-programming.png)
C Programming Examples: Are you just starting out in C programming but feeling overwhelmed? Maybe you’ve been working through the basics of C programming for a while, but are now looking to take your skills to the next level. If so, we can definitely relate!
Here, we share C programs covering various topics in C Programming, including arrays, strings, series, area & volume of geometrical figures, mathematical calculations, sorting & searching algorithms, and many more. Our goal is to provide comprehensive solutions to all C programming questions you may encounter, whether in interviews or class assignments.
Each program in this article is accompanied by its working code and output. The programs are organized into categories, with related programs grouped together. It is recommended to grasp the fundamentals of the C language through our C tutorial before delving into these C programs. You can also download our C programming examples PDF to get instant access to C programming examples . So, whether you’re just setting out or have already made some progress in your learning adventure, this will be the perfect resource guide for honing your C coding skills!
If you find learning C language challenging, consider exploring our new C course from Physics Wallah . This interactive learning experience involves understanding a concept, completing small coding exercises, and progressing to the next lesson. Use “READER” coupon to get instant discounts on PW courses.
Also read: C Programming Language History, Invention, Timeline & More
Table of Contents
C Programming Examples for Beginners
Below, we will share C programming examples for beginners. You can also download C language programs PDF .
1. C Hello World Program
#include <stdio.h>
int main() {
printf(“Hello, World!\n”);
2. C Program to Print Your Own Name
printf(“Your Name\n”);
3. C Program to Print an Integer Entered By the User
printf(“Enter an integer: “);
scanf(“%d”, &num);
printf(“You entered: %d\n”, num);
4. C Program to Check Whether a Number is Prime or Not
int num, i, flag = 0;
printf(“Enter a number: “);
for (i = 2; i <= num / 2; ++i) {
if (num % i == 0) {
if (flag == 0)
printf(“%d is a prime number.\n”, num);
printf(“%d is not a prime number.\n”, num);
Also read: Top 30 Most Asked Basic Programming Questions Asked During Interviews
C Programming Examples With Solutions
Here are some C programming examples with solutions and codes:
1. C Program to Multiply two Floating-Point Numbers
float num1, num2, product;
printf(“Enter two floating-point numbers: “);
scanf(“%f %f”, &num1, &num2);
product = num1 * num2;
printf(“Product: %f\n”, product);
2. C Program to Print the ASCII Value of a Character
printf(“Enter a character: “);
scanf(“%c”, &ch);
printf(“ASCII value of %c = %d\n”, ch, ch);
3. C Program to Swap Two Numbers
int num1, num2, temp;
printf(“Enter two numbers: “);
scanf(“%d %d”, &num1, &num2);
temp = num1;
num1 = num2;
num2 = temp;
printf(“After swapping: num1 = %d, num2 = %d\n”, num1, num2);
4. C Program to Calculate Fahrenheit to Celsius
float fahrenheit, celsius;
printf(“Enter temperature in Fahrenheit: “);
scanf(“%f”, &fahrenheit);
celsius = (fahrenheit – 32) * 5 / 9;
printf(“Temperature in Celsius: %f\n”, celsius);
5. C Program to Find the Size of int, float, double, and char
printf(“Size of int: %d bytes\n”, sizeof(int));
printf(“Size of float: %d bytes\n”, sizeof(float));
printf(“Size of double: %d bytes\n”, sizeof(double));
printf(“Size of char: %d byte\n”, sizeof(char));
6. C Program to Print Prime Numbers From 1 to N
int i, j, n;
printf(“Enter a number (N): “);
scanf(“%d”, &n);
printf(“Prime numbers between 1 and %d are: “, n);
for (i = 2; i <= n; ++i) {
int isPrime = 1;
for (j = 2; j <= i / 2; ++j) {
if (i % j == 0) {
isPrime = 0;
if (isPrime)
printf(“%d “, i);
Also read: 10 Best Programming Languages for Game Development in 2024
C Programming Examples With Output
Learners can also download c programming examples with output PDF to start their C language journey. But practice is the key to learning C language properly. Here are some of the best C programming examples with output :
1. C Program to Check Whether a Number is Positive, Negative, or Zero
if (num > 0)
printf(“Positive number\n”);
else if (num < 0)
printf(“Negative number\n”);
printf(“Zero\n”);
Enter a number: 7
Positive number
2. C Program to Check Whether Number is Even or Odd
if (num % 2 == 0)
printf(“Even number\n”);
printf(“Odd number\n”);
Enter a number: 15
3. C Program to Calculate Sum of Natural Numbers
int n, sum = 0;
printf(“Enter a positive integer: “);
for (int i = 1; i <= n; ++i) {
printf(“Sum of natural numbers from 1 to %d: %d\n”, n, sum);
Enter a positive integer: 5
Sum of natural numbers from 1 to 5: 15
4. C Program to Print Alphabets From A to Z Using Loop
printf(“Alphabets from A to Z:\n”);
for (ch = ‘A’; ch <= ‘Z’; ++ch) {
printf(“%c “, ch);
Alphabets from A to Z:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Recommended Technical Course
- Full Stack Development Course
- Generative AI Course
- DSA C++ Course
- Data Analytics Course
- Python DSA Course
- DSA Java Course
C Programs for Practice
Below table shows the C programming code that you can use for practice:
1 | Hello World Program | Basic program to print “Hello, World!” |
2 | Print Your Own Name | Program to print your own name |
3 | Add Two Numbers | Program to input and add two numbers |
4 | Check Positive, Negative, or Zero | Program to check whether a number is positive, negative, or zero |
5 | Even or Odd Number | Program to check whether a number is even or odd |
6 | Vowel or Consonant | Program to check whether a character is a vowel or consonant |
7 | Largest Number Among Three Numbers | Program to find the largest number among three numbers |
8 | Calculate Sum of Natural Numbers | Program to calculate the sum of natural numbers |
9 | Multiply Two Floating-Point Numbers | Program to multiply two floating-point numbers |
10 | Print ASCII Value of a Character | Program to print the ASCII value of a character |
11 | Swap Two Numbers | Program to swap two numbers |
12 | Calculate Fahrenheit to Celsius | Program to convert temperature from Fahrenheit to Celsius |
13 | Find Size of int, float, double, and char | Program to find the size of int, float, double, and char |
14 | Add Two Complex Numbers | Program to add two complex numbers |
15 | Print Prime Numbers From 1 to N | Program to print prime numbers from 1 to N |
16 | Find Simple Interest | Program to calculate simple interest |
17 | Find Compound Interest | Program to calculate compound interest |
18 | Area and Perimeter of Rectangle | Program to calculate the area and perimeter of a rectangle |
19 | Print Alphabets From A to Z Using Loop | Program to print alphabets from A to Z using a loop |
20 | Armstrong Number | Program to check whether a number is an Armstrong number |
Why Choose C Language for Learning?
C language is an excellent entry point into the programming world due to its simplicity and ease of learning. While certain concepts may pose challenges, overall, learners find C language accessible. It introduces fundamental programming concepts like data types, variables, functions, arrays, strings, conditional statements, loops, input/output, and data structures—all foundational principles applicable to various modern programming languages.
For newcomers, acquiring proficiency in C/C++ is crucial for success in college placement interviews, especially with service-based companies such as TCS, Accenture, IBM, etc., which actively seek C developers.
Highly Efficient:
C language is renowned for its efficiency and performance. Programs written in C execute swiftly and optimize system resources effectively.
System-level Programming:
Offering low-level control over a computer’s hardware and memory, C language is well-suited for system-level programming and the development of operating systems.
Portability:
C language is favored for its portability; its code can be compiled and executed on various platforms with minimal modifications. This makes C an ideal choice to run programs on diverse platforms.
Easy to Learn:
With a small learning curve, C language involves fewer keywords and concepts. Its syntax is easy to remember and apply. The C compiler provides descriptive errors, simplifying the debugging process and making it particularly beginner-friendly.
Versatility:
C language’s versatility allows for creating both small utility software and large-scale enterprise applications. Its broad applicability makes it a valuable language to master in programming.
Benefits of Practicing C Programming Examples
Practicing C Programming Examples offers several benefits for learners and aspiring programmers:
- Concept Reinforcement: By working on C programming examples, individuals reinforce fundamental programming concepts such as variables, loops, conditionals, and functions. This hands-on practice helps solidify theoretical knowledge.
- Preparation for Interviews: Many technical interviews, especially for entry-level programming positions, involve solving coding problems. Practicing C programming examples prepares individuals for such interviews, helping them perform well and showcase their coding proficiency.
- Application of Knowledge: C programming examples provide a practical platform for applying theoretical knowledge gained from textbooks or tutorials. This application-oriented learning approach ensures a deeper understanding of programming concepts.
- Syntax Mastery: Working on examples allows learners to master the syntax of the C programming language. Writing and debugging code regularly contributes to becoming fluent in C syntax, which is essential for effective programming.
- Understanding Algorithms and Logic: Examples often involve implementing algorithms and logical reasoning. Working through these examples improves algorithmic thinking and logic building, essential skills for writing efficient and optimized code.
- Skill Development: Solving a variety of programming problems enhances problem-solving skills. Each example presents a unique challenge, requiring learners to devise efficient solutions and improve their analytical and coding abilities.
- Builds Confidence: Successfully solving programming problems instills confidence in learners. As they tackle increasingly complex examples, individuals become more comfortable handling challenging coding tasks, boosting their overall confidence in programming.
- Diverse Problem-Solving: C programming examples cover a wide range of problems, including mathematical calculations, string manipulations, array operations, and more. This diversity exposes learners to various problem-solving approaches, enriching their programming toolkit.
- Portfolio Building: Individuals can use the solutions to these examples to build a portfolio showcasing their coding skills. A well-documented portfolio becomes a valuable asset when seeking internships, jobs, or contributing to open-source projects.
Also read: C++ For Kids- Learn Programming in The Fun Way
Why is it essential to practice C programming examples?
Practicing C programming examples is crucial for several reasons. It helps reinforce theoretical knowledge, enhances problem-solving skills, and provides hands-on experience with the language. Through practice, programmers become familiar with common syntax, logic building, and debugging techniques, contributing to overall proficiency in C programming.
What is the purpose of the "Swap Two Numbers" program?
The "Swap Two Numbers" program is designed to interchange the values of two variables. It is a fundamental programming exercise that helps users understand the concept of swapping values using a temporary variable or without using one. Swapping is a common operation in programming, and mastering it is essential.
Where can I find more C programming examples for practice?
You can find more C programming examples for practice on online platforms, programming websites, and educational resources.
How can I use C programming examples for learning?
Start with simple examples like Hello World and gradually progress to more complex ones. Analyze the code, understand how each line works, and experiment with modifications. This hands-on approach is effective for learning programming.
Can I modify the examples to create my programs?
Absolutely! Modifying existing examples is an excellent way to practice. Experiment with changing variables, adding features, or solving similar problems. This process fosters creativity and a deeper understanding of coding.
- C Plus Plus Tutorial: Class, Objects, Applications
![example of problem solving c c plus plus](https://blog.pwskills.com/wp-content/uploads/2024/02/C-Plus-Plus-Tutorial-01-1024x640.jpg)
C Plus Plus: Welcome to the exciting world of C Plus Plus programming! In this course, you'll embark on a journey…
- What Is the Meaning Of 1LL In C++?
![example of problem solving c 1ll in c++](https://blog.pwskills.com/wp-content/uploads/2024/02/what-is-the-meaning-of-1-ll-in-c-1024x640.png)
1LL In C++ denotes a literal constant of type "long long", representing the integer value 1. It's commonly used to…
- C Language Fundamentals
![example of problem solving c C Language Fundamentals](https://blog.pwskills.com/wp-content/uploads/2024/06/C-Language-Fundamentals-1024x566.jpg)
Learning C language fundamentals helps aspiring developers to start their programming journey, Read this article to understand all the fundamental…
Leave a Comment Cancel Reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
![example of problem solving c right adv](https://image-upload-stage-test.s3.ap-south-1.amazonaws.com/cta/1725508411-c%2B%2B.png)
Related Articles
- C Cpp Interview Questions – What Is The Difference Between C And C++ Interview Questions?
- Difference between C and C++
- 10 Most Important Data Structures In C++ for Interview
- Can I Use C Programming in VS Code? Explained in Detail!
- Top C Plus Plus Programs List 2024
- What Are The Concepts Of Recursion In C, Definition, Types
- How to Make a Simple C Programs?
![example of problem solving c bottom banner](https://image-upload-stage-test.s3.ap-south-1.amazonaws.com/cta/1725508423-c%2B%2B.png)
![example of problem solving c IncludeHelp_logo](https://www.includehelp.com/images/ihelp.png)
- Data Structure
- Coding Problems
- C Interview Programs
- C++ Aptitude
- Java Aptitude
- C# Aptitude
- PHP Aptitude
- Linux Aptitude
- DBMS Aptitude
- Networking Aptitude
- AI Aptitude
- MIS Executive
- Web Technologie MCQs
- CS Subjects MCQs
- Databases MCQs
- Programming MCQs
- Testing Software MCQs
- Digital Mktg Subjects MCQs
- Cloud Computing S/W MCQs
- Engineering Subjects MCQs
- Commerce MCQs
- More MCQs...
- Machine Learning/AI
- Operating System
- Computer Network
- Software Engineering
- Discrete Mathematics
- Digital Electronics
- Data Mining
- Embedded Systems
- Cryptography
- CS Fundamental
- More Tutorials...
- Tech Articles
- Code Examples
- Programmer's Calculator
- XML Sitemap Generator
- Tools & Generators
![example of problem solving c IncludeHelp](https://www.includehelp.com/images/logo_mobile.png)
Advertisement
Home » C programming language
C Programs with Solutions
This section contains popular C programs with solution. Learn and practice these programs to test and enhance your C skills. Last updated : April 01, 2023
The best way to learn C programming is by practicing and solving the C programs (C problems). We have 1000+ C programs with solutions which are categorized below. Practice these C programs to learn and enhance your C problem-solving skills.
List of C programs
Practice the C programs based on the categories, library functions, advanced, top searched, and latest.
C programs by categories
- C Basic and Conditional Programs 90
- C switch case programs 06
- C 'goto' programs 10
- Bitwise related Programs 32
- Looping (for, while, do while) Programs 18
- C String Manipulation programs 10
- C String programs 50
- String User Define Functions Programs 11
- Recursion Programs 13
- Number (Digits Manipulation) Programs 10
- Number System Conversion Programs 15
- Star/Pyramid Programs 17
- Sum of Series Programs (set 1) 05
- Sum of Series Programs (set 2) 13
- Pattern printing programs 01
- User Define Function Programs (1) 05
- User Define Function Programs (2) 13
- One Dimensional Array Programs 58
- Two Dimensional Array (Matrix) Programs 21
- File Handling Programs 32
- Structure & Union Programs 12
- Pointer Programs 13
- Dynamic Memory Allocation Programs 05
- Command Line Arguments Programs 06
- Common C program Errors 22
- C scanf() programs 11
- C preprocessor programs 24
- C typedef programs 03
- C SQLite programs 11
- C MySQL programs 09
- C Tricky Programs 07
- Misc Problems & Solutions 05
C programs on standard library functions
- ctype.h Library Functions (Set 1)
- ctype.h Library Functions (Set 2)
- string.h Library Functions
- conio.h Library Functions
- dos.h Library Functions
- math.h Library Functions
- graphics.h Library Functions
- assert.h Library Functions
- stdio.h Library Functions
Advance C programs
- C program to create your own header file/ Create your your own header file in C
- gotoxy(),clrscr(),getch(),getche() for GCC, Linux.
- fork() function explanation and examples in Linux C
- C program to print character without using format specifiers.
- C program to find Binary Addition and Binary Subtraction.
- C program to print weekday of given date.
- C program to format/extract ip address octets
- C program to check given string is a valid IPv4 address or not.
- C program to extract bytes from an integer (Hexadecimal) value
- C program to store date in an integer variable
![](http://pechenka.online/777/templates/cheerup1/res/banner1.gif)
Top searched C programs
Here is the list of most important/useful programs searched on the web .
Top visited programs on IncludeHelp
- Pattern Programs in C
- C program to design calculator with basic operations using switch
- C program to find factorial of a number
- C program to check whether number is Perfect Square or not
- C program to find SUM and AVERAGE of two numbers
- C program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit
- C program to read and print an employee's detail using structure
- Dynamic Memory Allocation programs
- C program to convert number from Decimal to Binary
- C program to check whether number is Palindrome or not
Top searched programs on the web
- First C program to print "Hello World".
- C program to find factorial of a number.
- C program to swap two numbers without using third variable.
- C program to check whether a number if Armstrong or not.
- C program to check whether a number if Even or Odd.
- C program to print all leap years from 1 to N.
- C program to calculate employee gross salary.
- C Program to print tables of numbers from 1 to 20.
- C program to print star/pyramid series.
- C program to convert temperature from Celsius to Fahrenheit and vice versa.
- C program to convert number from Decimal to Binary.
- C program to convert number from Binary to Decimal.
- C program to print ASCII Table.
- C program to get and set current system date and time.
- C program to run dos command.
Latest C programs
- C program to generate random numbers within a range
- C program to compare strings using strcmp() function
- Interchange the two adjacent nodes in a given circular linked list | C program
- Find the largest element in a doubly linked list | C program
- Convert a given singly linked list to a circular list | C program
- Implement Circular Doubly Linked List | C program
- Print the Alternate Nodes in a Linked List without using Recursion
- Print the Alternate Nodes in a Linked List using Recursion
- Find the length of a linked list without using recursion
- Find the length of a linked list using recursion
- Count the number of occurrences of an element in a linked list without using recursion
- Count the number of occurrences of an element in a linked list using recursion
- C program to convert a Binary Tree into a Singly Linked List by Traversing Level by Level
- C program to Check if nth Bit in a 32-bit Integer is set or not
- C program to swap two Integers using Bitwise Operators
- C program to replace bit in an integer at a specified position from another integer
- C program to find odd or even number using bitmasking
- C program to check whether a given number is palindrome or not using Bitwise Operator
- C program to count number of bits set to 1 in an Integer
- C program to check if all the bits of a given integer is one (1)
- C program to find the Highest Bit Set for any given Integer
- C program to Count the Number of Trailing Zeroes in an Integer
- C Program to find the Biggest Number in an Array of Numbers using Recursion
- C program to accept Sorted Array and do Search using Binary Search
- C Program to Cyclically Permute the Elements of an Array
- C program to find two smallest elements in a one dimensional array
- Write your own memset() function in C
- memset() function in C with Example
- Write your own memcpy() function in C
- memcpy() function in C with Example
Comments and Discussions!
Load comments ↻
- Marketing MCQs
- Blockchain MCQs
- Artificial Intelligence MCQs
- Data Analytics & Visualization MCQs
- Python MCQs
- C++ Programs
- Python Programs
- Java Programs
- D.S. Programs
- Golang Programs
- C# Programs
- JavaScript Examples
- jQuery Examples
- CSS Examples
- C++ Tutorial
- Python Tutorial
- ML/AI Tutorial
- MIS Tutorial
- Software Engineering Tutorial
- Scala Tutorial
- Privacy policy
- Certificates
- Content Writers of the Month
Copyright © 2024 www.includehelp.com. All rights reserved.
C Functions
C structures, c reference, c exercises.
You can test your C skills with W3Schools' Exercises.
We have gathered a variety of C exercises (with answers) for each C Chapter.
Try to solve an exercise by editing some code, or show the answer to see what you've done wrong.
Count Your Score
You will get 1 point for each correct answer. Your score and total score will always be displayed.
Start C Exercises
Start C Exercises ❯
If you don't know C, we suggest that you read our C Tutorial from scratch.
![example of problem solving c Get Certified](https://www.w3schools.com/images/img_falilla_up_300.png)
COLOR PICKER
![example of problem solving c colorpicker](https://www.w3schools.com/images/colorpicker2000.png)
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.
C Solved programs, problems with solutions – C programming
C solved programs, problems with solutions.
C Solved programs —-> C is a powerful general-purpose programming language. It is fast, portable and available in all platforms. If you are new to programming, C is a good choice to start your programming journey.
This page contains the C solved programs/examples with solutions, here we are providing most important programs on each topic . These C examples cover a wide range of programming areas in Computer Science.
Every example program includes the description of the program, C code as well as output of the program. All examples are compiled and tested on a Windows system.
These examples can be as simple and basic as “Hello World” program to extremely tough and advanced C programs. Here is the List of C solved programs/examples with solutions (category wise) and detailed explanation.
C Solved Programs by categories…….
C Basic Solved Programs |
---|
C Number Solved Programs |
---|
C String Solved Programs |
---|
C Arrays Solved Programs |
---|
C Matrix Solved Programs |
---|
C Pattern Solved Programs |
---|
C Sorting Solved Programs |
---|
C Recursion Solved Programs |
---|
C Pointer Solved Programs |
---|
C File Handling Solved Programs |
---|
C Graphic Solved Programs |
---|
C Advance Solved Programs |
---|
If you found any error or any queries related to the above programs or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.
Thanks for reading the post….
No related posts.
(using file handling) Enter Country Name (Inida): india 5 states() Enter Name of State : Rajasthan Enter Name of capital : jaipur show the menu of jaipur city: 1. check college in city : 2. check school Name: Enter choice : 1 show list of all college in jaipur city(10): college Name address contact no Enter choice : 2 show list of all school in jaipur city(10): school Name address contact no
Write a program that reads a list of integers until a stopping condition is met and then print each test score together with Pass, if the score is greater than or equal to 60, and Fail otherwise.
worst website
Write a C program to find the sum of contiguous sub array within an array which has the smallest sum. Also print where in the array the smallest sum occurred. For example, given the array [4, -1, 2, -3, 1, -2, 7, -5, 4], the contiguous sub-array [1, -3, -2] has the smallest sum of -4 and it occurred in [0:6]. To understand contiguous sub array, given the array [1, 2, 3] the contiguous sub arrays are [1], [2], [3], [1, 2], [2, 3], [1, 2, 3], but [1, 3] is not a contiguous sub array. Sample Input Sample Output
Consider an Auto spares store which has different categories of items like. Under each category, the shop holds a maximum capacity of 1000 items. The arrangement of items in the racks vary from time to time. Based on the item type and availability, the supplier also varies. Each supplier can supply different items. The system in the shopping mall has the complete description of list of all items which includes item number, name, category, supplier name, price, total quantity and qty available. Based on the items purchased by the customer, billing is done. From the above description, initially the owner … Read more »
#include <stdio.h>
int main () { int i ; float avg = 0 , sum = 0 , a [ 10 ];
printf ( “Enter 10 numbers” ); for ( i = 0 ; i <= 9 ; i ++) scanf ( “ %d “ , & a [ i ]);
for ( i = 0 ; i <= 9 ; i ++); { sum = sum + a [ i ]; avg = sum / 10.0 ; } printf ( “average is %f “ , avg );
return 0 ; }
the output averge is 0.00000 please help i’m beginer in c programming using visual studio code
Try with this code ..
#include<stdio.h>
int main() { int a[20],i ,n ; float avg=0 , sum=0 ;
printf(“Enter no of elements in array :\n “); scanf(“%d”, &n); printf(“\n Enter the array of element : \n”);
for (i=1; i<=n; i++) { scanf(“%d”,&a[i]); } for (i=1; i<=n; i++) { sum=sum+a[i]; avg= sum/n; }
printf(“\n sum of elements :%f”,sum); printf(“\n average is %f”, avg);
return 0; }
#include <stdio.h> int main(){ /*Short and Sweet Code, Working code Please check inverted commas while running this code.*/
int value[10]; float Sum, Average; for(int i=0; i<=9; i++){ printf(“Enter %d number: \n”, i+1); scanf(“%d”, &value[i]); }
for(int i=0; i<=9; i++){
Sum += value[i]; } Average = Sum/10;
printf(“Average of these 10 numbers is %f”, Average); return 0; }
#include<stdio.h> int main() { /*You have made 2 mistakes in this program.*/ int i; float avg=0, sum=0 ,a[10]; printf(“Enter 10 numbers”); for (i=0; i<=9; i++) scanf(“ %d “, &a[i]); /*ERROR 1: %d should be replaced with %f in your program because you declared a[10] as a float so you cannot use %d.*/
for (i=0; i<=9; i++) ; /*ERROR 2: In this Loop Remove this semicolon after the brackets.*/ { sum=sum+a[i]; avg= sum/10.0; } printf(“average is %f“, avg);
/*After Doing this correction your program will run without giving error OR zero.*/
return 0; }
Plz Solve this Programe
![256676832_4608769575897180_2595566630400619699_n.png 256676832_4608769575897180_2595566630400619699_n.png](https://www.codezclub.com/wp-content/uploads/2021/11/256676832_4608769575897180_2595566630400619699_n-1637261650.5887.png)
ভাই পেয়েছেন
Interest is compounded annually at 10% by a certain bank. Make a program that would input an amount and a number of years (the program should test that both are positive) and output how much the original amount will be worth after that period.
It’s really a wonderful website💥
The Business organization has a problem that they encounter. They received complains about the orders they have that are inaccurate mostly in selection of orders, prices, and quantity of the products. They want to have system update as soon as possible to fix this problem and asking for a refund. Every order must be confirmed to avoid any conflicts of transaction. Also the discounts are not applied when the order are wholesales which is needed to be fix when being total. Certain products are discounted either from a voucher or a wholesale that is minimum of five products. The deduction of … Read more »
To check whether the candidate is eligible for vote or not
(A) Create a C structure, volume with fields: liter and mililiter. Read the value of two volumes and add them, if the value of mililiter is more than 1000 then add it to liter value.
Write a c program for There are 20 workers working in a field. the owner of Field gives them 20 rupees. In that 20 rupees each man get 4 rupees each woman get 50 paise and each child get 25 paise. Then how many are men, women, children in that 20 workers?
A vending machine questions
1. Write a C program to print all odd numbers between 2 values ‘n’ and ‘m’. Read the values ‘n’ and ‘m’ from the user and print all the odd numbers in this range (inclusive range, i.e if ‘n’ or ‘m’ is odd, print those as well).
write a programming using for loop to print all the numbers from them as even m to n there by case classifying them as even or odd
Problem Solving Through Programming in C
In this lesson, we are going to learn Problem Solving Through Programming in C. This is the first lesson while we start learning the C language.
Table of Contents
Introduction to Problem Solving Through Programming in C
Regardless of the area of the study, computer science is all about solving problems with computers. The problem that we want to solve can come from any real-world problem or perhaps even from the abstract world. We need to have a standard systematic approach to problem solving through programming in c.
computer programmers are problem solvers. In order to solve a problem on a computer, we must know how to represent the information describing the problem and determine the steps to transform the information from one representation into another.
A computer is a very powerful and versatile machine capable of performing a multitude of different tasks, yet it has no intelligence or thinking power.
The computer cannot solve the problem on its own, one has to provide step by step solutions of the problem to the computer. In fact, the task of problem-solving is not that of the computer.
It is the programmer who has to write down the solution to the problem in terms of simple operations which the computer can understand and execute.
In order to solve a problem with the computer, one has to pass through certain stages or steps. They are as follows:
Steps to Solve a Problem With the Computer
Step 1: understanding the problem:.
Here we try to understand the problem to be solved in totally. Before with the next stage or step, we should be absolutely sure about the objectives of the given problem.
Step 2: Analyzing the Problem:
The idea here is to search for an appropriate solution to the problem under consideration. The end result of this stage is a broad overview of the sequence of operations that are to be carried out to solve the given problem.
Step 3: Developing the solution:
Here, the overview of the sequence of operations that was the result of the analysis stage is expanded to form a detailed step by step solution to the problem under consideration.
Step 4: Coding and Implementation:
The vehicle for the computer solution to a problem is a set of explicit and unambiguous instructions expressed in a programming language. This set of instruction is called a program with problem solving through programming in C .
A program may also be thought of as an algorithm expressed in a programming language. an algorithm, therefore, corresponds to a solution to a problem that is independent of any programming language .
The problem solving is a skill and there are no universal approaches one can take to solving problems. Basically one must explore possible avenues to a solution one by one until she/he comes across the right path to a solution.
In general, as one gains experience in solving problems, one develops one’s own techniques and strategies, though they are often intangible. Problem-solving skills are recognized as an integral component of computer programming.
Problem Solving Steps
Problem-solving is a creative process which defines systematization and mechanization. There are a number of steps that can be taken to raise the level of one’s performance in problem-solving.
A problem-solving technique follows certain steps in finding the solution to a problem. Let us look into the steps one by one:
1. Problem Definition Phase:
In the problem definition phase, we must emphasize what must be done rather than how is it to be done. That is, we try to extract the precisely defined set of tasks from the problem statement.
Inexperienced problem solvers too often gallop ahead with the task of the problem – solving only to find that they are either solving the wrong problem or solving the wrong problem or solving just one particular problem.
2. Getting Started on a Problem:
Sometimes you do not have any idea where to begin solving a problem, even if the problem has been defined. Such block sometimes occurs because you are overly concerned with the details of the implementation even before you have completely understood or worked out a solution.
The best advice is not to get concerned with the details. Those can come later when the intricacies of the problem have been understood.
3. Use of Specific Examples:
It is usually much easier to work out the details of a solution to a specific problem because the relationship between the mechanism and the problem is more clearly defined.
This approach of focusing on a particular problem can give us the foothold we need for making a start on the solution to the general problem.
4. Similarities Among Problems:
The more experience one has the more tools and techniques one can bring to bear in tackling the given problem. But sometimes, it blocks us from discovering a desirable or better solution to the problem.
A skill that is important to try to develop in problem-solving is the ability to view a problem from a variety of angles.
5. Working Backwards from the Solution:
In some cases, we can assume that we already have the solution to the problem and then try to work backwards to the starting point. Even a guess at the solution to the problem may be enough to give us a foothold to start on the problem.
We can systematize the investigations and avoid duplicate efforts by writing down the various steps taken and explorations made.
General Problem Solving Strategies:
There are a number of general and powerful computational strategies that are repeatedly used in various guises in computer science.
Often it is possible to phrase a problem in terms of one of these strategies and achieve considerable gains in computational efficiency.
1. Divide and Conquer:
The Splitting can be carried on further so that eventually we have many sub-problems, so small that further splitting is no necessary to solve them. We shall see many examples of this strategy and discuss the gain in efficiency due to its application.
2. Binary Doubling:
This is the reverse of the divide and conquers strategy i.e build-up the solution for a larger problem from solutions and smaller sub-problems.
3. Dynamic Programming:
The travelling salesman problem falls into this category. The idea here is that a good or optimal solution to a problem can be built-up from good or optimal solutions of the sub-problems.
4. General Search, Back Tracking and Branch-and-Bound:
All of these are variants of the basic dynamic programming strategy but are equally important.
Share This Story, Choose Your Platform!
Related posts, what is preprocessor in c, what is file handling in c, structures and unions in c.
- C Programming Home
- ▼C Programming Exercises
- Basic Declarations and Expressions
- Basic Part-II
- Basic Algorithm
- Variable Type
- Input - Output
- Conditional Statements
- Do-While Loop
- Linked List
- Callback function
- Variadic function
- Inline Function
- File Handling
- Searching and Sorting
C Programming Exercises, Practice, Solution : For Loop
C for loop [61 exercises with solution].
[ An editor is available at the bottom of the page to write and execute the scripts. Go to the editor ]
1. Write a program in C to display the first 10 natural numbers. Expected Output : 1 2 3 4 5 6 7 8 9 10 Click me to see the solution
2. Write a C program to compute the sum of the first 10 natural numbers. Expected Output : The first 10 natural number is : 1 2 3 4 5 6 7 8 9 10 The Sum is : 55 Click me to see the solution
3. Write a program in C to display n terms of natural numbers and their sum. Test Data : 7 Expected Output : The first 7 natural number is : 1 2 3 4 5 6 7 The Sum of Natural Number upto 7 terms : 28 Click me to see the solution
4. Write a program in C to read 10 numbers from the keyboard and find their sum and average. Test Data : Input the 10 numbers : Number-1 :2 ... Number-10 :2 Expected Output : The sum of 10 no is : 55 The Average is : 5.500000 Click me to see the solution
5. Write a program in C to display the cube of the number up to an integer. Test Data : Input number of terms : 5 Expected Output : Number is : 1 and cube of the 1 is :1 Number is : 2 and cube of the 2 is :8 Number is : 3 and cube of the 3 is :27 Number is : 4 and cube of the 4 is :64 Number is : 5 and cube of the 5 is :125 Click me to see the solution
6. Write a program in C to display the multiplication table for a given integer. Test Data : Input the number (Table to be calculated) : 15 Expected Output : 15 X 1 = 15 ... ... 15 X 10 = 150 Click me to see the solution
7. Write a program in C to display the multiplier table vertically from 1 to n. Test Data : Input upto the table number starting from 1 : 8 Expected Output : Multiplication table from 1 to 8 1x1 = 1, 2x1 = 2, 3x1 = 3, 4x1 = 4, 5x1 = 5, 6x1 = 6, 7x1 = 7, 8x1 = 8 ... 1x10 = 10, 2x10 = 20, 3x10 = 30, 4x10 = 40, 5x10 = 50, 6x10 = 60, 7x10 = 70, 8x10 = 80 Click me to see the solution
8. Write a C program to display the n terms of odd natural numbers and their sum. Test Data Input number of terms : 10 Expected Output : The odd numbers are :1 3 5 7 9 11 13 15 17 19 The Sum of odd Natural Number upto 10 terms : 100 Click me to see the solution
9. Write a program in C to display a pattern like a right angle triangle using an asterisk.
The pattern like :
Click me to see the solution
10. Write a C program to display a pattern like a right angle triangle with a number.
11. Write a program in C to make such a pattern like a right angle triangle with a number which will repeat a number in a row.
12. Write a program in C to make such a pattern like a right angle triangle with the number increased by 1.
13. Write a program in C to make a pyramid pattern with numbers increased by 1. 1 2 3 4 5 6 7 8 9 10 Click me to see the solution
14. Write a C program to make such a pattern as a pyramid with an asterisk.
15. Write a C program to calculate the factorial of a given number. Test Data : Input the number : 5 Expected Output : The Factorial of 5 is: 120 Click me to see the solution
16. Write a C program to display the sum of n terms of even natural numbers. Test Data : Input number of terms : 5 Expected Output : The even numbers are :2 4 6 8 10 The Sum of even Natural Number upto 5 terms : 30 Click me to see the solution
17. Write a C program to make such a pattern like a pyramid with a number which will repeat the number in the same row.
18. Write a program in C to find the sum of the series [ 1-X^2/2!+X^4/4!- .........]. Test Data : Input the Value of x :2 Input the number of terms : 5 Expected Output : the sum = -0.415873 Number of terms = 5 value of x = 2.000000 Click me to see the solution
19. Write a program in C to display the n terms of a harmonic series and their sum. 1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms Test Data : Input the number of terms : 5 Expected Output : 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + Sum of Series upto 5 terms : 2.283334 Click me to see the solution
20. Write a C program to display the pattern as a pyramid using asterisks, with each row containing an odd number of asterisks.
21. Write a program in C to display the sum of the series [ 9 + 99 + 999 + 9999 ...]. Test Data : Input the number or terms :5 Expected Output : 9 99 999 9999 99999 The sum of the saries = 111105 Click me to see the solution
22. Write a program in C to print Floyd's Triangle.
23. Write a program in C to find the sum of the series [x - x^3 + x^5 + ......]. Test Data : Input the value of x :3 Input number of terms : 5 Expected Output : The sum is : 16.375000 Click me to see the solution
24. Write a program in C to find the sum of the series [ x - x^3 + x^5 + ......]. Test Data : Input the value of x :2 Input number of terms : 5 Expected Output : The values of the series: 2 -8 32 -128 512 The sum = 410 Click me to see the solution
25. Write a C program that displays the n terms of square natural numbers and their sum. 1 4 9 16 ... n Terms Test Data : Input the number of terms : 5 Expected Output : The square natural upto 5 terms are :1 4 9 16 25 The Sum of Square Natural Number upto 5 terms = 55 Click me to see the solution
26. Write a program in C to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. Test Data : Input the number of terms : 5 Expected Output : 1 + 11 + 111 + 1111 + 11111 The Sum is : 12345 Click me to see the solution
27. Write a C program to check whether a given number is a 'Perfect' number or not. Test Data : Input the number : 56 Expected Output : The positive divisor : 1 2 4 7 8 14 28 The sum of the divisor is : 64 So, the number is not perfect. Click me to see the solution
28. Write a C program to find the 'Perfect' numbers within a given number of ranges. Test Data : Input the starting range or number : 1 Input the ending range of number : 50 Expected Output : The Perfect numbers within the given range : 6 28 Click me to see the solution
29. Write a C program to check whether a given number is an Armstrong number or not. Test Data : Input a number: 153 Expected Output : 153 is an Armstrong number. Click me to see the solution
30. Write a C program to find the Armstrong number for a given range of number. Test Data : Input starting number of range: 1 Input ending number of range : 1000 Expected Output : Armstrong numbers in given range are: 1 153 370 371 407 Click me to see the solution
31. Write a program in C to display a pattern like a diamond.
32. Write a C program to determine whether a given number is prime or not. Test Data : Input a number: 13 Expected Output : 13 is a prime number. Click me to see the solution
33. Write a C program to display Pascal's triangle. Test Data : Input number of rows: 5 Expected Output :
34. Write a program in C to find the prime numbers within a range of numbers. Test Data : Input starting number of range: 1 Input ending number of range : 50 Expected Output : The prime number between 1 and 50 are : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 Click me to see the solution
35. Write a program in C to display the first n terms of the Fibonacci series. Fibonacci series 0 1 2 3 5 8 13 ..... Test Data : Input number of terms to display : 10 Expected Output : Here is the Fibonacci series upto to 10 terms : 0 1 1 2 3 5 8 13 21 34 Click me to see the solution
36. Write a C program to display a such a pattern for n rows using a number that starts with 1 and each row will have a 1 as the first and last number.
37. Write a program in C to display a given number in reverse order. Test Data : Input a number: 12345 Expected Output : The number in reverse order is : 54321 Click me to see the solution
38. Write a C program to check whether a number is a palindrome or not. Test Data : Input a number: 121 Expected Output : 121 is a palindrome number. Click me to see the solution
39. Write a program in C to find the number and sum of all integers between 100 and 200 which are divisible by 9. Expected Output : Numbers between 100 and 200, divisible by 9 : 108 117 126 135 144 153 162 171 180 189 198 The sum : 1683 Click me to see the solution
40. Write a C program to display the pyramid pattern using the alphabet.
41. Write a program in C to convert a decimal number into binary without using an array. Test Data : Input a decimal number: 25 Binary number equivalent to said decimal number is: 0000000000000000000000000001 1001 Click me to see the solution
42. Write a C program to convert a binary number into a decimal number without using array, function and while loop. Test Data : Input a binary number :1010101 Expected Output : The Binary Number : 1010101 The equivalent Decimal Number : 85 Click me to see the solution
43. Write a C program to find the HCF (Highest Common Factor) of two numbers. Test Data : Input 1st number for HCF: 24 Input 2nd number for HCF: 28 Expected Output : HCF of 24 and 28 is : 4 Click me to see the solution
44. Write a C program to find the LCM of any two numbers using HCF. Test Data : Input 1st number for LCM: 15 Input 2nd number for LCM: 20 Expected Output : The LCM of 15 and 20 is : 60 Click me to see the solution
45. Write a program in C to find the LCM of any two numbers. Test Data : Input 1st number for LCM: 15 Input 2nd number for LCM: 20 Expected Output : The LCM of 15 and 20 is : 60 Click me to see the solution
46. Write a C program to convert a binary number into a decimal number using the math function. Test Data : Input the binary number :1010100 Expected Output : The Binary Number : 1010100 The equivalent Decimal Number is : 84 Click me to see the solution
47. Write a C program to check whether a number is a Strong Number or not. Test Data : Input a number to check whether it is Strong number: 15 Expected Output : 15 is not a Strong number. Click me to see the solution
48. Write a C program to find Strong Numbers within a range of numbers. Test Data : Input starting range of number : 1 Input ending range of number: 200 Expected Output : The Strong numbers are : 1 2 145 Click me to see the solution
49. Write a C program to find the sum of an A.P. series. Test Data : Input the starting number of the A.P. series: 1 Input the number of items for the A.P. series: 10 Input the common difference of A.P. series: 4 Expected Output : The Sum of the A.P. series are : 1 + 5 + 9 + 13 + 17 + 21 + 25 + 29 + 33 + 37 = 190 Click me to see the solution
50. Write a program in C to convert a decimal number into octal without using an array. Test Data : Enter a number to convert : 79 Expected Output : The Octal of 79 is 117. Click me to see the solution
51. Write a C program to convert an octal number to a decimal without using an array. Test Data : Input an octal number (using digit 0 - 7) :745 Expected Output : The Octal Number : 745 The equivalent Decimal Number : 485 Click me to see the solution
52. Write a C program to find the sum of the G.P. series. Test Data : Input the first number of the G.P. series: 3 Input the number or terms in the G.P. series: 5 Input the common ratio of G.P. series: 2 Expected Output : The numbers for the G.P. series: 3.000000 6.000000 12.000000 24.000000 48.000000 The Sum of the G.P. series : 93.000000 Click me to see the solution
53. Write a C program to convert a binary number to octal. Test Data : Input a binary number :1001 Expected Output : The Binary Number : 1001 The equivalent Octal Number : 11 Click me to see the solution
54. Write a program in C to convert an octal number into binary. Test Data : Input an octal number (using digit 0 - 7) :57 Expected Output : The Octal Number : 57 The equivalent Binary Number : 101111
55. Write a C program to convert a decimal number to hexadecimal. Test Data : Input any Decimal number: 79 Expected Output : The equivalent Hexadecimal Number : 4F Click me to see the solution
56. Write a program in C to check whether a number can be expressed as the sum of two prime. Test Data : Input a positive integer: 16 Expected Output : 16 = 3 + 13 16 = 5 + 11 Click me to see the solution
57. Write a C program to print a string in reverse order. Test Data : Input a string to reverse : Welcome Expected Output : Reversed string is: emocleW Click me to see the solution
58. Write a C program to find the length of a string without using the library function. Test Data : Input a string : welcome Expected Output : The string contains 7 number of characters. So, the length of the string welcome is : 7 Click me to see the solution
59. Write a C program to check the Armstrong number of n digits. Test Data : Input an integer : 1634 Expected Output : 1634 is an Armstrong number Click me to see the solution
60. Write a C program that takes user input and counts the number of characters until the end of the file. Test Data : Input characters : w3resource Expected Output : Input characters: On Linux systems and OS X EOF is CTRL+D. For Windows EOF is CTRL+Z. Number of Characters: 10 Click me to see the solution
61. Write a C program that takes input from the user and counts the number of uppercase and lowercase letters, as well as the number of other characters. Test Data : Input characters : w3resource Expected Output : Input characters: On Linux systems and OS X EOF is CTRL+D. For Windows EOF is CTRL+Z. Uppercase letters: 0 Lowercase letters: 9 Other characters: 1 Click me to see the solution
C Programming Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
Follow us on Facebook and Twitter for latest update.
- Weekly Trends and Language Statistics
SkillUp September Flat 10% OFF , Use Code: SKILL10
30-days Money-Back Guarantee
C Programming and Problem Solving in C
C language is fruit of the computer. This course helps you to collect your fruits for any career opportunities.
English [CC]
Lectures - 84
Resources - 9
Duration - 16.5 hours
Training 5 or more people ?
Get your team access to 10000+ top Tutorials Point courses anytime, anywhere.
Course Description
Are you looking for a solid start to programming? Have you heard that "C Language is the best one to start with"? You have heard it right. C Language is one of the best ways to start programming. Even though you are not a newbie, C programming is going to suit your resume pretty well.
C is the best choice because it will also allow you the master the fundamental mentality behind programming. It is one of the most powerful programming languages out there and also called to be "the mother of programming languages". There is a reason for that!
By learning C, you will open the huge, rusty doors of C++, C#, and JAVA. Because C fundamentally teaches you behind the scenes. By taking this course, you will be able to apply for any elementary job relating to C Programming.
We are also taking a problem-solving approach to C. The best skill you can have when programming. Problem-solvers tend to be better programmers at the end of the day. That's why we are more focused on giving you the ability to solve problems in any capacity. Once you become a good problem solver, it is more likely for you to become a good programmer.
You'll develop your ability to produce good code and your problem-solving skills. This course provides all the information on "why" you are doing the things that you are doing in addition to teaching you how to write in the C programming language. The details are not skipped in this course.
You will have a thorough understanding of the C programming language's principles at the end of this course.
Who this course is for:
- Those who are interested in problem-solving.
- Those who contemplate a career in electrical and computer science.
- Those who are interested in gaining a fundamental in C Programming Language.
Understands the basics of C programming language.
Gains analytical thinking ability.
Improve his/her problem-solving capacity.
Learned data types and how to manipulate them.
Using Input and Output functions efficiently.
Logical Operators.
String Characters.
Control Flow: If-Else statements - switch cases.
Loops - while - for - do.
A hundred examples and FINAL PROJECT.
Prerequisites
Enthusiasm.
A computer.
![C Programming and Problem Solving in C C Programming and Problem Solving in C](https://d3mxt5v3yxgcsr.cloudfront.net/courses/15573/course_15573_image.jpg)
Check out the detailed breakdown of what’s inside the course
Instructor Details
![example of problem solving c user profile image](https://www.tutorialspoint.com/market/public/assets/newDesign/img/default-user-img.jpg)
Course Certificate
Use your certificate to make a career change or to advance in your current career.
![example of problem solving c sample Tutorialspoint certificate](https://www.tutorialspoint.com/market/public/assets/newDesign/img/primePacks/V-certificate.png)
Our students work with the Best
![example of problem solving c adobe logo](https://www.tutorialspoint.com/market/public/assets/newDesign/img/adobe.png)
Related Video Courses
Annual membership.
Become a valued member of Tutorials Point and enjoy unlimited access to our vast library of top-rated Video Courses
![Annual Membership Annual Membership](https://www.tutorialspoint.com/market/public/assets/newDesign/img/membership-large-small.jpg)
Online Certifications
Master prominent technologies at full length and become a valued certified professional.
![Online Certifications Online Certifications](https://www.tutorialspoint.com/market/public/assets/newDesign/img/traning-for-a-team.png)
1800-202-0515
Problem Solving with Computer
By Bipin Tiwari
Problem Solving is a scientific technique to discover and implement the answer to a problem. The computer is the symbol manipulating device that follows the set of commands known as program.
Program is the set of instructions which is run by the computer to perform specific task. The task of developing program is called programming.
Problem Solving Technique:
Sometimes it is not sufficient just to cope with problems. We have to solve that problems. Most people are involving to solve the problem. These problem are occur while performing small task or making small decision. So, Here are the some basic steps to solve the problems
Step 1: Identify and Define Problem
Explain you problem clearly as possible as you can.
Step 2: Generate Possible Solutions
- List out all the solution that you find. Don’t focus on the quality of the solution
- Generate the maximum number of solution as you can without considering the quality of the solution
Step 3: Evaluate Alternatives
After generating the maximum solution, Remove the undesired solutions.
Step 4: Decide a Solution
After filtering all the solution, you have the best solution only. Then choose on of the best solution and make a decision to make it as a perfect solution.
Step 5: Implement a Solution:
After getting the best solution, Implement that solution to solve a problem.
Step 6: Evaluate the result
After implementing a best solution, Evaluate how much you solution solve the problem. If your solution will not solve the problem then you can again start with Step 2 .
Algorithm is the set of rules that define how particular problem can be solved in finite number of steps. Any good algorithm must have following characteristics
- Input: Specify and require input
- Output: Solution of any problem
- Definite: Solution must be clearly defined
- Finite: Steps must be finite
- Correct: Correct output must be generated
Advantages of Algorithms:
- It is the way to sole a problem step-wise so it is easy to understand.
- It uses definite procedure.
- It is not dependent with any programming language.
- Each step has it own meaning so it is easy to debug
Disadvantage of Algorithms:
- It is time consuming
- Difficult to show branching and looping statement
- Large problems are difficult to implement
The solution of any problem in picture form is called flowchart. It is the one of the most important technique to depict an algorithm.
Advantage of Flowchart:
- Easier to understand
- Helps to understand logic of problem
- Easy to draw flowchart in any software like MS-Word
- Complex problem can be represent using less symbols
- It is the way to documenting any problem
- Helps in debugging process
Disadvantage of Flowchart:
- For any change, Flowchart have to redrawn
- Showing many looping and branching become complex
- Modification of flowchart is time consuming
Symbol Used in Flowchart:
Terminal | Terminal represent start and end | |
Input / Output | Used for input (reading) and output (printing) operation. | |
Processing | Used for data manipulation and data operations. | |
Arrow | Used to represent flow of operations. | |
Connector | Used to connect different flow of lines | |
Decision | Used to make decision |
Example: Algorithm and Flowchart to check odd or even
Coding, Compiling and Execution
Question's answer.
Share this link via
Or copy link
Copyright 2022 | HAMROCSIT.COM | All Right Reserved
Learn C practically and Get Certified .
Popular Tutorials
Popular examples, reference materials, learn c interactively, c introduction.
- Getting Started with C
- Your First C Program
C Fundamentals
- C Variables, Constants and Literals
- C Data Types
- C Input Output (I/O)
- C Programming Operators
C Flow Control
- C if...else Statement
- C while and do...while Loop
- C break and continue
- C switch Statement
- C goto Statement
- C Functions
- C User-defined functions
- Types of User-defined Functions in C Programming
C Recursion
- C Storage Class
C Programming Arrays
- C Multidimensional Arrays
- Pass arrays to a function in C
C Programming Pointers
- Relationship Between Arrays and Pointers
- C Pass Addresses and Pointers
- C Dynamic Memory Allocation
- C Array and Pointer Examples
- C Programming Strings
- String Manipulations In C Programming Using Library Functions
String Examples in C Programming
C Structure and Union
- C structs and Pointers
- C Structure and Function
C Programming Files
- C File Handling
- C Files Examples
C Additional Topics
- C Keywords and Identifiers
- C Precedence And Associativity Of Operators
- C Bitwise Operators
- C Preprocessor and Macros
- C Standard Library Functions
C Tutorials
- Check Prime or Armstrong Number Using User-defined Function
C Control Flow Examples
- Check Whether a Number can be Expressed as Sum of Two Prime Numbers
- Convert Binary Number to Octal and vice-versa
- Find Factorial of a Number Using Recursion
C Function Examples
A function is a block of code that performs a specific task.
You will find examples related to functions in this article. To understand examples in this page, you should have the knowledge of the following topics:
- User-Defined Function
- Types of User-defined functions
- Scope of a local variable
Sorry about that.
Our premium learning platform, created with over a decade of experience and thousands of feedbacks .
Learn and improve your coding skills like never before.
- Interactive Courses
- Certificates
- 2000+ Challenges
Related Tutorials
C Struct Examples
![example of problem solving c time-travel-ticket](https://leetcode.com/_next/static/images/ttt-a2c700529300981c5d372d69bb9bbdaa.png)
![example of problem solving c Codeforwin](https://codeforwin.org/wp-content/uploads/2023/01/codeforwin_900x300.png)
Loop programming exercises and solutions in C
In programming, there exists situations when you need to repeat single or a group of statements till some condition is met. Such as – read all files of a directory, send mail to all employees one after another etc. These task in C programming is handled by looping statements .
Looping statement defines a set of repetitive statements. These statements are repeated with same or different parameters for a number of times. Looping statement is also known as iterative or repetitive statement .
C supports three looping statements.
- do…while loop
In this exercise we will practice lots of looping problems to get a strong grip on loop. This is most recommended C programming exercise for beginners.
Always feel free to drop your queries, suggestions, hugs or bugs down below in the comments section . I always look forward to hear from you.
Required knowledge
Basic C programming , Relational operators , Logical operators , If else , For loop
List of loop programming exercises
- Write a C program to print all natural numbers from 1 to n. – using while loop
- Write a C program to print all natural numbers in reverse (from n to 1) . – using while loop
- Write a C program to print all alphabets from a to z. – using while loop
- Write a C program to print all even numbers between 1 to 100. – using while loop
- Write a C program to print all odd number between 1 to 100.
- Write a C program to find sum of all natural numbers between 1 to n.
- Write a C program to find sum of all even numbers between 1 to n .
- Write a C program to find sum of all odd numbers between 1 to n .
- Write a C program to print multiplication table of any number .
- Write a C program to count number of digits in a number .
- Write a C program to find first and last digit of a number .
- Write a C program to find sum of first and last digit of a number.
- Write a C program to swap first and last digits of a number .
- Write a C program to calculate sum of digits of a number .
- Write a C program to calculate product of digits of a number .
- Write a C program to enter a number and print its reverse .
- Write a C program to check whether a number is palindrome or not.
- Write a C program to find frequency of each digit in a given integer .
- Write a C program to enter a number and print it in words.
- Write a C program to print all ASCII character with their values .
- Write a C program to find power of a number using for loop .
- Write a C program to find all factors of a number .
- Write a C program to calculate factorial of a number .
- Write a C program to find HCF (GCD) of two numbers .
- Write a C program to find LCM of two numbers .
- Write a C program to check whether a number is Prime number or not.
- Write a C program to print all Prime numbers between 1 to n.
- Write a C program to find sum of all prime numbers between 1 to n .
- Write a C program to find all prime factors of a number .
- Write a C program to check whether a number is Armstrong number or not.
- Write a C program to print all Armstrong numbers between 1 to n.
- Write a C program to check whether a number is Perfect number or not .
- Write a C program to print all Perfect numbers between 1 to n .
- Write a C program to check whether a number is Strong number or not .
- Write a C program to print all Strong numbers between 1 to n .
- Write a C program to print Fibonacci series up to n terms .
- Write a C program to find one’s complement of a binary number .
- Write a C program to find two’s complement of a binary number .
- Write a C program to convert Binary to Octal number system .
- Write a C program to convert Binary to Decimal number system .
- Write a C program to convert Binary to Hexadecimal number system .
- Write a C program to convert Octal to Binary number system .
- Write a C program to convert Octal to Decimal number system .
- Write a C program to convert Octal to Hexadecimal number system .
- Write a C program to convert Decimal to Binary number system .
- Write a C program to convert Decimal to Octal number system .
- Write a C program to convert Decimal to Hexadecimal number system .
- Write a C program to convert Hexadecimal to Binary number system .
- Write a C program to convert Hexadecimal to Octal number system .
- Write a C program to convert Hexadecimal to Decimal number system .
- Write a C program to print Pascal triangle upto n rows .
- Star pattern programs – Write a C program to print the given star patterns.
- Number pattern programs – Write a C program to print the given number patterns .
![](http://pechenka.online/777/templates/cheerup1/res/banner1.gif)
IMAGES
VIDEO
COMMENTS
Practice Questions with Solutions for C Programming
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 ...
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. C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.
Solve C - HackerRank ... Solve C
C programming examples, exercises and solutions for ...
C Programming Examples include many programs, from beginner-level examples like "Hello World" and "Sum of Two Numbers" to more advanced programs like the Fibonacci series and Prime Numbers. ... Diverse Problem-Solving: C programming examples cover a wide range of problems, including mathematical calculations, string manipulations, array ...
1000 C Programs (C Programming Examples)
Problem solving in C. Beginner level. Practice. Practice Basic Math. Beginner level. Practice. Practice Strings. Beginner level. Earn certificate after completing all the problems. Prerequisite course. Learn C Programming. Beginner. 4.6 (13856) 76.5k learners 36 lessons.
C Exercises - W3Schools ... C Exercises
Learn problem solving in C from our online course and tutorial. You will learn basic math, conditionals and step by step logic building to solve problems easily. 4.5 (1483 reviews) 18 lessons Beginner level. 24.4k Learners.
C Solved programs —-> C is a powerful general-purpose programming language. It is fast, portable and available in all platforms. If you are new to programming, C is a good choice to start your programming journey. This page contains the C solved programs/examples with solutions, here we are providing most important programs on each topic ...
Basic programming exercises and solutions in C
Table of Contents. Introduction to Problem Solving Through Programming in C. Problem Solving Through Programming in C. Steps to Solve a Problem With the Computer. Step 1: Understanding the Problem: Step 2: Analyzing the Problem: Step 3: Developing the solution: Step 4: Coding and Implementation: Problem Solving Steps.
Go to the editor] 1. Write a C program to compute the sum of the two input values. If the two values are the same, then return triple their sum. Expected Output: 3 12. Click me to see the solution. 2. Write a C program that will take a number as input and find the absolute difference between the input number and 51.
C programming exercises: For Loop
List of function and recursion programming exercises. Write a C program to find cube of any number using function. Write a C program to find diameter, circumference and area of circle using functions. Write a C program to find maximum and minimum between two numbers using functions. Write a C program to check whether a number is even or odd ...
By learning C, you will open the huge, rusty doors of C++, C#, and JAVA. Because C fundamentally teaches you behind the scenes. By taking this course, you will be able to apply for any elementary job relating to C Programming. We are also taking a problem-solving approach to C. The best skill you can have when programming.
C Examples - Programiz ... C Examples
Step 1: Identify and Define Problem. Explain you problem clearly as possible as you can. Step 2: Generate Possible Solutions. List out all the solution that you find. Don't focus on the quality of the solution. Generate the maximum number of solution as you can without considering the quality of the solution.
If else programming exercises and solutions in C. if...else is a branching statement. It is used to take an action based on some condition. For example - if user inputs valid account number and pin, then allow money withdrawal. If statement works like "If condition is met, then execute the task". It is used to compare things and take some ...
C Function Examples
Problems - LeetCode
Loop programming exercises and solutions in C