Lecture 1
Lecture 1
1.1 Introduction
1. Keywords
2. Identifiers
3. Variables
4. Constants
5. Special Symbols
6. Character & String
7. Operators
1.3.1 Keywords كلية تكنولوجيا الصناعة والطاقة
✓
arena, s_count
marks40
class_one
1.3.3 Variables
Fundamental Data
Types
كلية تكنولوجيا الصناعة والطاقة
Outputs
كلية تكنولوجيا الصناعة والطاقة
Typical C
Program
Development
Environment
C systems
generally consist
of several parts
كلية تكنولوجيا الصناعة والطاقة
Outputs
كلية تكنولوجيا الصناعة والطاقة
Outputs
Simple input and output statements كلية تكنولوجيا الصناعة والطاقة
كلية تكنولوجيا الصناعة والطاقة
1.3.7. Operators
• Operator is a symbol that operates on one or more operands and
produces output.
Example - z=x+y;
• In the above Example the symbols + and = are operators that operate
on operands x, y , and z .
كلية تكنولوجيا الصناعة والطاقة
1.3.7. Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions. C language is rich in built-in operators
and provides the
• following types of operators:
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Misc Operators
• We will, in this chapter, look into the way each operator works.
Arithmetic Operators: كلية تكنولوجيا الصناعة والطاقة
Precedence of arithmetic operators.
كلية تكنولوجيا الصناعة والطاقة
Outputs
Arithmetic Operators: Example كلية تكنولوجيا الصناعة والطاقة
outputs
كلية تكنولوجيا الصناعة والطاقة
Suppose variables a, b, c
and x in the preceding
second-degree
polynomial are
initialized as follows:
a=2, b=3, c=7 and x=5
Evaluate
Relational Operators كلية تكنولوجيا الصناعة والطاقة
The following table shows all the relational operators supported
by C. Assume variable A holds 10 and variable B holds 20, then:
Logical Operators كلية تكنولوجيا الصناعة والطاقة
Save F2 abc.c
Compile Alt + F9 abc.obj
\n new line
\t tab
\\ backslash
\” double quote
كلية تكنولوجيا الصناعة والطاقة
Simple decision-making statements
Syntax of Conditional/Ternary Operator in C
variable = Expression1 ? Expression2 : Expression3;
Or the syntax can also be in this form
variable = (condition) ? Expression2 : Expression3;
Or syntax can also be in this form
(condition) ? (variable = Expression2) : (variable = Expression3);
كلية تكنولوجيا الصناعة والطاقة
Working of Conditional/Ternary Operator in C
The working of the conditional operator in C is as follows:
•Step 1: Expression1 is the condition to be evaluated.
•Step 2A: If the condition(Expression1) is True
then Expression2 will be executed.
•Step 2B: If the condition(Expression1) is false
then Expression3 will be executed.
•Step 3: Results will be returned.
Example : C Program to Store the greatest of the two كلية تكنولوجيا الصناعة والطاقة
Output:
m is greater than n that is 5 > 4
كلية تكنولوجيا الصناعة والطاقة
Classroom Assignment
Write a program to evaluate the following equation.
Equation1 = 𝑎𝑥 2 + 6
Equation2 = 𝑎 ∗ 𝑥 + 𝑎/𝑥 2 + 6
Online C Compiler كلية تكنولوجيا الصناعة والطاقة
https://www.onlinegdb.com/online_c_compiler
https://www.tutorialspoint.com/compile_c_online.php
https://onecompiler.com/c
https://www.jdoodle.com/c-online-compiler/
كلية تكنولوجيا الصناعة والطاقة
Thank
q
you