Computer Programming: C language

Slides:



Advertisements
Similar presentations
Operators and Arithmetic Operations. Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands.
Advertisements

1 C Programming. 2 Operators 3 Operators in C An operator is a symbol that tells the computer to perform certain mathematical or logical manipulation.
Department of Computer Science. Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations.
Types and Arithmetic Operators
1 CSE1301 Computer Programming Lecture 5 C Primitives 2.
Chapter 3 Assignment and Interactive Input. 2 Objectives You should be able to describe: Assignment Operators Mathematical Library Functions Interactive.
Expressions An expression is a sequence of operands and operators that reduces to a single value expression operator operand An operator is a language-specific.
1  Ex: Declare a variable to store user’s age: int age; Prompt the user to enter his/her age: printf (“ How old are you? “); Read / scan the entered value.
Performing Computations C provides operators that can be applied to calculate expressions: example: tax is 8.5% of the total sale expression: tax =
C++ Operators CS242 COMPUTER PROGRAMMING T.Banan Al-Hadlaq.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
Chapter 4: Operators Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills /1436.
Chapter 2 part #4 Operator
2440: 211 Interactive Web Programming Expressions & Operators.
1.2 – Evaluate and Simplify Algebraic Expressions A numerical expression consists of numbers, operations, and grouping symbols. An expression formed by.
CSE1301 Computer Programming Lecture 5: C Primitives 2 Corrections.
CNG 140 C Programming Lecture Notes 2 Processing and Interactive Input Spring 2007.
CHAPTER 2 PART #4 OPERATOR 2 nd semester King Saud University College of Applied studies and Community Service Csc 1101 By: Asma Alosaimi Edited.
CP104 Introduction to Programming Overview of C Lecture 4__ 1 Assignment Statements An assignment statement is to store a value in a variable variable.
CHAPTER 2 COMPONENTS OF A PROGRAMMING LANGUAGE I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
C Operators. CONTENTS C OPERATORS TYPES OF OPERATOR UNARY BINARY TERNARY ARITHMATIC RELATIONAL LOGICAL.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Recap……Last Time [Variables, Data Types and Constants]
Operators & Expressions
Types of Operator Arithmetic operator Relational operator Logical operator Assignment operator Increment or decrement operator(unary) Bitwise operator.
STRUCTURED PROGRAMMING C++ Operators. Content 2  C++ operators  Assignment operators  Arithmetic operators  Increment and decrement operators  Decision.
1 Chapter 3 – Operators and Expressions Outline 3.1Introduction 3.2Arithmetic operators 3.3Relational operators 3.4Logical operators 3.5Assignment operators.
SCP1103 Basic C Programming SEM1 2010/2011 Arithmetic Expressions Week 5.
Principles of Programming - NI July Chapter 4: Basic C Operators In this chapter, you will learn about: Assignment operators Arithmetic operators.
Operators & Expressions
CompSci 230 S Programming Techniques
Arithmetic Expressions
CSE 220 – C Programming Expressions.
Chapter 7: Expressions and Assignment Statements
Lecture 3 Java Operators.
Operators And Expressions
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 3 Assignment and Interactive Input.
INSPIRING CREATIVE AND INNOVATIVE MINDS
Computing Fundamentals
Chapter 2 Assignment and Interactive Input
Relational Operations
Chapter 7: Expressions and Assignment Statements
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Visit for more Learning Resources
11/10/2018.
Operators and Expressions
Arithmetic Operator Operation Example + addition x + y
OPERATORS (1) CSC 111.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Variables Kingdom of Saudi Arabia
With Assignment Operator
CSI 121 Structured Programming Language Lecture 5: C Primitives 2
C Operators, Operands, Expressions & Statements
Chapter-3 Operators.
Associativity and Prescedence
Lecture3.
Alternate Version of STARTING OUT WITH C++ 4th Edition
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Chapter 3 Operators and Expressions
Engineering Problem Solving with C++ An Object Based Approach
Chapter 4: Expression and Operator
Operator and Expression
OPERATORS in C Programming
Operator King Saud University
DATA TYPES There are four basic data types associated with variables:
Course Outcomes of Programming In C (PIC) (17212, C203):
Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a language-specific syntactical token.
OPERATORS in C Programming
Presentation transcript:

Computer Programming: C language Subject Teacher: Shamshad Lakho shamshad.lakho@gmail.com Lecture – 12 & 13

Prompt the user to enter an integer in inverted commas. #include<stdio.h> #include<conio.h> int main() { int a; printf(" \"Enter an integer\" "); scanf("%d",&a); getch(); }

Expressions Expression consists of two things: Operands It specifies an entity on which an operation is to be performed. Operators It specifies the operation to be applied to its operands.

Simple Expression and Compound Expression An Expression has only one operator called Simple expression eg: a+2 An Expression has more than one operator called Compound Expression. eg: b=2+3*5

Operators An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations Classification of Operators: Number of operands on which an operator operates The role of an operator Classification based on Number of operands Unary- it operates on only one operand Eg: &, sizeof operator, !, ~, ++, -- Binary – it operates on two operands eg: *, /, <<, ==,&&, & Ternary- it operates on three operands eg: ?:

Classification based on Role of Operator Arithmetic Operators +, -, *, /, % Relational Operators <, <=, >, >=, ==, != Logical Operators &&, ||, ! Assignment Operators = Increment and Decrement Operators ++,-- Conditional Operators ?= Special Operators ,, sizeof, &, * ., ->

Arithmetic Operators C Operation Algebraic C Addition (+) f + 7 Subtraction (-) p – c Multiplication (*) bm b * m Division (/) x / y Modulus (%) r mod s r % s

Expressions Arithmetic Expressions An expression is a combination of variables constants and operators written according to the syntax of C language. Algebraic Expression C Expression a x b – c a * b – c (m + n) (x + y) (m + n) * (x + y) 3x2 +2x + 1 3*x*x+2*x+1

Assignment Write a C program that read two integers from the keyboard and store the value entered in the variable a & b and display their sum. Write a C program that read an integer value from the keyboard and display its square. Write a C program that read a value of Temperature in Celsius from the keyboard and display its equivalent Temperature in Fahrenheit. Write a C program that read a value of Temperature in Fahrenheit from the keyboard and display its equivalent Temperature in Celcius.