
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program for Print the pattern by using one loop
The challenge is to display the pattern using one loop only and with continue statement.
Algorith
START Step 1 -> declare start variables i and j to 0 with number of rows in n to 6 Step 2 -> Loop For i=1 and i<=n IF j<i Print * Increment j by 1 Continue End IF IF j=1 Print
Set j=0 Increment i by 1 End IF Step 3 -> End For Loop STOP
Example
#include <stdio.h> int main() { int i, j=0; int n = 6; for ( i = 1; i <= n; ) { if( j < i ) { printf("*"); j++; continue; } if(j == i) { printf("
"); j = 0; i++; } } return 0; }
Output
If we run above program then it will generate following output
* ** *** **** ***** ******
- Related Articles
- C program to print name inside heart pattern using for loop.
- C program to print multiplication table by using for Loop
- Print a pattern without using any loop in C++
- Python Program for Print Number series without using any loop
- How to print a one-month calendar of user choice using for loop in C?
- C program to print number series without using any loop
- Write a C program to print the message in reverse order using for loop in strings
- C program to print four powers of numbers 1 to 9 using nested for loop
- Python program to print rangoli pattern using alphabets
- Program to print Interesting pattern in C++
- Program to print Kite Pattern in C++
- Program to print number pattern in C
- Program to print Diamond Pattern in C
- Program to print numeric pattern in C
- Program to print pyramid pattern in C

Advertisements