# C Programming Exercises, Practice, Solution

## What is C Programming Language?

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. It has since become one of the most widely used programming languages of all time, with C compilers from various vendors available for the majority of existing computer architectures and operating systems.

The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with C programming.

Hope, these exercises help you to improve your C programming coding skills. Currently, following sections are available, we are working hard to add more exercises. Please refer to this page for important C snippets, code, and examples before starting the exercises. Happy Coding!

**List of C Programming Exercises :**

- Basic Declarations and Expressions [ 142 Exercises with Solution ]
- Basic Part-II [ 2 Exercises with Solution ]
- Basic Algorithm [ 75 Exercises with Solution ]
- Variable Type [ 18 Exercises with Solution ]
- Input, Output [ 10 Exercises with Solution ]
- Conditional Statement [ 26 Exercises with Solution ]
- For Loop [ 59 Exercises with Solution ]
- Array [ 107 Exercises with Solution ]
- Pointer [ 22 Exercises with Solution ]
- Linked List [ 30 Exercises with Solution ]
- Numbers [ 38 Exercises with Solution ]
- String [ 41 Exercises with Solution ]
- Date Time [ 10 Exercises with Solution ]
- Math [ 28 Exercises with Solution ]
- Function [ 12 Exercises with Solution ]
- Recursion [ 21 Exercises with Solution ]
- File Handling [ 15 Exercises with Solution ]
- Search and Sorting [ 31 Exercises with Solution ]
- Challenges [ 35 exercises with solution ]
- C Snippets [ 4 exercises with solution ]
- More to Come !

[ Want to contribute to C exercises? Send your code (attached with a .zip file) to us at w3resource[at]yahoo[dot]com. Please avoid copyrighted materials.]

**Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.**

## Popularity of Programming Language

Worldwide, Oct 2022 compared to a year ago:

Rank | Change | Language | Share | Trend |
---|---|---|---|---|

1 | Python | 28.3 % | -1.8 % | |

2 | Java | 17.2 % | -0.9 % | |

3 | Javascript | 9.69 % | +0.4 % | |

4 | C# | 7.2 % | -0.2% | |

5 | C/C++ | 6.45 % | -0.4 % | |

6 | PHP | 5.39 % | -0.9 % | |

7 | R | 4.03 % | +0.3 % | |

8 | TypeScript | 2.17 % | +1.1 % | |

9 | Objective-C | 2.16 % | +0.2 % | |

10 | Go | 2.08% | +0.5 % | |

11 | Swift | 2.05% | +0.4 % | |

12 | Kotlin | 1.81 % | +0.1 % | |

13 | Rust | 1.57 % | +0.8 % | |

14 | Matlab | 1.52 % | +0.1 % | |

15 | Ruby | 1.13 % | +0.1% | |

16 | VBA | 0.96 % | -0.3 % | |

17 | Scala | 0.78 % | +0.3 % | |

18 | Ada | 0.76 % | +0.2 % | |

19 | Dart | 0.75 % | +0.1 % | |

20 | Visual Basic | 0.64 % | -0.2 % | |

21 | Lua | 0.61 % | +0.2 % | |

22 | Abap | 0.48 % | -0.1 % | |

23 | Groovy | 0.44 % | -0.1 % | |

24 | Cobol | 0.32 % | -0.0 % | |

25 | Julia | 0.28 % | -0.1 % | |

26 | Perl | 0.28 % | -0.1 % | |

27 | Haskell | 0.28 % | +0.0 % | |

28 | Delphi/Pascal | 0.14 % | +0.1 % |

Source : https://pypl.github.io/PYPL.html

**TIOBE Index for September 2022**

Sep 2022 | Sep 2021 | Change | Programming Language | Ratings | Change |
---|---|---|---|---|---|

1 | 2 | Python | 15.74% | +4.07% | |

2 | 1 | C | 13.96% | +2.13% | |

3 | 3 | Java | 11.72% | +0.60% | |

4 | 4 | C++ | 9.76% | +2.63% | |

5 | 5 | C# | 4.88% | -0.89% | |

6 | 6 | Visual Basic | 4.39% | -0.22% | |

7 | 7 | JavaScript | 2.82% | +0.27% | |

8 | 8 | Assembly language | 2.49% | +0.07% | |

9 | 10 | SQL | 2.01% | +0.21% | |

10 | 9 | PHP | 1.68% | -0.17% | |

11 | 24 | Objective-C | 1.49% | +0.86% | |

12 | 14 | Go | 1.16% | +0.03% | |

13 | 20 | Delphi/Object Pascal | 1.09% | +0.32% | |

14 | 16 | MATLAB | 1.06% | +0.04 | |

15 | 17 | Fortan | 1.03% | +0.02% | |

16 | 15 | Swift | 0.98% | -0.09% | |

17 | 11 | Classic Visual Basic | 0.98% | -0.55% | |

18 | 18 | R | 0.95% | -0.02% | |

19 | 19 | Perl | 0.72% | -0.06% | |

20 | 13 | Ruby | 0.66% | -0.62% |

Source : https://www.tiobe.com/tiobe-index/

**List of Exercises with Solutions :**

- HTML CSS Exercises, Practice, Solution
- JavaScript Exercises, Practice, Solution
- jQuery Exercises, Practice, Solution
- jQuery-UI Exercises, Practice, Solution
- CoffeeScript Exercises, Practice, Solution
- Twitter Bootstrap Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution
- C# Sharp Programming Exercises, Practice, Solution
- PHP Exercises, Practice, Solution
- Python Exercises, Practice, Solution
- R Programming Exercises, Practice, Solution
- Java Exercises, Practice, Solution
- SQL Exercises, Practice, Solution
- MySQL Exercises, Practice, Solution
- PostgreSQL Exercises, Practice, Solution
- SQLite Exercises, Practice, Solution
- MongoDB Exercises, Practice, Solution

## C Programming: Tips of the Day

**~x + ~y == ~(x + y) is always false? **

Assume for the sake of contradiction that there exists some x and some y (mod 2n) such that

~(x+y) == ~x + ~y

By two's complement*, we know that,

-x == ~x + 1 <==> -1 == ~x + x

Noting this result, we have,

~(x+y) == ~x + ~y <==> ~(x+y) + (x+y) == ~x + ~y + (x+y) <==> ~(x+y) + (x+y) == (~x + x) + (~y + y) <==> ~(x+y) + (x+y) == -1 + -1 <==> ~(x+y) + (x+y) == -2 <==> -1 == -2

Hence, a contradiction. Therefore, ~(x+y) != ~x + ~y for all x and y (mod 2n).

*It is interesting to note that on a machine with one's complement arithmetic, the equality actually holds true for all x and y. This is because under one's complement, ~x = -x. Thus, ~x + ~y == -x + -y == -(x+y) == ~(x+y).

Ref : https://bit.ly/3EcHJb3

**Exercises: Weekly Top 16 Most Popular Topics**- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- JavaScript basic - Exercises, Practice, Solution
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- JavaScript conditional statements and loops - Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation