Saturday, 25 August 2018

Program in C to print different types of pattern

For printing this type structure in C:

* * * * *
* * * * 
* * * 
* * 


Here as we seen the figure is in row and column form thus we have to declare two variable ( i and j ) for row and column respectively. Here we use for loop statement of c.

/* program to print structure */
#include<stdio.h>
void main()
{
int i,j,n ;
clrscr () ;
printf ("\n Enter number of rows:") ;
scanf ("%d", &n) ;
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
{
if (i<=j)
printf ("*") ;
else 
printf ("  ") ;
}
printf ("\n") ;
}
getch () ;
}

Output screen :: 

Enter number of rows :: 5

output :: 

* * * * *
* * * * 
* * * 
* * 

        

19 comments:

  1. Great way for us to know to print C

    ReplyDelete
  2. Well, this seems a very fun way to generate interest of kids in C and other coding languages. I remember hating those big big codes. These short and sweet codes would generate anyone's interest in coding.

    ReplyDelete
  3. As a non techie, a little bit of introduction on what is this used for would be helpful. Or may be your article is for the programmers?

    ReplyDelete
  4. I'm totally lost. lol. I guess programming is not my thing.

    ReplyDelete
  5. I have no idea about coding or C language. But a lil intro never hurt anyone right?

    ReplyDelete
  6. What is this used for? I have no clue what it is.

    ReplyDelete
    Replies
    1. Here we write C program to print pattern in C

      Delete
  7. Thanks for taking the time to share. This stuff can be confusing.

    ReplyDelete
  8. I took a programming class in college and still find it so difficult to understand.

    ReplyDelete
    Replies
    1. You can learn here programming in very easy way.

      Delete
  9. Wow! this is great idea from you. Nice one!

    ReplyDelete
  10. I have no idea what this means, but looks like you love what you do!

    ReplyDelete
  11. great information... This is going to be very helpful for the students.

    ReplyDelete
  12. Programming is not my thing. :( I'm happy to see that a lot of people learned from your blog.

    ReplyDelete
  13. I learnt C++ when I was in college...seems so long ago

    ReplyDelete
  14. wow sounds too complicating to understand. Maybe il have to learn everything from the scratch

    ReplyDelete

Featured post

Program to find Volume of given box in java

class volume { public static void main (String args []) { int l=5,b=6,h=10; int volume; volume=l*b*h; System.out.println (" vol...