Thread: Getting error with digit position

  1. #1
    Registered User
    Join Date
    Sep 2018
    Posts
    2

    Getting error with digit position

    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.
    Last edited by Arthuoff; 09-13-2018 at 12:35 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 10-25-2017, 06:12 AM
  2. Print digit from k position.
    By Herien Wolf in forum C Programming
    Replies: 2
    Last Post: 11-14-2016, 12:16 AM
  3. Read from file - 1-digit and 2-digit numbers
    By Bonaventura in forum C Programming
    Replies: 8
    Last Post: 03-06-2010, 06:33 AM
  4. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 23
    Last Post: 09-21-2007, 03:00 PM
  5. Adding a Large number digit by digit
    By mejv3 in forum C Programming
    Replies: 1
    Last Post: 09-14-2007, 03:28 AM

Tags for this Thread