একটি সংখ্যা n দেওয়া হয়েছে এবং আমাদের সর্বাধিক n সংখ্যক তারার তীর স্টার প্যাটার্ন প্রিন্ট করতে হবে।
ইনপুট 4 এর স্টার প্যাটার্ন −
এর মত দেখাবে

উদাহরণ
Input: 3 Output:

Input: 5 Output:

নীচে ব্যবহৃত পদ্ধতি নিম্নরূপ -
- পূর্ণসংখ্যায় ইনপুট নিন।
- তারপর n স্পেস এবং n তারা প্রিন্ট করুন।
- n>1 পর্যন্ত হ্রাস।
- এখন n পর্যন্ত বৃদ্ধি।
- এবং ক্রমবর্ধমান ক্রমে স্পেস এবং তারা প্রিন্ট করুন।
অ্যালগরিদম
Start In function int arrow(int num) Step 1-> declare and initialize i, j Step 2-> Loop For i = 1 and i <= num and i++ Loop For j = i and j < num and j++ Print a space Loop For j = i and j <= num and j++ Print "*" Print newline Step 3-> Loop For i = 2 and i <= num and i++ Loop For j= 1 and j < I and j++ Print a space Loop For j = 1 and j <= i and j++ Print "*" Print newline In function int main() Step 1-> declare and initialize num = 4 Step 2-> call arrow(num)
উদাহরণ
#include <stdio.h>
// arrow function
int arrow(int num) {
int i, j;
// Prints the upper part of the arrow
for (i = 1; i <= num; i++) {
// to print the spaces
for (j = i; j < num; j++) {
printf(" ");
}
// to print the * for the pattern
for (j = i; j <= num; j++) {
printf("*");
}
printf("\n");
}
// Prints lower part of the arrow
for (i = 2; i <= num; i++) {
// to print the spaces
for (j = 1; j < i; j++) {
printf(" ");
}
// to print the * for the pattern
for (j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
int main() {
// get the value from user
int num = 4;
// function calling
arrow(num);
return 0;
} আউটপুট
উপরের কোডটি চালালে এটি নিম্নলিখিত আউটপুট −
উৎপন্ন করবে
