Pattern C Program
Pattern C Program
#include<stdio.h>
Void main()
{
Int I,j,n; \\(where I for rows & j for column)
for (intiolaization;condition;increement/decreement) \\(loop for rows)
{
for(intiolaization ; condition;increement/decreement)\\
(loop for colmun)
{
printf(“”);
}
}
}
Square programe
#include<stdio.h>
Void main()
{
Int I,j,n; \\(where I for rows & j for column)
for (i=1;i<=n;i++) \\(loop for rows)
{
for(j=1;j<=n;j++)\\ (loop for colmun)
{
printf(“*”);
}
}
}
output
• Assume value of n=5
*****
*****
*****
*****
*****
triangle
• We can make new patterns by just doing smaller changes
#include<stdio.h>
Void main()
{
Int I,j,n; \\(where I for rows & j for column)
for (i=1;i<=n;i++) \\(loop for rows)
{
for(j=1;j<=i;j++)\\ (loop for colmun)
{
printf(“*”);
}
}
}
Out put
• Assume value of n is 7
*
**
***
****
*****
******
*******
• We can print alphabets by just changing in
printf function.
• printf(“%c”,m);
• We can use numbers by using %d in printf
function