EE171 Lecture 5 Programming in C
EE171 Lecture 5 Programming in C
Lecture 5:
Computer Programing with C
1
Online Compilers
https://www.onlinegdb.com/online_c_compiler#
https://www.programiz.com/c-programming/online-compiler/
https://www.tutorialspoint.com/compile_c_online.php
2
Loop Control Statements
Jump Statements
Arrays
3
Loop Control Statements
Jump Statements
Arrays
4
Loop Control Statements
5
The for loop is used to execute a block of statements for a predefined iterations
until a particular condition is satisfied.
The general form of for loop is:
for (initialization; condition; increment/decrement)
{
statements;
}
Initialization: Starting point of the loop. Checked only once.
Condition:The test expression, evaluated on each iteration of the loop
Increment/decrement: The modifier expression, which changes the value of loop
control variable.This expression is executed at the end of each loop.
for Loop…
8
The while loop is useful when we don't know the number of iterations
in advance.
The general form of while loop is:
Jump Statements
Arrays
13
Jump Statements
14
Jump Statements
Arrays
22
23
Arrays
24
int marks[5];
char letters [100];
float temperature[31];
Arrays Initialization
27
marks[0] = 90;
marks[1] = 86;
………..
marks[4] = 91;
Arrays Dimensions
29
Single-Dimensional Array
int marks[5] = {3, 2, 1, 5, 4};
Multi-Dimensional Array
int manymarks[2][3] = {10, 20, 30, 40, 60, 70};
int manymarks[2][3] = {{10, 20, 30}, {40, 60, 70}};
int manymarks[][3] = {{10, 20, 30}, {40, 60, 70}};
Accessing Array Elements
30