Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming: C language

Similar presentations


Presentation on theme: "Computer Programming: C language"— Presentation transcript:

1 Computer Programming: C language
Subject Teacher: Shamshad Lakho Lecture – 12 & 13

2 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(); }

3 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.

4 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

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: ?:

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

7 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

8 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

9 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.


Download ppt "Computer Programming: C language"

Similar presentations


Ads by Google