+ All Categories
Home > Technology > Introduction to C programming

Introduction to C programming

Date post: 15-Jan-2017
Category:
Upload: rutvik-pensionwar
View: 30 times
Download: 4 times
Share this document with a friend
17
INTRODUCTION TO C PROGRAMMING C language : Is system programming language. Is procedure-oriented programming language. Is also called mid level programming language. was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T(American Telephone & Telegraph), located in U.S.A. was developed to be used in UNIX Operating system.
Transcript

PowerPoint Presentation

INTRODUCTION TO C PROGRAMMINGC language :Is system programming language.Is procedure-oriented programming language.Is also called mid level programming language.was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T(American Telephone & Telegraph), located in U.S.A.was developed to be used in UNIX Operating system.

FEATURESSimpleMachine Independent or PortableMid-level programming languagestructured programming languageRich LibraryMemory ManagementFast SpeedPointersRecursionExtensible

FIRST PROGRAM OF LANGUAGE

PROGRAM :#include#includevoidmain(){printf("HelloWorld");getch();}

OUTPUT :Hello World

DESCRIBING THE PROGRAM#include includes thestandard input outputlibrary functions. The printf() function is defined in stdio.h#include includes theconsole input outputlibrary functions. The getch() function is defined in conio.h filevoid main()Themain() function is the entry point of every programin C language. The void keyword specifies that it returns no valueprintf()The printf() function isused to print dataon the consolegetch()The getch() functionasks for a single character. Until you press any key, it blocks the screen

INPUT OUTPUT FUNCTIONThere are two input output function of c language.printf() is used for output. It prints the given statement to the console.Syntax of printf() is given below:printf(format string,arguments_list);Sample Format strings : %d(integer), %c(character), %s(string), %f(float) etc.

scanf() is used for input. It reads the input data from console.Syntax of scanf() is given below:scanf(format string,argument_list);

DATA TYPES & KEYWORDS4 types of data types

A keyword is areserved word. You cannot use it as a variable name, constant name etc.

OPERATORS

There are following types of operators to perform different types of operations in C language.

Arithmetic OperatorsRelational OperatorsShift OperatorsLogical OperatorsBitwise OperatorsTernary or Conditional OperatorsAssignment OperatorMisc Operator

CONTROL STATEMENTSif-elseIf statementIf-else statementIf else-if ladderNested ifswitchloopsdo-while loopwhile loopfor loopbreak continue

IF-ELSE IN C

SWITCH IN C

switch(expression) {case constant-expression : statement(s); break; /* optional */case constant-expression : statement(s); break; /* optional */ default : /* Optional */ statement(s);}

LOOPS IN CLoops are used to execute a block of code or a part of program of the program several times.Types of loops in C language:-do whileIt is better if you have to execute the code at least oncewhileIt is better if number of iteration is not known by the user.forIt is good if number of iteration is known by the user.

CONTROL STATEMENTS continuedBREAK is used to break the execution of loop (while, do while and for) and switch case.CONTINUE is used to continue the execution of loop (while, do while and for). It is used withif conditionwithin the loop.

FUNCTIONS IN CTo perform any task, we can create function. A function can be called many times. It providesmodularity and codereusability.Advantage of function:-Code ReusabilityCode optimization

CALL BY VALUEIn call by value, value being passed to the function is locally stored by the function parameter in stack memory location. If you change the value of function parameter, it is changed for the current function only. It will not change the value of variable inside the caller method such as main().

Output :

CALL BY REFERENCEIn call by reference,original value is modifiedbecause we pass reference (address).

OUTPUT :

RECURSION IN CA function that calls itself, and doen't perform any task after function call, is know astail recursion. In tail recursion, we generally call the same function with return statement.

ARRAY IN CArrayin C language is acollectionorgroupof elements (data). All the elements of array arehomogeneous(similar). It has contiguous memory location.Declaration of array :data_typearray_name[array_size];Types of array:-1-D Array2-D ArrayAdvantage of array :Code OptimizationEasy to traverse dataEasy to sort dataRandom Access


Recommended