C Programming

C Programming


Nested Number Character Pyramid

Posted: 26 Mar 2014 04:51 AM PDT

Q. Write a C program to print the following nested number-character pyramid/pattern as:

A
1
BB
22
CCC
333

Ans.

/*c program for nested number character pyramid*/
#include<stdio.h>
int main()
{
 int num,r,c,z,n=1;
 char ch='A';
 printf("Enter Maximum number : ");
 scanf("%d", &num);

 for(r=1; r<=num; r++,ch++,n++)
 {
  for(c=1; c<=2; c++)
  {
   if(c%2==0)
   {
     for(z=1; z<=r; z++)
        printf("%d",n);
   }
   else
   {
     for(z=1; z<=r; z++)
        printf("%c",ch);
   }
   printf("\n");
  }
 }
 getch();
 return 0;
}


/**************************************************************
The output of above program would be:
**************************************************************/


Output for Nested Number Character Pyramid C program
Figure: Screen shot for Nested Number Character Pyramid C program


Related programs:

1. Nested same Symbol Pyramid as:

   #
   #
   ##
   ##
   ###
   ###

2. Nested Differ Symbol Pyramid as:

   @
   #
   @@
   ##
   @@@
   ###

3. Nested Equal same-equal Pyramid as:
   
   @
   @
   ##
   ##
   @@@
   @@@

4. Nested Equal Number Pyramid as:

   1
   1
   22
   22
   333
   333

5. Nested Differ Character Pyramid as:
   
   A
   A
   BB
   BB
   CCC
   CCC


Post a Comment

9lessons:Facebook Style Friend Request System Database Design.

9lessons:Facebook Style Friend Request System Database Design.

Link to 9lessons Programming Blog

Facebook Style Friend Request System Database Design.

Posted: 17 Mar 2014 10:24 AM PDT

I received few tutorial requests from my readers that asked to me, how to design Facebook style friend request system using MySQL. I had posted few tutorials about twitter style friend follow and follower concept designs, Facebook friend system is involved with few pending steps such as sending a request and accepting a request. Here I have discussed how to design a database and implementation of SQL queries, hope this post will help you to understand the friend system.

Friend Request System Database Design.

Read more »


Post a Comment

9lessons:Professional Website Design Platform Showdown – Webydo vs. Squarespace

9lessons:Professional Website Design Platform Showdown – Webydo vs. Squarespace

Link to 9lessons Programming Blog

Professional Website Design Platform Showdown – Webydo vs. Squarespace

Posted: 09 Mar 2014 09:44 AM PDT

In today's fast paced world of website design, new services are breaking on to the scene that provide elegant, all-encompassing solutions for those looking to build up a compelling web presence. Two of the major players in this new arena are Webydo and Squarespace. Both platforms are built to offer professional web designers a complete platform for creating feature rich web designs without the need for a degree in web development.

Read more »


Post a Comment

9lessons:Blogger Template Design

9lessons:Blogger Template Design

Link to 9lessons Programming Blog

Blogger Template Design

Posted: 04 Mar 2014 10:38 AM PST

Hope you know 9lessons blog is power by google blogger platform and I am not paying any hosting changers from last 4 years. I strongly suggest blogger is the perfect platform for blogging (present your ideas), but you have to do few coding changes for better results. My first success was I did customized blogger template completely, so take a look at this post and implement for great results.

Blogger Template Design.

Read more »


Post a Comment