03 June, 2013

C Program To Perform Character Design : #02

This Post Contains A C Program To Perform Character Design With Correct Source Code, Algorithm & Output. This Program Is Written, Compiled & Executed At Turbo C/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 : #02
/* Declaration Of Header Files */
#include <stdio.h>
#include <conio.h>

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

/* Declaration Of Variables */
int num=0 ,col=0;

clrscr();


 /* Asking For The Input From User */
 printf(" \n Enter Number Of Rows : ");
 scanf("%d",&num);

 /* Source Code For Character Design */
 for(; num>=1; num--)
 {
        for(col=1; col<=num; col++)
        {     
              printf("@");
        }
        printf("\n");
 }

 getch();

 return 0;

}
/* End Of Main Program */

Output:
@@@@@
@@@@   
@@@
@@
@

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

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

/* Declaration Of Variables */
int num=0 ,col=0;

clrscr();


 /* Asking For The Input From User */
 cout  <<  " \n Enter Number Of Rows : ";
 cin  >>  num;

 /* Source Code For Character Design */
 for(; num>=1; num--)
 {
        for(col=1; col<=num; col++)
        {     
              cout  <<  "@";
        }
        cout  <<  "\n";
 }

 getch();

 return 0;

}
/* End Of Main Program */

Output:
@@@@@
@@@@   
@@@
@@
@




No comments:

Post a Comment

Subscribe To:

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

Blog Archive