Silly doubt, how can i print numbers in sequence in C programming according to its variable value. my Code
#include <stdio.h>
void main()
{
int i,j,result;
for (i=1;i<=4;i++)
{
for (j=i;j<=i;j++)
{
printf("%d\n%d",i,j+1);
}
}
}
getting output as
1
22
33
44
Expecting answer is:
1
22
333
4444
void main()
{
int i,j,result;
for (i=1;i<=4;i++)
{
for (j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
}
It could help you. Note that in C
array indexing starts at 0, not 1.
void main()
{
int i,j;
for (i = 0; i < 4; ++i)
{
for (j = 0; j < i; ++j)
{
printf("%d", i);
}
printf("\n");
}
}
#include <stdio.h>
void main()
{
int i,j,result;
for (i=1;i<=4;i++)
{
for (j=i;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.