Anonymous Anonymous - 14 days ago
213 0

pset 1 credit

C

credit

#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main (void) {

///Get correct user input

    printf("Number:");
    long long number = get_long_long();

    if (number<0) {
        printf("Must be positive, retry: ");
        number = get_long_long();
    }

    ///Counting numbers in card
    int counter = 1;
    long long characters = number;

    do {
        characters = characters/10;
        counter = counter+1;

    } while (characters>1);

    ///So original long long can be used if needed

    int digits = round(number);

    //validity algorithms go heree

    int a = 0;
    int i;
    int k;
    int q;
    int z = 0;
    int n;

    /// a is every other nunber * 2

   for (i=1; i<counter; i++) {

        for (n=0; n<1; n++) {
            k = pow(10,2*i);
            q = pow(10, 2*i-1);
            z = (digits%k-digits%q)/q;
            z = z*2;

                if (z >= 10) {

                    z = z%10 + 1;
                }
            }

    a = a + z;
    ///if statement here for if the number is two digit//
   }