Sunday, July 22, 2012

Pattern Program Using C Language

This is a pattern displaying program. The pattern is


1 2 3 4 5 6

1 3 5 7 9 11

1 4 7 10 13 16

1 5 9 13 17 21



#include<stdio.h>
void main()
{
int i,j,x;
clrscr();
for(i=1;i<=4;i++)
{
x=1;
for(j=1;j<=6;j++)
{
printf(" %d",x);
x=x+i;
}
printf("\n");
}
getch();
}


Here is another pattern programwhich depends on user interaction:

if user input 1 -> {}
if user input 2 ->
{}{}
{}{}

if user input 3 ->
{}{}{}
{}{}{}
{}{}{}




#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter '1', '2' or '3':");
scanf("%d",&n);
for(i=0;i< n;i++)
{
for(j=0;j< n;j++)
{
printf("{}");
}
printf("\n");
}
getch ();
}

2 comments:

  1. sir plz post some java programs on stack & queue
    principle with their variable description &algorithm
    plzzzzz help sir its urgent

    ReplyDelete
    Replies
    1. I will post the program very soon, please visit the site after 2-3 days.

      Delete

Subscribe via email

Enter your email address:

Delivered by FeedBurner