1 Lab 1. C Introduction  C: –Developed by Bell lab. in 1972. –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

SPIM and MIPS programming
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Introduction to basic programming Kai Zang Jul 2 nd, 2012.
Lecture 2 Introduction to C Programming
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Introduction Kingdom of Saudi Arabia Shaqra University
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect M1 P. 1Winter Quarter Midterm I Review Topics.
Guide To UNIX Using Linux Third Edition
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
Arrays.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 21P. 1Winter Quarter MATLAB: Structures.
COMPUTER SCIENCE I C++ INTRODUCTION
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
Arrays One-Dimensional initialize & display Arrays as Arguments Part I.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
ECE 264 Object-Oriented Software Development Instructor: Dr. Michael Geiger Spring 2009 Lecture 2: Basic C++ Programs.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
M.T.Stanhope Oct Title : C++ Basics Bolton Institute - Faculty of Technology (Engineering) 1 C++ Basics u Data types. u Variables and Constants.
Week 1 Algorithmization and Programming Languages.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
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.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Introduction to Programming Lecture 11. ARRAYS They are special kind of data type They are special kind of data type They are like data structures in.
Introduction to C Programming Lecture 6. Functions – Call by value – Call by reference Arrays Today's Lecture Includes.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
C is a high level language (HLL)
Array and Pointers An Introduction Unit Unit Introduction This unit covers the usage of pointers and arrays in C++
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
Computer science C programming language lecture 1.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
CS 1428 Final Exam Review. Exam Format 200 Total Points – 60 Points Writing Programs – 45 Points Tracing Algorithms and determining results – 20 Points.
Lecture2.
Chapter 1.2 Introduction to C++ Programming
Engineering Problem Solving With C An Object Based Approach
Chapter 1: Introduction to computers and C++ Programming
Chapter 1.2 Introduction to C++ Programming
Beginning C++ Programming
CS 1428 Exam I Review.
C Basics.
Visit for more Learning Resources
CS 2308 Exam I Review.
CS 1428 Final Exam Review.
CS 1428 Final Exam Review.
Programs written in C and C++ can run on many different computers
Course Outcomes of Programming In C (PIC) (17212, C203):
CS 1428 Exam I Review.
Presentation transcript:

1 Lab 1. C Introduction  C: –Developed by Bell lab. in –a procedure-oriented programming language.  Developing environments: –Editing –Preprocessing (header files) –Compile (.obj) –Link (.exe) –load –Execution  Include: –Head files used in the main file. #include

2  Variable and constant: –Must be declared before use –e.g. int i=3; float f=15.7; double x. –const int max=100;  Data type transfer: –Assignment: x=1; –Mathematic operations: y=i/5+2/3; –Model transfer: i=(int)(x+0.5); –Function call: x=sum(a,b);  Basic input/output commands: printf(“\t xxxx %vf1 xxx %vf2 xxx \n”, var1, var2); scanf(“\t %vf1 %vf2 ”, &var1, &var2); Variable format Address

3  Output format:  Mathematic operators: –Similar to those in Matlab %: Remainder

4  Others: –int i=3; –int a;  If/else: If (condition) { statements; } elseif (condition) { statements; } else { } If (condition) { statements; } else { statements; }

5  Practice 1: –Input three numbers from the keyboard. –Calculate the maximum, the minimum, and the average values. –Print the result on the screen.  For loops: for (initial setting; terminate conditions; index operations) { statements }

6  Array:  Function: –Call by value –Call by reference Elements of the array Array name Function name Return value

7  Define (preprocessor): –Increase readability –Increase the flexibility for paramter changes –Replace simple function

8  Practice 2: –Input two sequences from the keyboard. –Calculate the convolution of the sequences. –Print the result on the screen.  File operations (read): FILE * fp; //declare file pointer fp = fopen(“filename.dat","rb"); // rb: read for bits for (i=0 ; i<512 ; i++) { fread(&temp,1,4,fp); // 1: one byte, 4: 4x1 bytes at a time x[i] = temp; // store the read value into an array } * int/float: use 4 bytes to store one value FILE * fp; fp = fopen(“filename.dat","rb"); fread(x,4,sizeof(x),fp); Or,

9  File operation (write):  File operations in Matlab: FILE * fp1; //declare file pointer fp = fopen(“filename.dat",“wb"); // wb: write for bits fwrite(x,4,sizeof(x),fp1); // 4: 4 bytes a unit r = randint(1,n); s = r > 0.5; fid = fopen(‘filename.dat','wb'); fwrite(fid, s,'ubit1'); % ubit1: unsigned bit fclose(fid); % float/int32 fid2 = fopen(‘filename.dat','rb','n'); Buffer = fread(fid2,n,'ubit1'); fclose(fid2);

10  Practice 3: –Store the values of inputted two sequences in two files. –Read the values from the files. –Calculate the convolution of the sequences. –Store the result into another file.  Homework –Find out how to create a function with sequence input and sequence output. –Rewrite the convolution operations with a function. –Generate two sequences with Matlab and store them in the two files. –Use C to read the files and conduct convolution operations. –Store the result to another file and use Matlab to read it.