0% found this document useful (0 votes)
4 views3 pages

C Notes

The document discusses computer languages, categorizing them into low level and high level languages, detailing their functions and examples. It explains the role of language processors, including compilers, assemblers, and interpreters, in translating high level languages into machine code. Additionally, it introduces the C programming language, its structure, and key components necessary for writing a C program.

Uploaded by

Rashi Tanwar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

C Notes

The document discusses computer languages, categorizing them into low level and high level languages, detailing their functions and examples. It explains the role of language processors, including compilers, assemblers, and interpreters, in translating high level languages into machine code. Additionally, it introduces the C programming language, its structure, and key components necessary for writing a C program.

Uploaded by

Rashi Tanwar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Computer Languages

The user of a computer must be able to communicate with it. That means, he must be able to give the computer
commands and understand the output that the computer generates. This is possible due to the invention of
computer languages.
Basically, there are two main categories of computer languages, namely Low Level Language and High Level
Language. Let us take a brief look at both these types of computer languages.

1] Low Level Languages


Low level languages are the basic computer instructions or better known as machine codes. A computer cannot
understand any instruction given to it by the user in English or any other high level language. These low level
languages are very easily understandable by the machine.
The main function of low level languages is to interact with the hardware of the computer. They help in
operating, syncing and managing all the hardware and system components of the computer. They handle all the
instructions which form the architecture of the hardware systems.
Machine Language
This is one of the most basic low level languages. The language was first developed to interact with the first
generation computers. It is written in binary code or machine code, which means it basically comprises of only
two digits – 1 and 0.
Assembly Language
This is the second generation programming language. It is a development on the machine language, where
instead of using only numbers, we use English words, names, and symbols. It is the most basic computer
language necessary for any processor.

2] High Level Language


When we talk about high level languages, these are programming languages. Some prominent examples are
PASCAL, FORTRAN,C, C++ etc. The important feature about such high level languages is that they allow
the programmer to write programs for all types of computers and systems. Every instruction in high level
language is converted to machine language for the computer to comprehend.
Language Processors –
Assembly language is machine dependent yet mnemonics that are being used to represent instructions in it
are not directly understandable by machine and high Level language is machine independent. A computer
understands instructions in machine code, i.e. in the form of 0s and 1s. It is a tedious task to write a
computer program directly in machine code. The programs are written mostly in high level languages like
Java, C++, Python etc. and are called source code. These source code cannot be executed directly by the
computer and must be converted into machine language to be executed. Hence, a special translator system
software is used to translate the program written in high-level language into machine code is
called Language Processor and the program after translated into machine code (object program / object
code).
The language processors can be any of the following three types:
1. Compiler –
The language processor that reads the complete source program written in high level language as a
whole in one go and translates it into an equivalent program in machine language is called as a
Compiler.
Example: C, C++, C#, Java
In a compiler, the source code is translated to object code successfully if it is free of errors. The
compiler specifies the errors at the end of compilation with line numbers when there are any errors in
the source code. The errors must be removed before the compiler can successfully recompile the source
code again.
2. Assembler –
The Assembler is used to translate the program written in Assembly language into machine code. The
source program is a input of assembler that contains assembly language instructions. The output
generated by assembler is the object code or machine code understandable by the computer.
3. Interpreter –
The translation of single statement of source program into machine code is done by language processor
and executes it immediately before moving on to the next line is called an interpreter. If there is an
error in the statement, the interpreter terminates its translating process at that statement and displays an
error message. The interpreter moves on to the next line for execution only after removal of the error.
An Interpreter directly executes instructions written in a programming or scripting language without
previously converting them to an object code or machine code.
Example: Perl, Python and Matlab.

A programmer is a person who designs the algorithms and writes the necessary code to create an
application or computer program. A programming language is the tool or means used by
the programmer to create applications and computer programs.

C Language Introduction
C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It
was mainly developed as a system programming language to write an operating system. The main features
of C language include low-level access to memory, a simple set of keywords, and clean style, these features
make C language suitable for system programmings like an operating system or compiler development.
Many later languages have borrowed syntax/features directly or indirectly from C language. Like syntax of
Java, PHP, JavaScript, and many other languages are mainly based on C language. C++ is nearly a superset
of C language (There are few programs that may compile in C, but not in C++).

Structure of a C program
After the above discussion, we can formally assess the structure of a C program. By structure, it is meant
that any program can be written in this structure only. Writing a C program in any other structure will hence
lead to a Compilation Error.
The structure of a C program is as follows:
The components of the above structure are:
1. Header Files Inclusion: The first and foremost component is the inclusion of the Header files in a C
program.
A header file is a file with extension .h which contains C function declarations and macro definitions to
be shared between several source files.
Some of C Header files:
 stddef.h – Defines several useful types and macros.
 stdint.h – Defines exact width integer types.
 stdio.h – Defines core input and output functions
 stdlib.h – Defines numeric conversion functions, pseudo-random network generator, memory
allocation
 string.h – Defines string handling functions
 math.h – Defines common mathematical functions
Syntax to include a header file in C:
#include <stdio.h>
2. Main Method Declaration: The next part of a C program is to declare the main() function. The syntax
to declare the main function is:
Syntax to Declare main method:
int main()
{

}
3. Variable Declaration: The next part of any C program is the variable declaration. It refers to the
variables that are to be used in the function. Please note that in the C program, no variable can be used
without being declared. Also in a C program, the variables are to be declared before any operation in
the function.
Example:
int main()
{
int a;
.
.
4. Body: Body of a function in C program, refers to the operations that are performed in the functions. It
can be anything like manipulations, searching, sorting, printing, etc.
Example:
int main()
{
int a;

printf("%d", a);
.
.
5. Return Statement: The last part in any C program is the return statement. The return statement refers
to the returning of the values from a function. This return statement and return value depend upon the
return type of the function. For example, if the return type is void, then there will be no return
statement. In any other case, there will be a return statement and the return value will be of the type of
the specified return type.
Example:
1.
1. #include<stdio.h>
2. int main()
3. {
4. int a;
5.
6. printf("%d", a);
7.
8. return 0;
9. }

You might also like