[go: up one dir, main page]

0% found this document useful (0 votes)
3 views5 pages

Unit 1 Notes

C is a general-purpose, procedural programming language that provides low-level access to system memory and is used for various applications such as system administration and embedded software. It is characterized as a middle-level language, offering features of both low-level and high-level languages, and includes a rich set of built-in operators and libraries. The structure of a C program includes documentation, preprocessor directives, definitions, global declarations, the main function, and user-defined functions.

Uploaded by

manjulak.comp
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)
3 views5 pages

Unit 1 Notes

C is a general-purpose, procedural programming language that provides low-level access to system memory and is used for various applications such as system administration and embedded software. It is characterized as a middle-level language, offering features of both low-level and high-level languages, and includes a rich set of built-in operators and libraries. The structure of a C program includes documentation, preprocessor directives, definitions, global declarations, the main function, and user-defined functions.

Uploaded by

manjulak.comp
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
You are on page 1/ 5

C Programming

C PROGRAMMING
UNIT-01
Definition of C
C is a general-purpose, procedural programming language that provides low-level
access to a computer's system memory.

OR

C is a general-purpose computer programming language for system administration,


network programming, and embedded software.

Overview of C
C is a middle level, general purpose, compiler based and Procedure oriented programming
language (POP)

1) Middle level Language: C is considered as a middle-level language because it


supports the feature of both low-level and high-level languages
2) General Purpose: C is a general-purpose computer programming language for system
administration, network programming, and embedded software. It has several features
that make it desirable for these applications: C program syntax is easy to learn and
read; this makes debugging code more accessible and faster
3) Compiler Based: C is called compiled language because it uses a compiler for the
translation of source code to machine code.
4) C is a POP: C is a procedural language that specifies a series of steps for a program to
solve a problem.

Features of C
 Procedural Language
 Fast and Efficient
 Modularity
 Statically Type
 General-Purpose Language
 Rich set of built-in Operators
 Rich Library Set
 Middle-Level Language
 Portability
 Easy to Extend

1) Procedural Language
In a procedural language like C step by step predefined instructions are
carried out. C program may contain more than one function to perform a particular
task. New people to programming will think that this is the only way a particular

Prof. Manjula K ., ASST. PROFESSOR., FCIT., GM UNIVERSITY


C Programming
programming language works. There are other programming paradigms as well in
the programming world. Most of the commonly used paradigm is an object-oriented
programming language.

2) Fast and Efficient


Newer languages like java, python offer more features than c programming
language but due to additional processing in these languages, their performance rate
gets down effectively. C programming language as the been middle-level language
provides programmers access to direct manipulation with the computer hardware but
higher-level languages do not allow this. That’s one of the reasons C languages is
considered the first choice to start learning programming languages. It’s fast because
statically typed languages are faster than dynamically typed languages.

3) Modularity
The concept of storing C programming language code in the form of libraries
for further future uses is known as modularity. This programming language van does
very little on its own most of its power is held by its libraries. C language has its own
library to solve common problems like in this we can use a particular function by
using a header file stored in its library.

4) Statically Type
C programming language is a statically typed language. Meaning the type of
variable is checked at the time of compilation but not at run time. This means each
time a programmer types a program they have to mention the type of variables used.

5) General Purpose Language


From system programming to photo editing software, the C programming
language is used in various applications. Some of the common applications where
it’s used are as follows:
Operating systems: Windows, Linux, iOS, Android, OXS
Databases: PostgreSQL, Oracle, MySQL, MS SQL Server etc.

6) Rich set of built-in Operators


It is a diversified language with a rich set of built-in operators which are used
in writing complex or simplified C programs.

7) Rich Library Set


Robust libraries and functions in C help even a beginner coder to code with
ease.

8) Middle-Level Language
As it is a middle-level language so it has the combined form of both
capabilities of assembly language and features of the high-level language.

9) Portability
C language is lavishly portable as programs that are written in C language
can run and compile on any system with either none or small changes.

10) Easy to Extend


Programs written in C language can be extended means when a program is
already written in it then some more features and operations can be added to it.

Prof. Manjula K ., ASST. PROFESSOR., FCIT., GM UNIVERSITY


C Programming

Structure of C

Documentation section

It includes the statement specified at the beginning of a program, such as a program's


name, date, description, and title.

It is represented as:
//name of a program
Or
/*
Overview of the code
. */

Preprocessor section

The preprocessor section contains all the header files used in a program. It informs the
system to link the header files to the system libraries.

It is given by:

#include<stdio.h>
#include<conio.h>

Prof. Manjula K ., ASST. PROFESSOR., FCIT., GM UNIVERSITY


C Programming

The #include<stdio.h> consists of the contents of the standard input output files, which
contains the definition of stdin.

There are various header files available for different purposes. For example, # include
<math.h>. It is used for mathematic functions in a program.

Definition section

The define section comprises of different constants declared using the define keyword. It is
given by:

#define PI 3.142

Global declaration

The global section comprises of all the global declarations in the program. It is given by:

float num = 2.54;


int a = 5;
char ch ='z';

main function

main() is the first function to be executed by the computer. It is necessary for a code to
include the main(). It is like any other function available in the C library. Parenthesis () are
used for passing parameters (if any) to a function.

The main function is declared as:

main()

We can also use int or main with the main (). The void main() specifies that the
program will not return any value. The int main() specifies that the program can return
integer type data.

int main()

Or

void main()

Main function is further categorized into local declarations, statements, and


expressions.

User defined functions

The user defined functions specified the functions specified as per the requirements of the
user. For example, color(), sum(), division(), etc.

Prof. Manjula K ., ASST. PROFESSOR., FCIT., GM UNIVERSITY


C Programming

Example 1: To find the sum of two numbers given by the user

/* Sum of two numbers */


#include<stdio.h>
int main()
{
int a, b, sum;
printf("Enter two numbers to be added ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("%d + %d = %d", a, b, sum);
return 0;
}

Prof. Manjula K ., ASST. PROFESSOR., FCIT., GM UNIVERSITY

You might also like