Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
262Activity

Table Of Contents

0 of .
Results for:
No results containing your search query
P. 1
C Programming

C Programming

Ratings:

5.0

(2)
|Views: 1,051 |Likes:
Published by sunil_tiwary07

More info:

Published by: sunil_tiwary07 on May 15, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/03/2013

pdf

text

original

 
Introduction to
C Programming
Rob MilesDepartment of Computer Science
 
i
Contents
Computers 1
An Introduction to Computers........................................................................................1Hardware and Software....................................................................................1Data and Information.......................................................................................2Data Processing................................................................................................2
Programming Languages 4
What is Programming?..................................................................................................4From Problem to Program................................................................................5Programming Languages...............................................................................................8
C 8
A look at C....................................................................................................................8Making C Run..................................................................................................9Creating C Programs........................................................................................9What Comprises a C Program?.......................................................................10The Advantages of C......................................................................................11The Disadvantages of C..................................................................................11
A First C Program 11
The Program Example.................................................................................................11
#include
........................................................................................................12
<stdio.h>
.......................................................................................................12
void
...............................................................................................................12
main
..............................................................................................................13
( void )
...........................................................................................................13
{
.....................................................................................................................13
float
...............................................................................................................13
height, width, area, wood_length
................................................................13
;
.....................................................................................................................14
scanf
.............................................................................................................14
(
.....................................................................................................................14
"%f",
..............................................................................................................14
&height
..........................................................................................................15
) ;
...................................................................................................................15
scanf ( "%f", &width ) ;
.................................................................................15
area = 2 * height * width ;
............................................................................15wood_length = 2 * ( height + width ) * 3.25 ;.................................................16
printf
..............................................................................................................16
( "The area of glass needed is : %f metres.\n",
.........................................16
area ) ;
..........................................................................................................17
printf ( "The length of wood needed is : %f feet.\n", wood_length ) ;
......17
}
.....................................................................................................................17Punctuation....................................................................................................17
Variables 18
 
ii
Variables and Data.........................................................................................18Types of Variables.......................................................................................................18Declaration..................................................................................................................18
int
variables....................................................................................................19
float
variables................................................................................................19
char
variables................................................................................................19Missing Types................................................................................................19Variable Declaration....................................................................................................19Giving Values to Variables..........................................................................................20Expressions....................................................................................................21Types of Data in Expressions..........................................................................22Getting Values into the Program..................................................................................23
Writing a Program 24
Comments......................................................................................................24Program Flow..............................................................................................................24Conditional Execution -
if
...............................................................................25Conditions and Relational Operators..............................................................26Combining Logical Operators.........................................................................27Lumping Code Together.................................................................................27Magic Numbers and
#define
..........................................................................28Loops.............................................................................................................29Breaking Out of Loops...................................................................................32Going Back to the Top of a Loop....................................................................32More Complicated Decisions..........................................................................33Complete Glazing Program............................................................................33Operator Shorthand........................................................................................34Statements and Values....................................................................................35Neater Printing...............................................................................................36
Functions 37
Functions So Far..........................................................................................................37Function Heading...........................................................................................37Function Body................................................................................................38return.............................................................................................................38Calling a Function..........................................................................................38Scope.............................................................................................................39Variables Local to Blocks...............................................................................40Full Functions Example..................................................................................40Pointers........................................................................................................................42NULL Pointers...............................................................................................44Pointers and Functions...................................................................................44Static Variables............................................................................................................45
Arrays 46
Why We Need Arrays..................................................................................................46Sorting...........................................................................................................47Array Types and Sizes..................................................................................................49More Than One Dimension............................................................................50
Switching 53
Making Multiple Decisions..........................................................................................53
Strings 55

Activity (262)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
vimallouis liked this
Anupam Gurung liked this
ahmadmakki liked this
pankajsuwalka4u liked this
ahmadmakki liked this
Venkat Reddy liked this
manoj liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->