–1 vote

Do you mean you would like to print integers out on the screen?

You can loop through a set of numbers and print each one of them one by one.

In the following example we start from 0 and end before reaching 10, so our last number is 9. After every number we also add a space. "%d" means, we want to print a decimal number, so the second argument of printf is the decimal number we would like to print. For details, see printf().

#include <stdio.h> int main() { for (int i = 0; i < 10; i++) { printf("%d ", i); } return 0; }

There is another typical scenario. You have an array, and you would like to print the content of this array. In this case, you'd write something, like this:

#include <stdio.h> #define count 5 int main() { int numbers[count] = { 5, 6, 9, 8, 2 }; for (int i = 0; i < count; i++) { printf("%d ", numbers[i]); } return 0; }

So we created a macro called *count* so we know how many elements are in our array. Then in the loop, we iterate through these elements one by one and print them.

I hope this helps.

Good luck! :)

0 votes

use array to count the digits of a number. first make the reverse of the number and then wse FOR loop to print induvidual number in the units place to get the digits of the number

the main code to use here is :

int n,i,m,rem,a=0;

scanf("%d",&n); // n is the number

scanf("%d",&m); // m is number the digits of the number

while(n!=0)

{

for(i=0;i<m;i++)

{

rem=n%10;

printf("%d",rem);

}

for(i=0;i<m;i++)

{

a=rem%10;

printf("%d",a);

}

}

return 0;

}

the main code to use here is :

int n,i,m,rem,a=0;

scanf("%d",&n); // n is the number

scanf("%d",&m); // m is number the digits of the number

while(n!=0)

{

for(i=0;i<m;i++)

{

rem=n%10;

printf("%d",rem);

}

for(i=0;i<m;i++)

{

a=rem%10;

printf("%d",a);

}

}

return 0;

}

...