computer programming and utilization 2110003

17
Subject: Computer Programming & Utilization Subject code: 2110003 Om Institute of Technology 1

Upload: juhi-shah

Post on 16-Jan-2017

115 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Computer programming and utilization 2110003

Subject: Computer Programming

& Utilization

Subject code: 2110003

Om Institute of Technology 1

Page 2: Computer programming and utilization 2110003

PRESENTATION ON:

Fundamental of ‘C’

Presented by:Shah Juhi

Om Institute of Technology 2

Page 3: Computer programming and utilization 2110003

TopicsHistory of ‘c’Features of ‘c’Structure of programHeader filesMain functionData typeConstantVariablesOperatorsInput/outputC preprocessor

Om Institute of Technology 3

Page 4: Computer programming and utilization 2110003

Om Institute of Technology 4

C is developed by Dennis Ritchie C is a structured programming language C supports functions that enables easy

maintainability of code, by breaking large file into smaller modules

Comments in C provides easy readability C is a powerful language

History of ‘C’

Page 5: Computer programming and utilization 2110003

Om Institute of Technology 5

Important feature of ‘C’ language is it is portable, by portability we mean that the program can be run on any hardware machine.

It supports modular programming. It supports bit-wise operations. It is known as structured programming language.

Features of ‘C’

Page 6: Computer programming and utilization 2110003

Om Institute of Technology 6

Documentation Section         //optional Link section                          //optional Defining section                    //optional Global declaration section     //optional Main function section                     //Must {                    Declaration part                     Executable part. } Sub program section                      //optional              Function 1              Function 2              .              .              Function n

STRUCTURE OF PROGRAM

Page 7: Computer programming and utilization 2110003

Om Institute of Technology 7

The files that are specified in the include section is called as header file

These are precompiled files that has some functions defined in them

We can call those functions in our program by supplying parameters

Header file is given an extension .h C Source file is given an extension .c

Header files

Page 8: Computer programming and utilization 2110003

Om Institute of Technology 8

This is the entry point of a program When a file is executed, the start point is the

main function From main function the flow goes as per the

programmers choice. There may or may not be other functions written

by user in a program Main function is compulsory for any c program

Main function

Page 9: Computer programming and utilization 2110003

Om Institute of Technology 9

A data type in a programming language is a set of data values having predefine characteristics.

there are three classes of data types: Data Type

Primitive derived user define

WHAT IS DATA TYPE ?

Page 10: Computer programming and utilization 2110003

Om Institute of Technology 10

Primitive data typesint, float, double, char

Aggregate data typesArrays come under this categoryArrays can contain collection of int or float

or char or double data User defined data types

Structures and enum fall under this category.

Data types in ‘C’

Page 11: Computer programming and utilization 2110003

Om Institute of Technology 11

The ‘C’ language supports following types of constants:Numeric constants (5, 15, 3.6, -5.4 etc)Non-numeric constants

Character constants (‘B’ , ‘a’ , ‘?’ , ‘5’ , ‘+’ etc)

String Constants (“Computer”, “XYZ”, “-5.4” etc)

Constants

Page 12: Computer programming and utilization 2110003

Om Institute of Technology 12

\a Bell \b Back space \f Form feed \n New line \r Carriage return \t Horizontal tab \v vertical tab \’ single quote \” Double quote \? Question Mark \\ Backslash \0 Null

Character constant

Page 13: Computer programming and utilization 2110003

Om Institute of Technology 13

Variables are the identifiers whose value changes as opposite to constants.

As variable is an identifier, all the rules for naming an identifier applies to variables also.

Should not be a reserved word like int etc.. Should start with a letter or an underscore(_) Can contain letters, numbers or underscore. No other special characters are allowed

including space Variable names are case sensitive

A and a are different.

Variables

Variable names- Rules

Page 14: Computer programming and utilization 2110003

Om Institute of Technology 14

Arithmetic (+,-,*,/,%) Relational (<,>,<=,>=,==,!=) Logical (&&,||,!) Bitwise (&,|) Assignment (=) Compound assignment(+=,*=,-=,/=,%=,&=,|

=) Shift (right shift >>, left shift <<)

OPERATORS

Page 15: Computer programming and utilization 2110003

Om Institute of Technology 15

Inputscanf(“%d”,&a);Gets an integer value from the user and

stores it under the name “a” Output

printf(“%d”,a);Prints the value present in variable a on the

screen

Input and Output

Page 16: Computer programming and utilization 2110003

Om Institute of Technology 16

All preprocessor directives begin with # Possible actions

Inclusion of other filesDefinition of symbolic constants & macrosConditional compilation of program codeConditional compilation of preprocessor

directives

C Preprocessor

Page 17: Computer programming and utilization 2110003

Than

k yo

u

Om Institute of Technology 17