First As stated I am not looking for answers I would just like some pointers on why it is not working like I think it should almost some "Mentorship". Thanks in advance.
Assignment:
Write a main function to input 20 integers in the range of 1 to 6. Write a function to count the number of times the numbers 2 and 5 occur. The function should declare static variables count2 and count5. Check the data validity in the main function.
My Issue:
My issues are
I'm not printing the counted numbers cont2 or cont5 when the program ends
and I tested the funccountnum and it doesnt seem to get to the else if(Num = 5) part.
I am using Microsoft Visual Studio 2010 express.
Code:
#include<stdio.h>
#include<iostream>
void funccountnum(int, int, int);
int main(){
int Num = 0;
int cont2 = 0, cont5 = 0;
int p;
for (p = 0; p < 21; p++){
printf("Enter a number between 1 and 6: ");
scanf("%d", &Num);
if (Num <= 6){
funccountnum(Num, cont2, cont5);
}
elseif(Num >= 7){
printf("Please input a valid number!\n");
}
}
printf("\n");
printf("Times 2 was selected\tTimes 5 was selected\n\n");
printf("%d\t%d\n\n", cont2, cont5);
system("PAUSE");
return 0;
}
void funccountnum(int Num, int cont2, int cont5){
staticint count2 = 0;
staticint count5 = 0;
if(Num = 2){
count2++;
}
elseif(Num = 5){
count5++;
}
cont2 = count2;
cont5 = count5;
return;
}