Twin Islands There are two islands, one made of \'!\' in the top left and one ma
ID: 3825030 • Letter: T
Question
Twin Islands
There are two islands, one made of '!' in the top left and one made of '?' in the bottom right. There is a border in the middle and ocean everywhere else.
Running total
You print an NxN matrix of numbers seperated by commas.
The pattern is simply a running total of values where each row contains only N values.
Make use of the function std::to_string for converting numeric values to strings
Upper Left Triangle
Print a trianble of '*' in the upper left portion.
Upper Right Triangle
Print a triangle of '*' in the upper right portion..
Can you teach me how to do that by for loop?
Explanation / Answer
Upper Left Triangle:-
#include <stdio.h>
int main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf(" ");
}
return 0;
}
Upper Right Triangle:-
#include <stdio.h>
int main()
{
int i, j, k;
for(i=5;i>=1;i--)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(k=5;k>=i;k--)
{
printf("*");
}
printf(" ");
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.