07 June, 2013

C Program To Perform Character Design : #04.

This Post Contains A C Program To Perform Character Design With Correct Source Code, Algorithm & Output. This Program Is Written, Compiled & Executed At TurboC/C++3.0 Compiler & Will Help You To Understand The Concept Of 'Nested For-Loops' From C Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.

# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.



C Program To Perform Character Design : #04.
/* Declaration Of Header Files */
#include <stdio.h>
#include <conio.h>

/* Start Of Main Program */
void main()
{

/* Declaration Of Variables */
int i, j;

clrscr();

for(i=5; i>=1; i--)
{
   for(j=1; j<=i; j++)
   {    
      printf("%d\t",j % 2);
   }
   printf("\n");
}

getch();

}
/* End Of Main Program */

Output:
1  0  1  0  1
1  0  1  0
1  0  1
1  0
1

C++ Program To Perform Character Design : #04.
/* Declaration Of Header Files */
#include <iostream.h>
#include <conio.h>

/* Start Of Main Program */
void main()
{

/* Declaration Of Variables */
int i, j;

clrscr();

for(i=5; i>=1; i--)
{
   for(j=1; j<=i; j++)
   {    
      cout  <<  j % 2  <<  "\t";
   }
   cout  <<  "\n";
}

getch();

}
/* End Of Main Program */

Output:
1  0  1  0  1
1  0  1  0
1  0  1
1  0
1




No comments:

Post a Comment

Subscribe To:

Most Commonly Asked Programs In 'C' & 'C++' Language.

Blog Archive