There are basic four data types
1. char
2. int
3. float
4. double
A variable type char is 8 bits long and can hold a character.
A variable type int holds number with no fraction.(int came from the word integer). In 16 bit environment it can hold numbers valued from -32768(to keep in mind easily by (2)^(16-1) ) to + 32768. In 32 bits environment it can hold numbers valued form -2147483648(=2^(32-1) ) to +2147483647.
A variable type float and double holds numbers with fraction. The difference between float and double is that double can hold number valued twice larger than float.
This blog is designed for academic purpose for learning basic ideas of c programming and it will not make a professional programmer. All contents and programmes are based on my personal experience and class lecture when I was studying civil engineering in Chittagong University of Engineering and Technology (CUET). As I'm not a computer engineering student I can not assure you 100% accuracy. So I will be happy if you provide me comments and suggestions.
Monday, May 6, 2013
Control Statement
control Statements are used to create special programme features such as logical test, loopoing and branches. An example of control statement is
for(i=0;i<=n;i++)
{ sum+=i }
This means that "i" is a number which starts from 0 and ends at a number "n" which may be given to computer manually and "sum+=i" means computer has to sum present value of i with the previous.For example
for i=0 sum=0
for i=1 sum=0+1=1
for i=2 sum=1+2=3
for i=3 sum=3+3=6
for i=4 sum=6+4=10 and so on.
Note:- Here "sum" itself does not means to sum a value. It is used to keep in mind easily. It can be written in other format as "x+=i".
for(i=0;i<=n;i++)
{ sum+=i }
This means that "i" is a number which starts from 0 and ends at a number "n" which may be given to computer manually and "sum+=i" means computer has to sum present value of i with the previous.For example
for i=0 sum=0
for i=1 sum=0+1=1
for i=2 sum=1+2=3
for i=3 sum=3+3=6
for i=4 sum=6+4=10 and so on.
Note:- Here "sum" itself does not means to sum a value. It is used to keep in mind easily. It can be written in other format as "x+=i".
Compound Statement
A compound statement consists of several statements enclosed in a pair of second brackets. Such as-
{cin>>a;
sum=a+b;
cout<<sum;}
Each statement of a compound statement can be expression statement, compound statement and control statement.
{cin>>a;
sum=a+b;
cout<<sum;}
Each statement of a compound statement can be expression statement, compound statement and control statement.
Expression Statement
An expression statement consists of an expression followed by a semicolon. Such as
cin>>a>>b;
Note:- cin and cout are used in C++ but they can be used in C programming and easier to use than scanf and printf.
cin>>a>>b;
Note:- cin and cout are used in C++ but they can be used in C programming and easier to use than scanf and printf.
Statement
Statements are those which direct computer to carryout actions. Statements are of three types --
1.Expression Statement
2.Compound Statement
3.Control Statement
1.Expression Statement
2.Compound Statement
3.Control Statement
Subscribe to:
Posts (Atom)