/****************************
* Umang B Bhatt *
* bhatt.umang7@gmail.com *
*****************************/
/**
* program for pattern
*/
#include<stdio.h>
void fun1(int arr[100][100], int n)
{
int i, j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
printf("%d ", arr[i][j]);
}
for (j = 0; j < n; j++)
{
printf("* ");
}
for (j = 0; j < n; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
}
void fun2(int arr[100][100], int n)
{
int i, j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
printf("* ");
}
for (j = 0; j < n; j++)
{
printf("%d ", arr[i][j]);
}
for (j = 0; j < n; j++)
{
printf("* ");
}
printf("\n");
}
}
void main()
{
int arr[100][100] = {0};
/* this is a trick to assign all the values whether
they are float integer or char this will do all the appropriate assignments.
eg 0 to integer and long, 0.0f to float and null to a character
:refer iso standards
*/
int n;
int i, j;
int count;
printf("Enter the number: ");
/* the number should be between 1 to 9*/
scanf("%d", &n);
count = n;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
arr[i][j] = count;
count++;
if (count > 9)
{
count = 0;
}
}
}
fun1(arr, n);
fun2(arr, n);
fun1(arr, n);
}
Wednesday, January 19, 2011
pattern
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment