Lec-5 Programming Fundamentals (1)
Lec-5 Programming Fundamentals (1)
Lecture 05
Week 03
Ms. Noor-ul-Huda
Senior Lecturer-I
Department of Computer Science
College of Computer Science and Information Systems
[email protected]
Lecture outcomes:
▪Arithmetic Operators
▪Compound Statements
* multiplication
/ division
c = a+b;
printf("a+b = %d \n",c);
c = a-b;
printf("a-b = %d \n",c);
c = a*b;
printf("a*b = %d \n",c);
c = a/b;
printf("a/b = %d \n",c);
c = a%b;
printf("Remainder when a divided by b = %d \n",c);
return 0;
Compound Statements
• Compound statements, also known as block statements, are used to group multiple
statements together into a single block.
• In many programming languages, compound statements are enclosed within curly braces {}.
• They are often used in control structures like loops and conditionals.
Compound Statements
#include <stdio.h>
int main() {
int x = 7;
if (x > 5) {
printf("x is greater than 5.\n");
printf("This is part of the if block.\n");
} else {
printf("x is not greater than 5.\n");
printf("This is part of the else block.\n");
}
Order of Sub-expression Evaluation:
int main() {
int num = 5;
return 0;
}