Decision Making and Branching - Looping Statements
Decision Making and Branching - Looping Statements
Branching – Looping
Statements
#include <stdio.h>
int main()
{
int j=0;
do
{
printf("Value of variable j is: %d\n", j);
j++;
}while (j<=3);
return 0;
}
#include<stdio.h>
int main()
{
int i=1,number=0;
printf("Enter a number: ");
scanf("%d",&number);
for(i=1;i<=10;i++)
{
printf("%d \n",(number*i));
}
01/05/2021 S.SENTHILKUMAR ASSO.PROF/ECE,GRTIET 12
break
It causes the next iteration of the enclosing for, #include <stdio.h>
int main()
while, or do loop to begin.
{
In the while and do, this means that the test part is int counter=10;
while (counter >=0)
executed immediately; {
if (counter==7)
In the for, control passes to the increment step. {
counter--;
The continue statement applies only to loops, not continue;
to switch. }
printf("%d ", counter);
A continue inside a switch inside a loop causes the counter--;
next loop iteration. }
return 0;
}
even:
printf("%d is even", num);
// return if even
return;
odd:
printf("%d is odd", num);
}
int main() {
int num = 26;
checkEvenOrNot(num);
return 0;
}
01/05/2021 S.SENTHILKUMAR ASSO.PROF/ECE,GRTIET 15
Write and share
Write a program in c to
print number 1 to 5 using
for loop statement?