0% found this document useful (0 votes)
10 views51 pages

Unit2pptx 2022 10 20 09 40 44

The document discusses various topics related to C programming basics including features of C language, simple C program, program execution steps, data types, constants, variables, operators, expressions, type conversion and precedence rules. It provides information on the basic structure and components of C programs.

Uploaded by

bapah97958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views51 pages

Unit2pptx 2022 10 20 09 40 44

The document discusses various topics related to C programming basics including features of C language, simple C program, program execution steps, data types, constants, variables, operators, expressions, type conversion and precedence rules. It provides information on the basic structure and components of C programs.

Uploaded by

bapah97958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

Department of

Information Technology

Unit-2
C Programming Basics Computer
Programming-
01CE0101

Prof. Riddhi Kotak


 Robust Language
 Built-in-Functions
 Well structured Programming Language
 Combine assembly language with High-Level Language
 Efficient and Fast
Features of C
 Highly Portable
Language  Ability to extend
 #include<stdio.h>
 #include<conioh.>
void main()
{
printf(“Hello World..”) ;
Simple C
}
Program
Output
Steps of
Program
Execution
Basic Structure
of C Programs
Basic Structure
of C Programs
Basic Structure
of C Programs
Documentation
section
Link section
and
Definition
section
Global
Declaration
and
Main function
Continue..
 1) *
 **
 ***
 ****
 *****
 Constants:
 Constants represent fixed values.

Constants,
Variables and
Data-types
 Integer Constants
 Floating-point Constants
Types of  Character Constants
Constants
 String Constants
 Consists a sequence of digits.
 Types of Integers:
 Decimal -> 123
Integer  Octal -> 0463
Constants  Hexadecimal -> 0x8F
 These represent numbers containing
fractional parts.
Floating point
Constants  Example: 2.36
-97.2354
 These represent a single character
value.
Character
Constants  Example: ‘A’ ,
‘b’ ,
’@’
 A sequence of characters which are
enclosed in double quotes.
String
Constants  Example: “Computer”
“12345”
 Symbolic representation of a value
 Used to store values in program.
 It’s value changes as the program
statements are executed.
Variables  Example:
 x
 balance
 User_name
Data-Types of  C language supports 4 fundamental data types :
C
Some other
data types :
 Individual words and punctuation marks in C program are
called as C tokens.

Tokens
Continue..
 Refers to the names of variables, functions and
arrays.
 Rules for defining identifiers:
 First character must be an alphabet (or
Identifiers underscore).
 Must contain only letters, digits or
underscore.
 Only first 32 characters are significant.
 Cannot use a special keyword.
 Must not contain white space.
 Operators
 Symbol that indicates the operation or
activity to be performed.
Different types  Example
of Operators
 + means addition like A+B
 Here, A,B called operands
 + called operator
Arithmetic Operators
Performs arithmetic operations
Assignment Operators
It copy/store, thus assigning value
hence the name is assignment operator.
Shorthand Operators
Increment/Decrement Operators
Increment/Decrement Operators
Relational Operators
Used to compare two operands
Logical Operators
& (AND operation)
In C form : condition-1 & condition-2
Example :
 | (OR operation)
 In C form : condition-1 | condition-2
 Example :
! (NOT operation)
In C form : !condition-1
Example :
Also known as ternary operator.
Bitwise Operator
Special Operators
 Evaluation an expression
Expression,  Implicit Type Conversion
Type  Explicit Type Conversion
conversion,  Conversion Order
Precedence
and
Associativity
Evaluation an expression
Conversion
Order
• Implicit type conversion in C language is the conversion of
one data type into another datatype by the compiler during
the execution of the program.

• Implicit Type Conversion is also known as ‘automatic type


Implicit Type conversion‘.
Conversion
• It generally takes place when in an expression more than one
data type is present.

• In such condition type conversion (type promotion) takes


place to avoid loss of data.

• All the data types of the variables are upgraded to the data
type of the variable with the largest data type.
Implicit Type Conversion
• This process is also called type casting and it is user
defined. Here the user can type cast the result to
make it of a particular data type.

• The syntax in C:
Explicit Type (type) expression
Conversion
Explicit conversion or cast is a process of passing
information to the compiler that the program is
trying to perform conversion with the knowledge of
possible data loss.
For Example, if we are converting a higher numeric
value into a lower one.

double d = 75.25;
Continue.. int i;
i = (int)d;

Now, if you print “i”, you will find that it will print
“75”. All the data after the decimal will be lost in the
conversion.
Rules for evaluation of expression

1. The expressions within parentheses assume highest


priority
2. If parentheses are nested, the evaluation begins with
the innermost sub expression
3. The precedence rule is applied in determining the
order of application of operators.
4. The associatively rule is applied when 2 or more
operators of the same precedence level appear in a
sub expression.
Evaluation an expression

You might also like