ITEC113Algorithms and Programming Techniques. C programming: Variables, Expressions Part I. Objectives. To understand what variables are initialization/garbage values naming conventions To learn about the frequently used data types To understand the components of an assignment Statements - PowerPoint PPT Presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
ITEC113Algorithms and Programming Techniques
C programming: Variables, Expressions Part I
Examples:
int x;
char gender;
float avg;
float sum=0;
char name[10];
int *fp;
(e.g. if, else, int, float, case, for, …).
The second and the other characters of the name can be any letter, any number, or an underscore “_”.
Examples
Some valid names:
my_name, m113_1, salary, bluemoon, _at
Some invalid names:
my name, my-name , 1stmonth , salary! , guns&roses ,
These are NOTrules but you can increase the quality of your program by using them!
are declared.
Example : intk ;
intm=15;
floatfnumber= 1.75;
charch=’w’ ;
Examples :
137–62081024
Real Numbers:
Example:
3.14159 534.3223440.3333333 0.1234567
Example :
-3738.78787878783.1415926535897900.123456789123456
Example:
Character : ( char )
Example: ‘A’ , ‘7’,
Example:
A is represented by decimal 65 or
8-bit binary 0 1 0 0 0 0 0 1
Categories of characters :
Example
cnt= 1; sum = 0;
ch= ‘Y’;
sum = sum + 1; avg = sum / cnt;
stores values 1 and 0 to cnt and sum.
stores character ‘Y’ to ch
stores computational results to sum and avg
In the Assignment Statement:
M = a * 5 + b % 4 ;
For real or integer numbers
For integer numbers only
parentheses
-ve and +ve signs
Mult. Div., and mod.
Add and subtract