1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
CSE Spring 2015 INTERMEDIATE PROGRAMMING
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
COSC 120 Computer Programming
Introduction to C Programming CE Lecture 1 Introduction to C.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Programming The Development Environment and Your First C Program.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Ceng 230 Programming with C
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
H.Melikian Introduction on C C is a high-level programming language that forms the basis to other programming languages such as C++, Perl and Java. It.
Programming With C.
Introduction to Computer Systems and the Java Programming Language.
EPSII 59:006 Spring Introduction to C More Administrative Details The C Programming Language How a computer processes programs Your first C program.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
1 C++ Programming Basics Chapter 1 Lecture CSIS 10A.
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
INC 161 , CPE 100 Computer Programming
Introduction to C Topics Compilation Using the gcc Compiler
BASIC PROGRAMMING C SCP1103 (02)
Engineering Problem Solving With C An Object Based Approach
CSC201: Computer Programming
BASIC PROGRAMMING C SCP1103 (02)
Chapter 2 - Introduction to C Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Beginning C++ Programming
Java programming lecture one
The Development Environment and Your First C Program
Chapter 2 - Introduction to C Programming
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to CS Your First C Programs
Chapter 2 - Introduction to C Programming
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Chapter 2 - Introduction to C Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
Programs written in C and C++ can run on many different computers
Chapter 2 - Introduction to C Programming
Introduction to C Programming
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables

2 Administration Teaching assistant: Assaf Zaritsky Course’s home page: Office hours: Tuesdays, 15:10-16:10, Shenkar-Physics Building, room 406, or scheduled via /phone Office phone:

3 Grades Assignments: 20% Exam: 80%

4 Web Site Contact information Announcements All relevant material (homework, solutions, code examples, slides, etc…)

5 Homework Weekly homework assignments Programming assignment Each assignment is due in one week 20% of final grade Computer lab 06, open: 8:00 – 20:00, use /disk-on-key See submission guidelines for detailssubmission guidelines

6 Submission Guidelines Submission in singles! Hard-copy submission during practice or to my mail box (252) in the Schreiber building (second floor, in front of the elevator) Include example execution output Do not forget your ID Extensions Should work on Microsoft Dev Studio Pay careful attention to the guidelines

7 Agenda Administration Background Our first C program Working environment Memory and Variables

8 Basic Computer Model CPU (central processing unit) Input Output Memory Mouse, keyboard, hard disk… Printer, screen, hard disk…

9 Computer Program A sequence of processor instructions designed to achieve a specific purpose The instructions are executed sequentially. No instruction is executed before the previous has been completed

10 Machine Language Computers understand only machine language Basically looks like a sequence of 1’s and 0’s. Very inconvenient to work with and non intuitive. All other computer languages were created for human convenience The computer does not understand C Must be “translated” into machine language

11 Computer Languages Assembly – machine language with some text codes (still inconvenient). Compiled languages – C, Pascal, Fortran. The program is translated into machine language before execution

12 C is a Procedural Language It enables the user to create new instructions (procedures) from existing ones. Instead of re-writing the same code over and over again, write it once and call it when needed.

13 How do we compile? A special program – the “compiler” – “translates” from computer language to machine language There are many compilers on the market We will work with Microsoft Visual C++ 6.0

14 The Whole Process Write a program Your favorite text editor Compile + link the program C compiler will do one of two things: print error messages and abort (most probably…) produce an executable program Run the program

15 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables

16 C Program Template #include int main() { // Program’s “body” return 0; }

17 This is a comment – starts with a /* and ends with a */. Comments are used to explain the program to a human reader, and are ignored by the compiler. Curly braces indicate the beginning and end of a block of instructions. Specifically in this case – a function. This is an instruction to the compiler to insert the contents of the file stdio.h to the program prior to compilation. This file contains information about the printf fuction. Yet another C statement. This one terminates the program and informs the operating system that it has ended successfully. This tells the compiler we are about to define a function named main. main is a special function – it is where the program starts running. This is a C statement. This statement calls a function called printf, which causes text to be printed on the screen. Note that all C statements end with a semicolon (;). Our first C Program /* HelloWorld – An example program */ #include int main() { printf(“Hello, world!\n”); return 0; }

18 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables

19 Using Microsoft Visual c++

20 (Free) Visual Studio Express Free work environment Can be used from home Download and usage details can be found herehere

21 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables

22 Exercise Write, compile and run a program that prints your first name in one line, and your second name in another

23 A name printing program /* This program prints my name on the screen in two lines. */ #include int main() { printf(“Assaf\nZaritsky\n”); return 0; }

24 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables

25 Memory

26 Memory (Cont.) The computer memory is composed of a long list of bits Bits are grouped into bytes and words Every byte is numbered sequentially This number is called an address

27 What are variables? A named area in the computer memory, intended to contain values of a certain kind (integers, real numbers, etc.) Contain the data your program works with Can be used to store data to be used elsewhere in the program In short – they are the only way to manipulate data

28 Declaring Variables int num; int num1, num2; num = -1; // assignment int x = 9; // declaration + assignment int y = x + num; // y equals 8

29 Declaring Variables in C Before using a variable, one must declare it The declaration first introduces the variable type, then its name When a variable is declared, its value is undefined