This C# program demonstrates how to use the if-elseif-else statement.
using System; namespace XoaX { class Program { static void Main(string[] args) { string sString = ""; for (int i = 0; i < 20; ++i) { char c = ' '; // Change every third character to '*' if ((i % 3) == 0) { c = '*'; } else if ((i % 2) == 0) { // Set the remaining even 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.