Document

What is C?⁣

Why should we learn C/ Features of C?

  1. As mentioned above, it is one of the most popular programming languages in the world.
  2. Learning any other popular programming language such as Python or C++ becomes a cakewalk already if you know C.
  3. C is a flexible language and that gets proven by the fact that it can be used in a variety of applications as well as technologies.
  4. C is very fast when compared to other programming languages be it Java or Python.
  5. C takes only significant CPU time for interpretation. That is why a lot of Python libraries such as NumPy, pandas, Scikit-learn, etc. are built using C.
  6. Being close to Machine language, some of its functions include direct access to machine-level hardware APIs.

C Data Types & Constants


Datatype

It is the type of value which the variable holds.
Here, we will focus on the most basic ones:

Constants

Operators

Special symbols that are used to perform actions or operations are known as operators. They could be both unary or binary.
For example, the symbol asterisk (*) is used to perform multiplication in C so it is an operator and it is a binary operator.
This section covers all types of operators.

Types of operators

C if...else statements

Sometimes, we wish to execute one set of instructions if a particular condition is met, and another set of instructions if it is not. This kind of situation is dealt with in C language using a decision control system.
The condition for the if statement is always enclosed within a pair of parentheses. If the condition is true, then the set of statements following the if statement will execute. And if the condition evaluates to false, then the statement will not execute, instead, the program skips that enclosed part of the code.
An expression in if statements are defined using relational operators. Comparing two values using relational operators allows us to determine whether they are equal, unequal, greater than, or less than.
If we want to execute a particular code in some situation and its vice versa /opposite/or different code if that situation doesn’t occurs then if..else statements can be used. Its all depend on the condition. If the condition returns true value the situation has occurred and the true part of code will be executed and if condition returns false value false part of the code will be executed

Following is the syntax of if-else statements:

One example where we could use the if-else statement is:

Output:

Functions


A function is nothing but a group of code put together and given a name and it can be called anytime without writing the whole code again and again in a program.
I know its syntax is a bit difficult to understand but don’t worry after reading this whole information about Functions you will know each and every term or thing related to Functions.


Types of functions

  1. Library functions:
  2. Library functions are pre-defined functions in C Language. These are the functions that are included in C header files prior to any other part of the code in order to be used.
    E.g. printf(), scanf(), etc.

  3. User-defined functions:
  4. User-defined functions are functions created by the programmer for the reduction of the complexity of a program. Rather, these are functions that the user creates as per the requirements of a program.
    E.g. Any function created by the programmer.


Here’s the basic syntax of a function

Document
PROCODING
Copyright © 2023 to Rohit Negi