Ad Code

Creating Stunning Number and Star Patterns with C Programming Language.

Welcome to this tutorial where you will discover the fascinating world of number patterns and star patterns using the C programming language.

Patterns are essential in many programming tasks, and learning how to create and manipulate them is a valuable skill for any programmer. With the help of C programming, you can quickly and efficiently generate a wide variety of patterns that are both aesthetically pleasing and practical.


In this tutorial, we will provide you with a comprehensive guide to number patterns, where you will learn how to generate various patterns, including the Fibonacci sequence, Pascal's triangle, and many more. You will also discover how to create star patterns using C programming language, including hollow and filled stars, diamond patterns, and more.

We will cover all the essential concepts and syntax required to build these patterns in C programming language, making it easy for you to follow along and learn at your own pace. By the end of this tutorial, you will have gained the skills and knowledge needed to create your own unique number patterns and star patterns using C programming language.

Program 1:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=1;i<=n;i++)
	{
		for( j=1;j<=i;j++){
	        
			printf("%d",i);
			
		}
		printf("\n");
	}
	return 0;
 }


Output :

Enter the number
5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Program 2:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=1;i<=n;i++)
	{
		for( j=1;j<=i;j++){
	        
			printf("%d",j);
			
		}
		printf("\n");
	}
	return 0;
 }


Output :

Enter the number
5
1
1 2
1 2 3 
1 2 3 4
1 2 3 4 5

Program 3:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j,number=1;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=1;i<=n;i++)
	{
		for( j=1;j<i;j++){
	        
			printf("%d",number);
			number++;
		}
		printf("\n");
	}
	return 0;
 }


Output :

Enter the number
5

1
2 3
4 5 6
7 8 9 10


Star Patterns using a C programming language.

Program 1:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<n;j++){
	
			printf("*");
		}
		printf("\n");
	}
	return 0;
 }

Output :

Enter the number
5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

Program 2:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<=i;j++){
	
			printf("*");
		}
		printf("\n");
	}
	return 0;
 }



Output :

Enter the number
5
*
* *
* * *
* * * *
* * * * *

Program 3:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<n;j++){
	        if((i+j)>=(n-1))
	
			printf("*");
			else
			printf(" ");
		}
		printf("\n");
	}
	return 0;
 }



Output :

Enter the number
5
            *
         * *
      * * *
   * * * *
* * * * *

Program 4:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<2*n;j++){
	        if(j>=n-i&&j<=n+i)
			printf("*");
			else
			printf(" ");
		}
		printf("\n");
	}
	return 0;
 }




Output :

Enter the number
5
             *
          * * *
       * * * * *
    * * * * * * *
 * * * * * * * * * 

Program 5:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<n;j++){
	        if(j>=i)
			printf("*");
			else
			printf(" ");
		}
		printf("\n");
	}
	return 0;
 }



Output:

Enter the number
5
* * * * *
   * * * *
      * * *
         * *
            *

Program 6:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=0;i<n;i++)
	{
		for( j=0;j<n;j++){
	        if(i==0||j==0||i==n-1||j==n-1)
			printf("*");
			else
			printf(" ");
		}
		printf("\n");
	}
	return 0;
 }



Output:

Enter the number
5
* * * * *
*          * 
*          *
*          *
* * * * *

Program 7:
 #include<stdio.h>
 #include<conio.h>
 int main()
 {
	int n,i,j;
	printf("Enter the number \n");
	scanf("%d",&n);
	for( i=n;i>=1;i--)
	{
		for( j=1;j<=i;j++){
	        
			printf("*");
			
		}
		printf("\n");
	}
	return 0;
 }



Output:

Enter the number
5
* * * * *
* * * *
* * *
* *
*
 
Thank You for watching this tutorial. This tutorial is useful for you and

your practice.

Post a Comment

0 Comments

Ad Code