w3resource

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, and used to re-implement the Unix operating system. 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 .... Happy Coding!

List of C Programming Exercises :

[ 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.]

Popularity of Programming Language
Worldwide, Apr 2021 compared to a year ago:

Rank Change Language Share Trend
1 Python 29.5 % -0.1 %
2 Java 17.51 % -0.6 %
3 Javascript 8.19 % +0.2 %
4 C# 7.05 % -0.2%
5 up arrow C/C++ 6.73 % +1.0 %
6 down arrow PHP 6.23 % +0.0 %
7 R 3.86 % +0.0 %
8 Objective-C 2.77 % +0.3 %
9 up arrow TypeScript 1.87 % -0.0 %
10 down arrow Swift 1.85 % -0.3 %
11 up arrow Kotlin 1.78 % +0.3 %
12 down arrow Matlab 1.77 % -0.1 %
13 up arrow Go 1.37 % +0.1 %
14 down arrow VBA 1.33 % -0.0 %
15 Ruby 1.21 % -0.1 %
16 up arrow Rust 1.1 % +0.4 %
17 up arrow Ada 0.8 % +0.5 %
18 down arrow Scala 0.72 % -0.3 %
19 down arrow Visual Basic 0.71 % -0.2 %
20 down arrow Abap 0.58 % +0.0 %
21 up arrow Lua 0.57 % +0.3 %
22 down arrow Dart 0.52 % +0.0 %
23 down arrow Perl 0.41 % -0.0 %
24 up arrow Julia 0.38 % +0.1 %
25 up arrow Cobol 0.35 % +0.0 %
26 down arrow Groovy 0.34 % -0.1 %
27 down arrow Haskell 0.25 % -0.1 %
28 Delphi 0.25 % -0.0 %

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

TIOBE Index for April 2021

Apr 2021 Apr 2020 Change Programming Language Ratings Change
1 2 up arrow C 14.32% -2.40%
2 1 down arrow Java 11.23% -5.49%
3 3 Python 11.03% +1.72%
4 4 C++ 7.14% +0.36%
5 5 C# 4.91% +0.16%
6 6 Visual Basic 4.55% -0.18%
7 7 JavaScript 2.44% +0.06%
8 14 up arrow Assembly language 2.32% +1.16%
9 8 down arrow PHP 1.84% -0.54%
10 9 down arrow SQL 1.83% -0.34%
11 19 up arrow Classic Visual Basic 1.54% +0.71%
12 22 up arrow Delphi/Object Pascal 1.47% +0.77%
13 13 Ruby 1.23% -0.02%
14 12 down arrow Go 1.22% -0.13%
15 11 down arrow Swift 1.19% -0.32%
16 10 down arrow R 1.12% -0.42%
17 48 up arrow Groovy 1.04% +0.86%
18 16 down arrow Perl 0.99% +0.03%
19 18 down arrow MATLAB 0.99% +0.06%
20 34 up arrow Fortan 0.91% +0.58%

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

List of Exercises with Solutions :



C Programming: Tips of the Day

C Programming - How to print a int64_t type in C?

For int64_t type:

#include <inttypes.h>
int64_t t;
printf("%" PRId64 "\n", t);
for uint64_t type:

for uint64_t type:

#include <inttypes.h>
uint64_t t;
printf("%" PRIu64 "\n", t);

you can also use PRIx64 to print in hexadecimal.

cppreference.com has a full listing of available macros for all types including intptr_t (PRIxPTR). There are separate macros for scanf, like SCNd64.

A typical definition of PRIu16 would be "hu", so implicit string-constant concatenation happens at compile time.

For your code to be fully portable, you must use PRId32 and so on for printing int32_t, and "%d" or similar for printing int.

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