C Programming Language (1) (1)
C Programming Language (1) (1)
Programming
Language
What is C Programming Language?
➢Turbo C
➢Tiny C Compiler
➢GCC
➢Clang
➢Portable C Compiler
Structure of a Basic C Program
Link
❖ This section includes all header files. A header file is a file that
contains C declarations that can be shared among many files. We
can use other people’s codes in our files due to it. Before
compilation, a copy of these header files is inserted into your code.
#include
Documentation
❖ In a C program, single-line comments can be written using two
forward slashes i.e., //, and we can create multi-line
comments using / /. Here, we’ve used multi-line comments.
Definition
❖Any statement in C that starts with the symbol "#" is referred to
be a preprocessor directive. Constants are made using the
#define preprocessor compiler command. The usage of
constants in our code is fundamentally made possible by
#define, which enables the macro declaration. #define BORN
2000
Global Declaration
❖ All global variables, function declarations, and static variables
are contained in this section. Anywhere in the program can
utilize the variables specified in this section. They get access to
all of the program’s features. Consequently, they are known as
global variables
Main() Function
❖ This section of a C program’s structure comprises the code’s
primary purpose. The main() function is when the compiler
begins running code. It may make use of user-defined
functions as well as built-in and global variables. The main()
function’s return type is not required to be an int and can
alternatively be void.
Subprograms
❖ This also applies to the user-defined programs that the main()
function calls. Regardless of their sequence, user-defined functions
are typically written after the main() function. The program’s control
switches to the user-defined function when it is called from the
main() function, and it returns to the main() function when it meets a
return statement. In this instance, we’ve developed the age()
function, which only accepts the current year as an input.
Formation of C
#include This is the main header file preprocessor function, which
preprocesses standard input and output header files from the C library
repository, such as <stdio.h>,before compiling the program.
int main() This C statement, like most programming languages, is
the main function, which is the point where the program execution
begins. Once the primary main () has been executed, all other methods
and functions are performed.
{ Curly braces are a type of bracket that can be seen in any
computer language, not just C. This represents the start of a method or
function definition.
✓ /* explanation of C code */ The text inside the /* and */ tags will be
considered as comments and will not be executed or compile.
✓ Printf The output is printed to the console screen using this C
command.
✓ Scanf The user data is taken from the usual console terminal window
using this C function.
✓ Getch() This function is being used to wait for the user's input.
✓ return 0 This C function returns 0 after terminating the C program or
main function.
✓ } The function or method block is closed with these curly braces.
✓ // These are called single line comments, and they are utilized not only
in the C programming language but in others as well.
Data Types in C
➢Rich Library
C provides a lot of inbuilt functions that make the development fast.
➢Memory Management
It supports the feature of dynamic memory allocation. In C language,
we can free the allocated memory at any time by calling the free() function.
Features of C Language
➢Speed
The compilation and execution time of C language is fast since there
are lesser inbuilt functions and hence the lesser overhead.
➢Pointer
provides the feature of pointers. We can directly interact with the
memory by using the pointers. We can use pointers for memory, structures,
functions, array, etc..
Features of C Language
➢Recursion
In C, we can call the function within the function. It provides code
reusability for every function. Recursion enables us to use the approach of
backtracking.
➢Extensible
C language is extensible because it can easily adopt new features.
#include <stdio.h>
int main() {
return 0; }
Thank you