+ 1
How to count the number of i? (the last numbers I print)
here's the code: #include <stdio.h> main() { int n1; int n2; int m; int i; printf("enter the min. value: "); scanf("%d", &n1); printf("enter the max. value: "); scanf("%d", &n2); printf("enter the m value: "); scanf("%d", &m); for (i=n1; i<=n2; i++) { if (i%m==0) { printf("%d\t", i); } } return 0; } example output: enter the min. value: 1 enter the max. value: 10 enter the m value: 3 3 6 9 //how to add 3 as the count of those numbers divisble by m?
3 odpowiedzi
+ 4
To count how many times the i%m==0
U must declare a count variable above the loop for example int count=0; then inside ur if u have the choice as u want u can put this instruction before or after the printf count++; then print the count variable after ur loop to view the result .
+ 2
TheGirlHasNoName yay it worked!! thank you ☺️❤️
+ 2
You welcome