In order to display the given pattern in C, we can do the following:
C Program Source Codes to display
5
55
555
5555
55555
#include<stdio.h>
int main()
{
int i,j;
for(i=0; i<5; i++)
{
for(j=0; j<=i; j++)
{
printf("%d", 5);
}
printf("\n");
}
return 0;
}Program Output
5
55
555
5555
55555
C Program Source Codes to display
n
nn
nnn
nnnn
nnnnn
Here, n is any user-entered integer.
#include<stdio.h>
int main()
{
int i,j,n;
printf("Enter any integer number? ";
scanf("%d", n);
for(i=0; i<5; i++)
{
for(j=0; j<=i; j++)
{
printf("%d", n);
}
printf("\n");
}
return 0;
}Enter any number? 6
6
66
666
6666
66666
Leave a Reply