Good Day Mr. Sachin Singh
Could you solved this ?
The output is like this:
*******
*****
***
*
Here is my code
C#
int y;
for (int x = 0; x < 7; x++)
{
for (y = 0; y <= x; y++)
{
//if (y==0 || y==x || x==16)
if (y % 2==0)
{
Console.Write("");
}
else
{
Console.Write("*");
}
}
Console.Write("\n");
}
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 14, 2021, 11:34 AM EDT
Ahmet TahaRank #3,505 · 414 reputationPosted Oct 15, 2021, 4:00 AM EDT
The output should be like this:
input number : 10
even number : 2 4 6 8
odd number number : 3 5 7 9
here is my code
int x; Console.Write("Input Number:\t"); int num = Convert.ToInt32(Console.ReadLine()); for (x = 0; x < num; x++) { if (x % 2 == 0) { Console.Write(" "); } else { Console.Write("{0}", x); } }Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 14, 2021, 11:10 AM EDT
Try this one
int y; for (int x = 9; x >= 1; x--) {for (y = x+2; y >= 1; y--){//if (y==0 || y==x || x==16)if (y % 2==0){Console.Write("");}else{Console.Write("*");}}Console.Write("\n"); }Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 14, 2021, 11:23 AM EDT
Try this... You can achieve the same without mod function
for ( int x = 7; x>=1; x=x-2)
{
for (int y = x; y>=1; y--)
{
console.write("*");
}
console.write("\n");
}
Ahmet TahaRank #3,505 · 414 reputationPosted Oct 14, 2021, 11:30 AM EDT
Ahmet TahaRank #3,505 · 414 reputationPosted Oct 14, 2021, 11:37 AM EDT
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 15, 2021, 4:53 AM EDT