This C# program demonstrates how to use the if-elseif-elseif-else statement.
using System; namespace XoaX { class Program { static void Main(string[] args) { string sString = ""; for (int i = 0; i < 40; ++i) { char c = ' '; // Change every character at an even index to '*' if ((i % 3) == 0) { c = '*'; } else if ((i % 2) == 0) { // Set the remaining even characters to "&" c = '&'; } else if ((i % 5) == 0) { // Set the remaining evry fifth characters to "|" c = '|'; } else { // Set the rest to "-" c = '-'; } sString += c; } Console.WriteLine(sString); } } }
*-&*&|*-&*&-*-&*&-*-&*&-*|&*&-*-&*&|*-&* Press any key to continue . . .
© 20072024 XoaX.net LLC. All rights reserved.