Triangle using Do While Loop in C

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.

Program Do While Loop Password Another program

Program

#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();
}
Output
Please Enter Password: 34342
Password Invalid!
Please Enter Password: 223
Password Invalid!
Please Enter Password: 12345
Password Correct!

Program Printing Triangle using Do While Loop

Program

#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();
}
Output
*
**
***
****
*****
******
*******
********
*********
**********
***********