Hey guys, having a bit of trouble with more of this array stuff. This is my code so far:
There are a few things I gotta get out of this. I have to print the values from the array that are greater than or equal to the starting value AND less than or equal to the stopping value. I then have to count the number of values between the starting and stopping values and how many of them are even and how many are odd. I tried using some IF statements, but it wasnt working out.Code:#include <stdio.h> #include <stdlib.h> int main(void) { int data[50]; int i, n, start, stop; printf("How many integers should I read (1--50)? "); scanf("%d", &n); if(n > 50) { printf("That value is too large.\n"); exit(1); } printf("\nEnter your values, one per line.\n"); for(i = 0; i < n; i++) scanf("%d", &data[i]); printf("\nYou entered\n"); for(i = 0; i < n; i++) printf("%d\n", data[i]); printf("Enter a Starting Value: "); scanf("%d", &start); printf("Enter a Stopping Value: "); scanf("%d", &stop); }



LinkBack URL
About LinkBacks



