Printing triangle using Do While Loop in C programming. Do While Loop will execute the code block once, before checking if the condition is true, and repeating the block of code.
#include<stdio.h>
#include<conio.h>
void main()
{
int val;
int a = 0;
do //executing process.
{
printf("Please Enter Password: ");
scanf("%d", &val); //user enter value storing in 'val'.
if(val == 12345) //if 'val' value equal to 12345 then
{
printf("Password Correct!");
break; //break the statement.
}
else //if not then
{
printf("Password Invalid!\n"); //print this.
}
a++; //adding 1 to 'a' value.
}
while(a < 3); //loop looping and checking condition.
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a = 0;
do //executing program.
{
int b = 0;
do //executing program
{
printf("*");
b++; //adding 1 to 'b' value.
}
while(b <= a); //loop checking condition.
printf("\n");
a++; //adding 1 to 'a' value.
}
while(a <= 10); //loop checking condition.
getch();
}