सी में स्टार पैटर्न की शुरूआत (Introduction of Star pattern in C)
इस लेख में, सबसे पहले, हम यह देखने जा रहे हैं कि उदाहरणों की मदद से विभिन्न स्टार पैटर्न कार्यक्रमों के साथ काम करने के लिए सी प्रोग्रामिंग भाषा का उपयोग कैसे किया जाए। किसी भी प्रोग्रामिंग भाषा में, स्टार पैटर्न आम पैटर्न में से एक है कि व्यापक रूप से उपयोग किया जाता है क्योंकि यह तार्किक सोच में सुधार और प्रवाह नियंत्रण ज्ञान में मदद करता है । सी भाषा में एक स्टार पैटर्न बनाने के लिए, आपको बस दो छोरों या तीन छोरों का उपयोग करना होगा। छोरों की संख्या पैटर्न है कि आप बनाने की जरूरत पर निर्भर करता है। पैटर्न के लिए न्यूनतम दो का उपयोग किया जाता है यानी पंक्ति के लिए एक और एक कॉलम के लिए। पहले लूप को बाहरी लूप कहा जाता है जो पंक्तियों को दिखाता है और दूसरा लूप को इनर लूप कहा जाता है जो कॉलम दिखाता है ।
In this article, first, we are going to see how to use C programming language to work with various star patterns programs with the help of examples. In any programming language, star patterns are one of the common patterns that are widely used because it helps to improve logical thinking and flow control knowledge. To create a star pattern in the C language, you just have to use two loops or three loops. The number of loops depends on the pattern that you need to create. For pattern minimum two are used i.e. one for row and one for a column. The First loop is called an outer loop that shows the rows and the second loop is called an inner loop that shows columns.
👉सी भाषा में स्टार पैटर्न के उदाहरण Examples of Star Patterns in C language
आइए सी भाषा में अवधारणा को आसानी से समझने के लिए कुछ उदाहरणों पर चर्चा करें ।
Let us discuss some examples to understand the concept in C language easily.
👉Example 1: सी में कार्यक्रम स्टार पिरामिड पैटर्न प्रिंट करने के लिए(Program in C to print star pyramid pattern).
निम्नलिखित कार्यक्रम में, उपयोगकर्ता स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा (In the following program, the user can enter the number of rows to print the star pyramid pattern as he wishes, then the result will be displayed on the screen)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, s, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
//for loop for displaying space
for(s = i; s < n; s++)
{
printf(" ");
}
//for loop to display star equal to row number
for(j = 1; j <= (2 * i - 1); j++)
{
printf("*");
}
// ending line after each row
printf("\n");
}
}
Output:
👉उदाहरण 2: पंक्तियों की संख्या दर्ज करने के लिए सी में कार्यक्रम (Program in C to enter the number of rows).
निम्नलिखित कार्यक्रम में, उपयोगकर्ता स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा (In the following program, the user can enter the number of rows to print the star pyramid pattern as he wishes, then the result will be displayed on the screen)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, s, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = n; i >= 1; i--)
{
//for loop to put space
for(s = i; s < n; s++)
printf(" ");
//for loop for displaying star
for(j = 1; j <= (2 * i - 1); j++)
printf("* ");
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉Example 3: सी में कार्यक्रम आधा सितारा पिरामिड पैटर्न प्रिंट करने के लिए (Program in C to print half star pyramid pattern).
निम्नलिखित कार्यक्रम में, उपयोगकर्ता आधा सितारा पिरामिड पैटर्न प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा (In the following program, the user can enter the number of rows to print the half star pyramid pattern as he wishes, then the result will be displayed on the screen)
#include<stdio.h>
#include<conio.h>
int main()
{
int i, j, n;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= i; j++)
{
printf("* ");
}
//Ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 4: उलटा आधा सितारा पिरामिड पैटर्न प्रिंट करने के लिए सी में कार्यक्रम (Program in C to print the inverted half star pyramid pattern)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता उल्टे आधे स्टार पिरामिड पैटर्न को मुद्रित करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा: (In the following program, the user can enter the number of rows to print the inverted half star pyramid pattern as he wishes, then the result will be displayed on the screen.)
#include<stdio.h>
#include<conio.h>
int main()
{
int i, j, n;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = n; i >= 1; i--)
{
for(j = 1; j <= i; j++)
{
printf("* ");
}
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 5: कार्यक्रम सी में पूर्ण सितारा हीरे पैटर्न प्रिंट करने के लिए (Program to print the full star diamond pattern in C.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता हीरे के पैटर्न को मुद्रित करने के लिए हीरे के आयाम के लिए पंक्तियों की संख्या दर्ज कर सकता है, फिर परिणाम स्क्रीन पर प्रदर्शित किया जाएगा: (In the following program, the user can enter the number of rows for the diamond dimension to print the diamond pattern as he wishes, then the result will be displayed on the screen.)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, s, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 0; i <= n; i++)
{
for(s = n; s > i; s--)
printf(" ");
for(j=0; j<i; j++)
printf("* ");
printf("\n");
}
for(i = 1; i < n; i++)
{
for(s = 0; s < i; s++)
printf(" ");
for(j = n; j > i; j--)
printf("* ");
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 6: उलटा सितारा पिरामिड पैटर्न प्रिंट करने के लिए सी में कार्यक्रम। ( Program in C to print inverted star pyramid pattern.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता उल्टे स्टार पिरामिड पैटर्न को मुद्रित करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा: (In the following program, the user can enter the number of rows to print the inverted star pyramid pattern as he wishes, then the result will be displayed on the screen.)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, s, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = n; i >= 1; i--)
{
//for loop to put space
for(s = i; s < n; s++)
printf(" ");
//for loop for displaying star
for(j = 1; j <= i; j++)
printf("* ");
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉Example 7: पंक्तियों की संख्या दर्ज करने के लिए सी में कार्यक्रम। (Program in C to enter the number of rows.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा | (In the following program, the user can enter the number of rows to print the star pyramid pattern as he wishes, then the result will be displayed on the screen:)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, s, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
//for loop to put space
for(s = i; s < n; s++)
printf(" ");
//for loop for displaying star
for(j = 1; j <= i; j++)
printf("* ");
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 8: सी में कार्यक्रम प्रिंट करने के लिए पंक्तियों की संख्या दर्ज करने के लिए। (Program in C to enter the number of rows to print.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा | (In the following program, the user can enter the number of rows to print the star pyramid pattern as he wishes, then the result will be displayed on the screen:)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, i , j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}
for(i = n; i >= 1; i--)
{
for(j = 1; j <= i; j++)
{
printf( "*");
}
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉Example 9: सी में कार्यक्रम स्टार प्रिंट करने के लिए पंक्तियों की संख्या दर्ज करने के लिए | (Program in C to enter the number of rows to print the star )
निम्नलिखित कार्यक्रम में, उपयोगकर्ता स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा | (In the following program, the user can enter the number of rows to print the star pyramid pattern as he wishes, then the result will be displayed on the screen:)
#include<stdio.h>
#include<conio.h>
int main()
{
int n, i, j;
printf("Enter number of rows: ");
scanf("%d",&n);
for(i = 1; i <= n; i++)
{
for(j = i; j < n; j++)
{
printf(" ");
}
for(j = 1; j <= i; j++)
{
printf("*");
}
printf("\n");
}
for(i = n; i >= 1; i--)
{
for(j = i; j <= n; j++)
{
printf(" ");
}
for(j = 1; j < i; j++)
{
printf("*");
}
// ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 10: सी + कार्यक्रम एक हीरे के पैटर्न में खोखले स्टार पिरामिड मुद्रित करने के लिए। (C+ Program to print the hollow star pyramid in a diamond pattern.)
निम्नलिखित सी कार्यक्रम में, उपयोगकर्ता खोखले स्टार पिरामिड को हीरे के पैटर्न में प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, फिर परिणाम स्क्रीन पर प्रदर्शित किया जाएगा | (In the following C program, the user can enter the number of rows to print the hollow star pyramid in a diamond pattern as he wishes, then the result will be displayed on the screen:)
#include<stdio.h>
#include<conio.h>
int main()
{
printf("Enter size of Daimond: ");
int n, i, j, m = 1, k;
scanf("%d",&n);
for(i = 0; i <= n; i++)
{
for(j = n; j > i; j--)
{
printf(" ");
}
printf("*");
if (i > 0)
{
for(k = 1; k <= m; k++)
{
printf(" ");
}
m += 2;
printf("*");
}
printf("\n");
}
m -= 4;
for(i = 0; i <= n-1; i++)
{
for(j = 0; j <= i; j++)
{
printf(" ");
}
printf("*");
for(k = 1; k <= m; k++)
{
printf(" ");
}
m -= 2;
if(i != n-1)
{
printf ("*");
}
//ending line after each row
printf("\n");
}
return 0;
}
Output:
👉उदाहरण 11: कार्यक्रम सी में खोखले स्टार पिरामिड पैटर्न प्रिंट करने के लिए । (Program to print hollow star pyramid pattern in C.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता खोखले स्टार पिरामिड पैटर्न को प्रिंट करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा |
(In the following program, the user can enter the number of rows to print the hollow star pyramid pattern as he wishes, then the result will be displayed on the screen.)
#include<stdio.h>
#include<conio.h>
int main()
{
int r, i, j, s;
printf("Enter number of rows: ");
scanf("%d",&r);
for(i = 1; i <= r; i++)
{
//for loop to put space in pyramid
for (s = i; s < r; s++)
printf(" ");
//for loop to print star
for(j = 1; j <= (2 * r - 1); j++)
{
if(i == r || j == 1 || j == 2*i - 1)
printf("*");
else
printf(" ");
}
//ending line after each row
printf("\n");
}
return 0;
}
Output:
उदाहरण 12: कार्यक्रम सी में उल्टे खोखले स्टार पिरामिड पैटर्न प्रिंट करने के लिए । ( Program to print inverted hollow star pyramid pattern in C.)
निम्नलिखित कार्यक्रम में, उपयोगकर्ता उल्टे खोखले स्टार पिरामिड पैटर्न को मुद्रित करने के लिए पंक्तियों की संख्या दर्ज कर सकता है, जैसा कि वह चाहता है, तो परिणाम स्क्रीन पर प्रदर्शित किया जाएगा | (In the following program, the user can enter the number of rows to print the inverted hollow star pyramid pattern as he wishes, then the result will be displayed on the screen:)
👉सी कार्यक्रम उल्टे खोखले स्टार पिरामिड प्रदर्शित करने के लिए। (C program to display the inverted hollow star pyramid.)
#include<stdio.h>
#include<conio.h>
int main()
{
int r, i, j, s;
printf("Enter number of rows: ");
scanf("%d",&r);
for(i = r; i >= 1; i--)
{
//for loop to put space in pyramid
for (s = i; s < r; s++)
printf(" ");
//for loop to print star in pyramid
for(j = 1; j <= 2 * i - 1; j++)
{
if(i == r || j == 1 || j == 2*i - 1)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
Output:
👉समाप्ति (Conclusion)
तो यहां हमने विभिन्न स्टार पैटर्न को प्रिंट करने के लिए कार्यक्रम देखे हैं। स्टार पिरामिड पैटर्न को कैसे प्रिंट करें और पंक्तियों की संख्या में उल्टे खोखले स्टार पिरामिड पैटर्न को प्रिंट करें। बेहतर बढ़ने और कदम से कदम समझने के लिए फार्मूले भी शामिल है. (So here we have seen programs for how to print various Star pattern. How to print the Star pyramid pattern and to print the inverted hollow star pyramid pattern in the number of rows. Includes Formulas to grow better and understand step by step.)
👉अनुशंसित लेख (Recommended Articles)
This has been a guide to Star Patterns in C. Here we discuss the examples of star patterns in C language with 12 different images and codes. You can also go through our other suggested articles to learn more-
💬https://romyou.blogspot.com/2021/09/windows-programming-with-c-example-with.html
💬 patterns C programming language.
💬window programming language.
1 Comments
Good information
ReplyDelete