Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main.

Slides:



Advertisements
Similar presentations
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Characters and Strings.
Advertisements

Expressions ► An expression can be a single variable, or can include a series of variables. If an expression includes multiple variables they are combined.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Expressions and Operators Program Style.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Data types and variables
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
JavaScript, Fourth Edition
Chapter 2 Data Types, Declarations, and Displays
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
1 Lecture 3  Lexical elements  Some operators:  /, %, =, +=, ++, --  precedence and associativity  #define  Readings: Chapter 2 Section 1 to 10.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Sales person receive RM200/week plus 9% of their gross sales for that week. Write an algorithms to calculate the sales person’s earning from the input.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
CNG 140 C Programming Lecture Notes 2 Processing and Interactive Input Spring 2007.
Chapter 2: Using Data.
C++ Programming: Basic Elements of C++.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
By Mr. Muhammad Pervez Akhtar
Module B - Computation1/61 Module-B-Computation Variables Basic Memory Operations Expressions.
C++ for Engineers and Scientists Second Edition
S CCS 200: I NTRODUCTION AND G ETTING S TART IN C P ROGRAMMING Lect. Napat Amphaiphan.
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Random Functions Selection Structure Comparison Operators Logical Operator
ECE Application Programming
Chap. 2. Types, Operators, and Expressions
INSPIRING CREATIVE AND INNOVATIVE MINDS
Computing Fundamentals
Tokens in C Keywords Identifiers Constants
Chapter 2: Problem Solving Using C++
INC 161 , CPE 100 Computer Programming
Java Programming: From Problem Analysis to Program Design, 4e
By: Syed Shahrukh Haider
Introduction to C Programming
Operators and Expressions
Basics of ‘C’.
Chapter 2: Basic Elements of Java
Introduction to C Programming
Lectures on Numerical Methods
Introduction to C Programming
DATA TYPES There are four basic data types associated with variables:
Introduction to C Programming
Presentation transcript:

Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main function –Functions consists of heading, arguments and compound statement –Every block begin with { and end with } –Every statement end with ; –// is used to insert single line comment

–/* … */ is used to insert multiple line C Fundamentals –Character set –Identifiers and keyword –Basic data types Int Character Float Double –Qualifiers

C Fundamentals (contd.) –Constants Integer constant –Decimal –Octal (start with 0) –Hexadecimal (start with 0x or 0X) Unsigned and Long Integer constant (UL) Floating point constant –Numerical accuracy (representation of 1.0) Character constant (enclosed by apostrophes) –ASCII, EBCDIC –Escape sequences (non-printing characters) String constant (enclosed in quotation marks)

C Fundamentals (contd.) Variables Declarations Expressions-+* Statements Symbolic constants #define name text

Operators and expressions Arithmetic operators (+, -, *, /, %) % requires integer operands and second operand must be nonzero Second operand of / must be nonzero Rules of division Type conversion ( (data type)) expression) Precedence and associativity

Operators and expressions (Contd.) Unary operators Relational operators (,>=) Equality Operators (==,!=) Logical operators or connectives(&&,||) –Act upon operands that are themselves logical expressions. The net effect is to combine the individual logical expressions into more complex conditions that are either true or false

Operators and expressions (Contd) –Any nonzero value, not just 1, is interpreted as true. –Logical and has higher precedence than logical or Logical negation operator(!, a unary) Assignment operators Conditional operators Library functions (abs, ceil, cos, floor, pow,

Operators and expressions (Contd) Rand, sqrt, tolower, toupper )

Data Input and Output Getchar(), putchar() Scanf(),scanf(“%[…]”),scanf(“%3d”), 3 is maximum field width Long decimal=%ld, long float or double=%lf Assignment suppression, “%*d” Scanf(“%c%1s%1s”,&c1,&c2,&c3) or scanf(“%c %c %c”)

Data Input and Output Scanf(“%d a %f”) Printf(), printf(“%3d”), 3 is minmum field width Printf(“%7.3f %.1f”) Printf(“%-7.0f %+7.0f%-+7.0f”)