Introduction To C Programming
Introduction To C Programming
Text Books
1. Programming in ANSI C (3rd Edition) by E Balagurusamy
2. C – The Complete Reference (4th Edition) by Herbert Schildt
3. C – How To Program (4th Edition) by Deitel & Deitel
Useful Links
• http://www.lysator.liu.se/c/bwk-tutor.html
• http://www.cs.cf.ac.uk/Dave/C
Grading System
Numerical Grade Letter Grade Grade point
80% or above A+ (A Plus) 4.00
75% to less than 80% A (A Regular ) 3.75
70% to less than 75% A- (A Minus) 3.50
65% to less than 70% B+ (B Plus) 3.25
60% to less than 65% B (B Regular) 3.00
55% to less than 60% B- (B Minus) 2.75
50% to less than 55% C+ (C Plus) 2.50
45% to less than 50% C (C Regular) 2.25
40% to less than 45% D 2.00
Less than 40% F 0.00
• Systems programming:
– OSes, like Linux
– microcontrollers: automobiles and airplanes
– Embedded processors: phones, portable electronics, etc.
– DSP processors: digital audio and TV systems.
Comments
#include <stdio.h>
Main() function begin here
int main ()
{ Library function
printf("Hello World!\n");
return 0;
} Return 0 from main means our program
finished without errors
Today's Outline
Data Types
C Tokens
Keywords & Identifiers
Constants
Variables
The four C scopes
Type Qualifiers
Storage Class Specifiers
Today's Outline
C operators
Operator Precedence & Associativity
C Expression Evaluation
Type Conversion in Expressions
Operator Example
+= X += 1
-= X -= 1
*= X *= Y
/= X /= Y
%= X %= Y
a = 10; a = 10;
b = 15; b = 15;
If (a > b) x = (a > b) ? a : b;
x = a;
else
x = b;
Today's Outline
Decision making statements in C
• Simple if statement
• if_else statement
• else_if ladder
• nested if_else statement
• switch statement
• goto statement
scanf( “ %f “ , &marks );
if( marks >= 80 )
printf( "Yes, the student get A+“ );
if( num % 2 == 0 )
printf( “Even number“ );
else
printf( “Odd number” );
Today's Outline
Looping statements in C
• for loop
• while loop
• do-while loop
Jump Statements in C
• continue
• break
• goto
Init
false
Condition
true
Body of loop
Inc / Dec
int i, sum=0;
for(i=1; ; i++)
{
sum += i;
if(sum >= 10)
break;
}
Md. Mahbub Alam Structured Programming Language (CSE- 8
1121)
goto Statement
Format:
goto label;
main()
.........
{
.........
double x,y;
label:
read:
statements;
scanf("%lf",&x);
if(x<0)
label: goto read;
statements; y=sqrt(x);
......... printf("%lf",y);
......... }
goto label;