Teach Me: A program that finds multiples of 7 between a range of numbers
Similar to my previous thread this is an assignment for my intro to programming course. I am tasked with designing and writing a program that finds the multiples of 7 within a range of numbers and places them into an array. This range is inputted by the user and the program needs to keep a counter for the multiples of 7.
This is what I've written thus far.
Code:
#include <stdio.h>
int main ()
{
char fname[] = "John";
char lname[] = "Doe";
int list[1429];
int iv1;
int iv2;
int count;
int n;
int m;
printf("Enter two integer values. It is required that the first value be smaller than the second. \n");
scanf("%i%i",&iv1,&iv2);
count = 0;
if (iv1 > iv2)
{
printf ("\nThe first value was greater than the second. Try Again\n");
}
for (n = iv1; n <= iv2; n++)
{
if (n % 7 == 0)
{
list[count] = n;
count++;
}
}
printf("\n%s %s\n",fname,lname);
printf("CSCI 1101 \n");
printf("C Project 5 \n\n");
if (iv1 < iv2)
{
for (m=0; m < count; m++)
{
printf("%d \n",list[m]);
}
printf("\n");
}
printf("Count %i",count);
}
Things I've run into:
Is it possible to make the table a variable size that can increase with the amount of multiples of 7? Right now it's 1429 which is big enough for all the multiples of 7 between 0 and 9999.
This program registers 0 as a multiple of 7 and I don't know why.
Other than those two things I think this is good.