CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
Advertisements

C Programming Course Overview
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Structure of a C program
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
KEAN UNIVERSITY Visual C++ Dr. K. Shahrabi. Developer studio Is a self-contain environment for creating, compiling, linking and testing windows program.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
1 CS 192 Lecture 5 Winter 2003 December 10-11, 2003 Dr. Shafay Shamail.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
 Programming Languages  First Generation Languages (Machine Language)  We Actually have to do a few things. First we have to find the operating code,
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
1 More C++ Basics Chapter 3 Lecture CSIS 10A. 2 Agenda Review  C++ Standard Numeric Types Arithmetic–way more than you want! Character (char) data type.
C++ Programming, Namiq Sultan1 Chapter 2 Introduction to C++ Namiq Sultan University of Duhok Department of Electrical and Computer Engineerin Reference:
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
COMPUTER PROGRAMMING. variable What is variable? a portion of memory to store a determined value. Each variable needs an identifier that distinguishes.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
Gator Engineering 1 Chapter 2 C Fundamentals (Continued) Copyright © 2008 W. W. Norton & Company. All rights reserved.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
2. C FUNDAMENTALS. Example: Printing a Message /* Illustrates comments, strings, and the printf function */ #include int main(void) { printf("To C, or.
Basic Types, Variables, Literals, Constants. What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet)
Introduction to C Programming I Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Variables, Identifiers, Assignments, Input/Output
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Basics (Variables, Assignments, I/O)
Chapter 1.2 Introduction to C++ Programming
Data types Data types Basic types
C Programming Course Overview
LESSON 3 IO, Variables and Operators
Compiler Construction
Computing with C# and the .NET Framework
Introduction to C Programming Language
مبانی کامپیوتر و برنامه سازی
CMSC 104, Section 4 Richard Chang
بسم الله الرحمن الرحيم.
Reserved Words.
Basics (Variables, Assignments, I/O)
null, true, and false are also reserved.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C++ Basics.
פרטים נוספים בסילבוס של הקורס
Introduction to Java Programming
درس برنامه‌سازي کامپيوتر
פרטים נוספים בסילבוס של הקורס
Keywords.
Govt. Polytechnic,Dhangar
Variables, Identifiers, Assignments, Input/Output
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Variables in C Declaring , Naming, and Using Variables.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
Module 2 Variables, Data Types and Arithmetic
Building Blocks of C Programming Language
C Language B. DHIVYA 17PCA140 II MCA.
Presentation transcript:

CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail

C++ Keywords asm dynamic_cast new template auto else operator this bool enum private throw break extern protected true case false public try catch float register typedef char for reinterpret_cast typeid class friend return union const goto short unsigned const_cast if signed using continue inline sizeof virtual default int static void delete long static_cast volatile do mutable struct wchar_t double namespace switch while

Basic Data Types TypeBit WidthRange char8-128 to 127 int to float323.4E-38 to 3.4E+38 double641.7E-308 to 1.7E+308 void-valueless

A number code used by C++ to store characters internally (it’s easy for a computer to store numbers) Each character corresponds to a binary code Most commonly used binary code is ASCII (American Standard Code for Information Interchange) CharacterASCII CodeInteger Equivalent % A a b c Larger character sets e.g. Unicode Exercise: Use char as a small int in a program

Type Modifiers signed unsigned short long

auto private register const protected static extern public virtual friend volatile mutable Access Modifiers

break forwhile case goto continue if default return else switch Control Keywords

CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail

Functions Building blocks of a C++ program Each function has a name, which is used to call the function; functions call each other You will write your own functions, e.g. main(), and also use pre-written functions from standard library

/* This program contains two functions: main() and myfunc(). */ #include void myfunc(); // myfunc's Protoype int main() { cout << "In main()"; myfunc(); // call myfunc() cout << "Back in main()"; return 0; } void myfunc() // myfunc’s Definition { cout << " Inside myfunc() "; }

Function Prototype void myfunc(); // myfunc's Protoype Like variable declaration; tells the compiler about the return type of the function and the number and type of parameters it needs from the calling function: return_type FunctionName (parameter list); So, place prototypes before main() main() is predefined in C++ and does not need a prototype Can’t the compiler look ahead and get definitions? Prototype can be omitted if whole function placed before it is called; is that a good practice?

Returning a Value // Returning a value. #include int mul(int x, int y); // mul()'s prototype int main() { int answer; answer = mul(10, 11); // assign return value cout << "The answer is " << answer; return 0; } // This function returns a value. int mul(int x, int y) { return x * y; // return product of x and y }

Library Functions Pre-written functions in libraries that you can use Just include the proper header file Compiler gets prototype from the header file and searches appropriate libraries itself to get function definition e.g. math library has mathematical functions in it #include #include //or int main() { cout << sqrt(9.0); return 0; }