[go: up one dir, main page]

0% found this document useful (0 votes)
30 views62 pages

Unit 1 INTRODUCTION

Computer programming 1 unit 1 engeneering

Uploaded by

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

Unit 1 INTRODUCTION

Computer programming 1 unit 1 engeneering

Uploaded by

beehyber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Computer

Programming-I
Unit-I
Introducton
By
Mr. Harshal S. Hemane
Assistant Professor,
Department of Electronics & Communication Engineering,
Bharati Vidyapeeth
(Deemed to be University)
College of Engineering, Pune
Computer Programming
Computer programming is the process of writing code to
facilitate specific actions in a computer, application or software
program, and instructs them on how to perform.
Basic Type of Programming Language
C Language
The C language is a basic programming language and it is a very popular
language, particularly used in embedded system ,game programming,
Because C language includes the additional packing of the C++, Every
programmer uses this language because it makes programs faster .
However the value of this language gives the reusability of C++ to get the
slight increase in performance with C language
Why to Learn C Programming?

• C programming language is a MUST for students and


working professionals to become a great Software
Engineer specially when they are working in Software
Development Domain. I will list down some of the key
advantages of learning C Programming:
• Easy to learn
• Structured language
• It produces efficient programs
• It can handle low-level activities
• It can be compiled on a variety of computer platforms
Facts about C

• C was invented to write an operating system called


UNIX.
• C is a successor of B language which was introduced
around the early 1970s.
• The language was formalized in 1988 by the American
National Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System
Programming Language.
• Most of the state-of-the-art software have been
implemented using C
comparison

C Vs C++ Vs Java
APPLICATION OF C
“Structure of C Program”
Program has six section The six sections are
1. Documentation
2.Link
3. Definition
4. Global Declarations
5.Main functions
6. Subprograms
1.Documentation Section
the Documentation Section consists of a set of
comment lines giving the name of the
Programmer, date, and other details about the
program. The documentation section helps
anyone to get an overview of the program.
example
/*
* File Name: Helloworld.c
* Author: ABC(name of programmer)
* date: 25/11/2020
* description: a program to display hello world
* no input needed
*/
IMP
Single line comments

//sum of two numbers

Multi-line comments

/* Comment*/
2. Link Section

• The Link section provides instructions to the compiler to


link functions from the system library such as using the
#include directive.
• This part of the code is used to declare all the header files
that will be used in the program. This leads to the compiler
being told to link the header files to the system libraries.
Some Examples
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
3. Definition

All the symbolic constants are written in the


definition section by using the #define
directive.
Examples
#define PI=3.14
#define
4. Global Declarations
• Global Declaration Section contains the global
declaration of user-defined functions and
Variables. There are some variables that are
used in more than one function. Such
variables are called Global Variables and are
declared in the global declaration section that
is outside of all the functions
5.Main Sections
• Every C-programs needs to have the main
function. Each main function contains 2 parts.
A declaration part and an Execution part. The
declaration part is the part where all the
variables are declared. The execution part
begins with the curly brackets and ends with
the curly close bracket. Both the declaration
and execution part are inside the curly brace
6. Subprogram Section
The subprogram section contains all the user-
defined functions that are used to perform a
specific task. These user-defined functions are
called in the main function. User-defined
functions are generally placed just after the
main() function, although they may appear in
any order
Identifiers,
Identifiers are names for entities in a C program,
such as variables, arrays, functions, structures,
unions and labels. An identifier can be composed
only of uppercase, lowercase letters, underscore
and digits, but should start only with an alphabet
or an underscore. If the identifier is not used in
an external link process, then it is called as
internal. Example: Local variable. If the identifier
is used in an external link process, then it is called
as external. Example: Global variable
Rules for constructing identifiers
• 1. The first character in an identifier must be an
alphabet or an underscore and can be followed only by
any number alphabets, or digits or underscores.
2. They must not begin with a digit.
3. Uppercase and lowercase letters are distinct. That
is, identifiers are case sensitive.
4. Commas or blank spaces are not allowed within an
identifier.
5. Keywords cannot be used as an identifier.
6. Identifiers should not be of length more than 31
characters.
7. Identifiers must be meaningful, short, quickly and
easily typed and easily read
Valid
identifiers: total sum average _x
y_ mark_1 x1

Invalid identifiers
1x - begins with a digit
char - reserved word
x+y - special character
Differentiate between Keywords
words and identifiers
What are Data types in C
Programming?
In C programming, data types are just the same
what their name suggests. They represent the
kind of data to store. They are used to declare
several functions as well as variables in a
program
C – Constant

• C Constants are also like normal variables. But,


only difference is, their values can not be
modified by the program once they are
defined. Constants refer to fixed values. They
are also called as literals. Constants may be
belonging to any of the data type.
Variable in C

• C variable is a named location in a memory


where a program can manipulate the data.
This location is used to hold the value of the
variable.
• The value of the C variable may get change in
the program.
• C variable might be belonging to any of the
data type like int, float, char etc.
Rules for naming C variable:

• Variable name must begin with letter or


underscore.
• Variables are case sensitive
• They can be constructed with digits, letters.
• No special symbols are allowed other than
underscore.
• average, height, age, total are some examples
for variable name
Operators in C

Operators are the foundation of any


programming language. Thus the functionality
of C programming language is incomplete
without the use of operators. We can define
operators as symbols that help us to perform
specific mathematical and logical
computations on operands. In other words,
we can say that an operator operates the
operands
1.Arithmetic Operators
An arithmetic operator performs mathematical
operations such as addition, subtraction,
multiplication, division etc on numerical
values
• Output
• a+b = 13
• a-b = 5
• a*b = 36
• a/b = 2 Remainder when a divided by b=1
Bitwise Operator in C

• The bitwise operators are the operators used


to perform the operations on the data at the
bit-level. When we perform the bitwise
operations, then it is also known as bit-level
programming.
• It consists of two digits, either 0 or 1. It is
mainly used in numerical computations to
make the calculations faster.
Relational Operators

• These Operators are used to check the


relationship between the two operands. If the
relation is true, it returns 1; if the relation is
false, it returns value 0. Relational operators
are used in decision making and loops.
3.logical operators
• A logical operator is a symbol or word used to
connect two or more expressions such that
the value of the compound expression
produced depends only on that of the original
expressions and on the meaning of the
operator. Common logical operators include
AND, OR, and NOT.
&& (LOGICAL AND Operator)
Assignment Operators

• Assignment operators are used when the


value is to be assigned to an identifier, a
variable. With execution of assignment
operators, value at the right is assigned to the
left. The destination variable loses the old
value; i.e. old value is over ridden with the
new value. If previous value is also required; it
should be saved in some other variables.
SAMPLE PROGRAMS
Thank You

You might also like