Introduction to C language


C language is a procedural programming language. It was originally developed by Dennis Ritchie in 1972. It was developed primarily as a system programming language for writing an operating system. The main features of the C language include low access to memory, a simple set of keywords and clean style, these features make the C language suitable for system programmings such as an operating system or compiler development.

Many later languages ​​borrowed syntaxes/features directly or indirectly from the C language. Like Java syntax, PHP, JavaScript, and many other languages ​​rely primarily on the C language. C ++ is almost a superset of the C language (There are few programs that can be compiled in C, but not in C ++).

List of Topics

  • Introduction to C language
  • Starting with c programming
  • How to override the above program
  • How to override the above program
  • Questions and answers

Starting with C programming:

The structure of a program C

After the above discussion, we can formally evaluate the structure of a C program. By structure, it is understood that any program can be written only in this structure. Writing a C program in any other structure will lead to a compilation error.

The structure of a C program is as follows:

Introduction to C language

The components of the above structure are:

Including header files: The first and most important component is the inclusion of header files in a C program. A header file is a file with the .h extension that contains C function statements and macro definitions that must be split between several source files.Some of the C header files

  • stddef.h – defines several useful types and macros.
  • stdint.h – defines the exact types of integers of width.
  • stdio.h – Defines the basic input and output functions
  • stdlib.h – Defines the functions of digital conversion, pseudo-random network generator,memory allocation.
  • string.h – Defines string manipulation functions.
  • math.h – Defines common mathematical functions.

Syntax for including a header file in C:

include

Main method statement: The next part of a C program is the main function statement (). The syntax for declaring the main function is :

main int ()
{}


Variable declaration: The next part of any C program is the variable declaration. Refers to the variables that will be used depending on the function. Please note that in program C, no variables can be used without being declared. Also, in a C program, variables must be declared before any operation in the function.
Example:

main int ()
{
int x;
.
.

Body: The body of a function in program C, refers to the operations that are performed in the functions. It can be anything, such as manipulations, search, sort, print, etc.
Example:

int main()
{ 

int x; 
printf ("%d", x);
. 
.


Return Declaration: The last part of any C program is the return declaration. The return statement refers to the return of values ​​in a function. This return statement and the return value depend on the return type of the function. For example, if the return type is null, then there will be no return declaration. In any other case, there will be a return declaration, and the value returned will be of the type of the specified return type.
Example:

int main()
{
int x;

printf ("%d", x);

return 0;
}</strong>


Writing the first program:

Introduction to C language program in C as follows

#include <stdio.h> 
int main(void) 
{ 
    printf("Welcome to Projugaadu"); 
    return 0; 
} 


Let’s analyze the program line one by one.

Line 1: [#include <stdio.h> ] In a C program, all lines starting with # are processed by the preprocessor, which is a program invoked by the compiler. In a very basic term, the preprocessor takes a C program and produces another C program. The produced program has no lines starting with #, all these lines are processed by the preprocessor. In the example above, the preprocessor copies the preprocessed code of stdio.h to our file. .H files are called header files in C. These header files generally contain the function statement. We need stdio.h for the printf () function used in the program.

Line 2 [int main (void)] There must be a starting point where the execution of the compiled C program begins. In C, execution usually starts with the first main line (). The gap in parentheses indicates that the principal does not take any parameters (see this for more details). main () can be written to take and parameters. We’ll cover that in future posts.
Int main writing before main indicates the return type of main (). The value returned by the principal indicates the status of the program termination. See this post for more details on the type of return.

Lines 3 and 6: [{and}] In the C language, a pair of curly parentheses define a purpose and are used primarily in control functions and instructions, such as, if otherwise, loops. All functions must begin and end with chalk brackets.

Line 4 (printf (“Welcome to Projugaadu”); ] printf () is a standard library function to print something on standard output. The semicolon at the end of printf indicates the end of the line. In C, a semicolon is always used to indicate the end of the statement.

Line 5 [return 0; ] The return statement returns the value from the principal (). The returned value can be used by the operating system to know the end status of your program. A value of 0 usually means successful completion.


How to override the above program:


In order to run the above program, we need a compiler to compile and run our programs. There are some online compilers such as http://ideone.com/ or http://codepad.org/ that can be used to start C without installing a compiler.

Windows: There are many freely available compilers for compiling C programs such as Code Blocks and Dev-CPP. We strongly recommend the code blocks.

Linux: For Linux, gcc comes with linux, the codes can also be used with Linux.

Introduction to C language

Question And Answers

What c language :- It is machine-independent, structured programming language which is used extensively in various applications

who invented c language:- Dennis Ritchie

When c language is invented :- 1972

you can get more c language related articles here

http://projugaadu.com/category/topics/c-language/

Leave a Comment