Doubt
-
Hi sir need clear a explanation for this problem (n = 3)??wap for this 1###1 33#33 55555 33#33 1###1 at the place of (#) should come spaces
-
Hi sir need clear a explanation for this problem (n = 3)??wap for this 1###1 33#33 55555 33#33 1###1 at the place of (#) should come spaces
Member 11779027 wrote:
need clear a explanation for this problem
That is a fairly basic logic/counting problem that you should be able to figure out by writing the numbers on paper, and deciding how to calculate the number of digits vs the number of spaces for each value.
-
Hi sir need clear a explanation for this problem (n = 3)??wap for this 1###1 33#33 55555 33#33 1###1 at the place of (#) should come spaces
You could make some reasoning about row number and to-be-produced pattern:
0 1###1
1 33#33
2 55555
3 33#33
4 1###1The first point could be observig that
pattern(0) == pattern(4)
pattern(1) == pattern(3)
pattern(2) == pattern(2)all hold true. In other words
pattern(k) == pattern(4-k)
hold true for
k = 0, 1 , 2;
Go on and post specific questions when you are not able to continue.
-
You could make some reasoning about row number and to-be-produced pattern:
0 1###1
1 33#33
2 55555
3 33#33
4 1###1The first point could be observig that
pattern(0) == pattern(4)
pattern(1) == pattern(3)
pattern(2) == pattern(2)all hold true. In other words
pattern(k) == pattern(4-k)
hold true for
k = 0, 1 , 2;
Go on and post specific questions when you are not able to continue.
#include #include int main() { int num=3; for(int r1=1;r1<=num;r1++) { for(int c1=1;c1<=r1;c1++) { printf("*"); } for(int s1=r1;s1=1;r2--) { for(int c2=1;c2<=r2;c2++) { printf("*"); } for(int s1=r2;s1
-
You could make some reasoning about row number and to-be-produced pattern:
0 1###1
1 33#33
2 55555
3 33#33
4 1###1The first point could be observig that
pattern(0) == pattern(4)
pattern(1) == pattern(3)
pattern(2) == pattern(2)all hold true. In other words
pattern(k) == pattern(4-k)
hold true for
k = 0, 1 , 2;
Go on and post specific questions when you are not able to continue.
#include #include int main() { int num=3; for(int r1=1;r1<=num;r1++) { for(int c1=1;c1<=r1;c1++) { printf("*"); } for(int s1=r1;s1=1;r2--) { for(int c2=1;c2<=r2;c2++) { printf("*"); } for(int s1=r2;s1
-
Member 11779027 wrote:
need clear a explanation for this problem
That is a fairly basic logic/counting problem that you should be able to figure out by writing the numbers on paper, and deciding how to calculate the number of digits vs the number of spaces for each value.
Sir Thanks for your advice Finally done!!! but check it once and report me back if any problem is there in coding #include #include int main() { int num=3; for(int r1=1;r1<=num;r1++) { for(int c1=1;c1<=r1;c1++) { printf("*"); } for(int s1=r1;s1=1;r2--) { for(int c2=1;c2<=r2;c2++) { printf("*"); } for(int s1=r2;s1
-
Sir Thanks for your advice Finally done!!! but check it once and report me back if any problem is there in coding #include #include int main() { int num=3; for(int r1=1;r1<=num;r1++) { for(int c1=1;c1<=r1;c1++) { printf("*"); } for(int s1=r1;s1=1;r2--) { for(int c2=1;c2<=r2;c2++) { printf("*"); } for(int s1=r2;s1
-
* * ** ** ****** ** ** * *
-
* * ** ** ****** ** ** * *
-
yes sir the actual result is this #include #include int main() { int num=5; for(int r1=1;r1<=num;r1+=2) { for(int c1=1;c1<=r1;c1++) { printf("%d",r1); } for(int s1=r1;s1=1;r2-=2) { for(int c2=1;c2<=r2;c2++) { printf("%d",r2); } for(int s1=r2;s1
-
* * ** ** ****** ** ** * *
Your loop values are slightly off. You should be counting 1 - 3 - 5 - 3 - 1, and printing the numeric values in each line rather than stars. Your main loops should be something like:
int num = 5;
int index;
// go from 1 to 5
for (index = 1; index <= num; index += 2)
{
// print the first set of values
printf("%d\n", index); // just to show the number
}
// already printed the 5 set, so go from 3 to 1
for (index = num - 2; index > 0; index -= 2)
{
// print the last set of values
printf("%d\n", index);
} -
Your loop values are slightly off. You should be counting 1 - 3 - 5 - 3 - 1, and printing the numeric values in each line rather than stars. Your main loops should be something like:
int num = 5;
int index;
// go from 1 to 5
for (index = 1; index <= num; index += 2)
{
// print the first set of values
printf("%d\n", index); // just to show the number
}
// already printed the 5 set, so go from 3 to 1
for (index = num - 2; index > 0; index -= 2)
{
// print the last set of values
printf("%d\n", index);
}Ok sir Thnak's and could you please give some examples to practise in this pattern??
-
Ok sir Thnak's and could you please give some examples to practise in this pattern??