Sunday, August 5, 2018

What is C language? First program in C!!

Introduction
The programming dialect C was produced in the mid-1070s by Ritchie at Bell Laboratories to be utilized by the UNIX working framework. It was named "C" in light of the fact that a significant number of its highlights were gotten from a before dialect called 'B'. In spite of the fact that C was intended for actualizing framework programming, it was later on generally utilized for creating compact application programming.

What is C language? First program in C!!
What is C language? First program in C!!

C is a standout amongst the most well-known programming dialects. It is being utilized on a few distinctive programming stages. More or less, there are a couple of PC designs for which a C compiler does not exist.

Background
Like many other modern languages, C is derived from ALGOL (The first language to use a block structure). Although ALGOL was not accepted widely in the United States it was widely used in Europe. ALGOL’s introduction in the 1960s led the way for the development of structured programming concepts.

Characteristics of C
C is a vigorous language whose rich arrangement of inherent capacities and administrators can be utilized to compose complex projects. The C compiler joins the highlights of low-level computing construct and abnormal state dialect which makes it most appropriate for composing framework programming and additionally business bundles.

Characteristics of C is:

1. A high-level programming language enables the programmer to concentrate on the problem at hand and not worry about the machine code on which the program would be run.
2. Small size C has only 32 keywords.
3. Makes extensive use of function calls.
4. C is well suited for structured programming.
5. Unlike PASCALL it supports loose typing.
6. Stable language. ANSI C was created in 1983 and since then it has not been revised.

Structure of a C Program
C program is composed of pre-processor commands, a global declaration section, and one or more functions.

Global declaration
Main()
{
       Local declarations
       Statements
}
Funtion 1()
{
       Local declarations
       Statements
}
Funtion N()
{
       Local declarations
       Statements
}



Writing the first C Program

#include<stdio.h>
Int main()
{
       printf(“\n Welcome to the world of C”);
       return 0;
}

Output
       Welcome to the world of C

#include<stdio.h>
This is a pre-processor command the comes as the first statement in our code. All pre-processor commands start with symbol hash (#). The #include statement tells the compiler to include the standard input/output library or header file (stdio.h) in the program. This file in our code we can use these functions directly. The standard input/output header file contains functions for input and output of data like reading values from the keyboard and printing the result.

int main()
int is the return value of the main function. After all the statements in the program have been written, the last statement of the program will return an integer value to the operating system. The concepts will be clear to us when we read the chapter on Functions. So even if you do not no understand certain things, do not worry.

{}
The two curly brackets are used to group all the related statements of the function main. All the statements between the braces from the function body. The function body contains a set of instructions to perform the given task.

printf(“\n Welcome to the world of C”)
The printf function is defined in the stdio.h file and is used to print text on the screen. The message that has to be displayed on the screen. The message that has to be displayed on the screen in enclosed is enclosed within double quotes and put inside brackets.

return 0;
This is a return command that is used to return the value 0 to the operating system to give an indication that there were no errors during the execution of the program. 

0 comments:

Post a Comment