intro to cprogramming

17
INTRODUCTION TO C PROGRAMMING

Upload: skashwin98

Post on 08-Feb-2017

152 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Intro to cprogramming

INTRODUCTION TO C PROGRAMMING

Page 2: Intro to cprogramming

HISTORY OF C LANGUAGE

LATE 60’s:MIT,GE and Bell labs partnered to build MULTICS create “B” Language

EARLY 70’s:From The “B” Language, Dennis Ritchie developed “C”

Later Dennis Ritchie and Brian Kernighan to-gether published “The white book”

Page 3: Intro to cprogramming

Middle Level Language ?

. C Programming bridges gap between traditional  Machine Understandable Machine Level language and more conventional High level languages. User can Use C Language to do system pro-gramming for writing operating system as well as application programming.

Page 4: Intro to cprogramming
Page 5: Intro to cprogramming

Why “C”?

Easy to learn Structured language It produces efficient programs. It can handle low-level activities. It can be compiled on a variety of computers.

Page 6: Intro to cprogramming

Facts about C

C was invented to write an operating system called UNIX. C is a successor of B language which was introduced around

1970 The language was formalized in 1988 by the American Na-

tional Standard Institute (ANSI). By 1973 UNIX OS almost totally written in C. Today C is the most widely used System Programming Lan-

guage. Most of the state of the art software have been imple-

mented using C Ex:Google Chrome

Page 7: Intro to cprogramming

Basic elements Of C Program

Preprocessor Commands Functions Variables Statements & Expressions Comments

Page 8: Intro to cprogramming

Let us look at a simple program that would print "Hello World"

Page 9: Intro to cprogramming

HELLO WORLD

#include <stdio.h> int main() { /* My first program */ printf("Hello, World! \n"); return 0; }

Page 10: Intro to cprogramming

#include <stdio.h>Preprocessor Commands

 These commands tells the compiler to do preprocessing before doing actual compi-lation. Like #include <stdio.h> is a pre-processor command which tells a C compiler to include stdio.h file before go-ing to actual compilation.

Page 11: Intro to cprogramming

intmain()Functions

Functions are main building blocks of any C Pro-gram. Every C Program will have one or more functions and there is one mandatory function which is called main() function. This function is prefixed with keyword int  which means this func-tion returns an integer value when it exits. This integer value is returned using return statement

Page 12: Intro to cprogramming

printfBuilt in Functions

The C Programming language provides a set of built-in functions. In the above example printf() Is a C built-in function which is used to print anything on the screen.Other built in Functions: scanf char *strcpy void* memcpy

Page 13: Intro to cprogramming

VariablesThey are used to hold numbers, strings and complex data for manipulation

A variable is just a named area of storage that can hold a single value (numeric or character). The C language demands that you declare the name of each variable that you are going to use and its type, or class, before you actually try to do anything with it.

The Programming language C has two main variable types Local Variables Global Variables

Page 14: Intro to cprogramming

Comments/*My First program */ 

 They are used to give additional useful information inside a C Program. All the comments will be put inside /*...*/ as given in the example above. A comment can span through multiple lines.

Page 15: Intro to cprogramming

CautionThere are certain Rules

C is a case sensitive programming language. It means in C  printf  and Printf  will have different meanings C has a free-form line structure. End of each C statement

must be marked with a semicolon. White Spaces (ie.. tab space and space bar ) are ignored.

Page 16: Intro to cprogramming

THE END

Page 17: Intro to cprogramming

Slideshare.net Profile : skashwin98