This is my program:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int k, br,j=1,zbroj;
printf("Ucitati broj(manji od 10000):\n");
scanf("%d", &k);
for(br=1;br<=k;br++)
{
if(br % 7 == 0){
printf("%d", br);
j=br;
while(j != 0)
{
zbroj=(k / 10) % 10;
}
}
}
printf("Cifra koja se nalazi na k-tom mjestu u ispisu je: %d\n", zbroj);
return 0;
}
I was doing some practice in C, and I got encountered with unusual problem.Program is about to find kth digit position(for loop prints numbers that are divisible by 7: 7 14 21 28 35 42…You get the point.So if I input k with value 3, it should print digit in that location is 4 but somehow it doesn’t).Any tip or suggestion would be appreciated.