Skip to main content

Posts

Showing posts with the label C

Simple Pyramid in Csharp .Net

    *   ***  ***** ******* Updated  As you can see below the code for simple pyramid has two for loop nested in each other. So for each row it enter, it increment the counter and draw the star against forming a pyramid like figure. You can use  different special counter, play with the loop and enjoy the coding. Simple Pyramid in Csharp    class Program     {          static void Main( string [] args)         {             int row, col = 0, n = 5;                                 for (row = 0; row <= n; row++)             {           ...

Inverted Pyramid, playing with stars

Playing with stars in C# *******  *****   ***     *     class Program     {          static void Main( string [] args)         {             int row, col = 0, n = 5;                                   int k = n;             for (row = 0; row <= n; row++)             {                 for ( int r = 0; r <= row; r++)                 {          ...

Worlds First Worm in C

The problems in C are not confined to just the language. Some routines in the standard library have  unsafe semantics. This was dramatically demonstrated in November 1988 by the worm program that wriggled through thousands of machines on the Internet network. When the smoke had cleared and the investigations were complete, it was determined that one way the worm had propagated was through a weakness in the finger daemon, which accepts queries over the network about who is currently logged in. The finger daemon, in.fingerd, used the standard I/O routine gets(). The nominal task of gets() is to read in a string from a stream. The caller tells it where to put the incoming characters. But gets() does not check the buffer space; in fact, it can't check the buffer space. If the caller provides a pointer to the stack, and more input than buffer space, gets() will happily overwrite the stack.  The finger daemon contained the code: main(argc, argv) char *argv[]; { ...