• Identifiers are the fundamental building blocks of a program • Used to give names to variables, functions, constant, and user defined data. • They are user-defined names and consist of a sequence of letters and digits
©LPU CSE101 C Programming Rules for naming an Identifier
©LPU CSE101 C Programming Some Identifiers Tool_spanner; tool_spanner; FORMULA1; engine_1; both are different Wrong identifiers name 1_engine; break; @car-roof;
©LPU CSE101 C Programming C Keywords • Keywords are the reserved words whose meaning has already been explained to the C compiler. • We cannot use these keywords as variables. • Each keyword is meant to perform a specific function in a C program. • There are 32 keywords in C language. • All keywords are written in lowercase only Eg: The name of person can never be home , eat , sleep , run , etc because these words have some predefined meaning to perform some task. Quick yak: Ask students some of the keywords i.e. words which are by themselves and cannot be used for anything else ex: left, right…
©LPU CSE101 C Programming List of C Keywords auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while
©LPU CSE101 C Programming Data Types • Data type means the type of value a variable will have. • It also defines memory space for a particular variable in computer. • The type of value of variable can be alphabets or numbers. • The numbers can be further divided as the integer or rational number.
©LPU CSE101 C Programming • Lets see a mathematics problem:
©LPU CSE101 C Programming My-Car 1. If the radius of car wheel is 15inch then what will the distance traveled after one rotation of that wheel? Sol: Given- radius = 15 dist_travelled = ? So, Circumference of circle = 2 * pi * r dist_travelled = 2 * 3.14 * radius dist_travelled = 6.28 * 15 dist_travelled = 94.2 Ans. 15 15 3.14 3.14 94.2 94.2 Integer( int in C ) Real ( float in C) Real ( float in C)
©LPU CSE101 C Programming My-Grades 2. Five students have appeared for Mathematics exam and their respective marks are 84 , 34 , 97 , 58 , 64 consider the rank bands and their respective grades as 80 to 100 – A 60 to 79 – B 40 to 59 – C less than 40 – D So find the grade for each students?
©LPU CSE101 C Programming Sol: Given- M1= 84 , G1=?
- Spring '18
- Long integer, Short integer
Other Related Materials
- Size bytes Minimal range char 1 128 to 127 unsigned char 1 0 to 255 int 2 or 4
- Lovely Professional University
- CSE 101 - Fall 2019
A1986010629_23838_8_2019_DATA TYPES (1).ppt