chapter_2 - Administrative Issues First project will be due...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Administrative Issues First project will be due on Wednesday, Feb 11. First project will be handed out today. TA office hours will be announced on Monday, Feb 2. Solve the odd numbered problems in the text Practice compiling your C code on a system My email address is [email protected]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UNIX Computing Sessions UNIX systems overview Interoperability with windows UNIX accounts File systems Permissions System commands Wednesday, Feb 4, 2pm – 4pm Thursday, Feb. 5, 10am – 12 noon Friday, Feb. 6, 10am – 12 noon ALL Sessions are scheduled in the Engineering Computing Center (W129)
Background image of page 2
Chapter 2 Introduction to C A First C Program Real World Application: Computing Distances Identifiers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Basic C Program The basic building block in a C program is the function A C program is made up of one or more functions Functions are made up of statements The function is the starting point of every C program The simplest C program is just a single function
Background image of page 4
Basic C Program Main () Function 1() { } Function 2() { } Function 3() { }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/* This is a simple C program */ #include <stdio.h> main() { printf( “Welcome to our first C program! \n”); } The output is: Welcome to our first C program! A First C Program
Background image of page 6
/* This is a simple C program */ #include <stdio.h> main() { printf( “Hello World! \n”); printf( “This is interesting! \n”); } The output is: ???? A First C Program
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Things to remember /* beginning of a comment */ end of a comment #include <stdio.h> preprocessor main() a must, exe begins here {…} enclose a group of statements printf(“…\n”) copies to video display \n escape character: new line ; terminates a statement
Background image of page 8
More things to remember Every C program contains a function called main. This is the start point of the program. #include <stdio.h> allows the program to interact with the screen, keyboard and file system of your computer. You will find it at the beginning of almost every C program. main() declares the start of the function, while the two curly brackets show the start and finish of the function.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A Simple Computation Code DISTANCE = RATE * TIME The inputs are RATE and TIME. The output is DISTANCE. NOTE: DISTANCE, RATE, and TIME are ALL INTEGERS (int data type)
Background image of page 10
A Simple Computation Code Given rate (speed)=14 km/h (CONSTANT) Inputs time in hours Outputs distance traveled in km The output looks like: Enter next time: 2 Time = 2 hours Distance = 28 kilometers Enter next time: 0 *** End of Program ***
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#include <stdio.h> /*Note: this line should appear if we use scanf() and printf ( ) function */ main() { int distance, rate, time; rate = 14; printf( “Enter next time: “ ); scanf( “%d”, &time); /* Note : %d denotes integer. ampersand (& ) is required before each (non pointer) variable in scanf */ while ( time > 0 ) { distance = rate * time; printf( “Time = %d hours\n”, time); printf( “Distance = %d kilometers\n\n”, distance);
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2011 for the course ECE 3331 taught by Professor Staff during the Fall '08 term at University of Houston.

Page1 / 58

chapter_2 - Administrative Issues First project will be due...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online