#My scanf ain't working for nome reason

5 messages · Page 1 of 1 (latest)

tired sequoiaBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

flat cosmos
#
#include <stdio.h>

int numbers[15];
int low, input, sum;

int lowCheck(){
    int x = numbers[0];
    for (int i=0; i<15; i++){
        if (numbers[i] <= low){
            x = numbers[i];
        }
    }
    return x;
}

int main(){
    int i = 0;
    while (i<15){
        printf("\nInput %d: ", i+1);
        scanf("%d", &input);
        sum += input;
        numbers[i] = input;
        i++;
    }
    low = lowCheck();
    printf("\nSum is %d", sum);
    printf("\nLowest is %d", low);
}
#
#include <stdio.h>

int numbers[15];
int low, input, sum;

int lowCheck(){
    int x = numbers[0];
    for (int i=0; i<15; i++){
        if (numbers[i] <= low){
            x = numbers[i];
        }
    }
    return x;
}

int main(){
    for (int i = 0; i<15; i++){
        printf("\nInput %d: ", i+1);
        scanf("%d", &input);
        sum += input;
        numbers[i] = input;
    }
    low = lowCheck();
    printf("\nSum is %d", sum);
    printf("\nLowest is %d", low);
}

I changed it into a for loop

tired sequoiaBOT
#

@flat cosmos

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

flat cosmos
#

!solvedd