Saturday, March 16, 2013

C#: An example about FOR loop


/ / Example 1: Write a C # program using FOR in structure to the screen the results are as follows:
*******
******
*****
****
***
**
*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FOR_1 {
class Program {
static void Main (string [] args) {
     int i, j;
     for (i = 0; i <= 6; i + +) {
           for (j = 1; j <= 7-i; j + +) Console.Write ("*");
           Console.Write ("\ n");
     }
Console.ReadLine ();
   }
 }
}

No comments:

Post a Comment