Question
IMPORTANT: So I have a problem with my code. IT WORKS OKAY, but I need help with possibly debugging or reconstructing. When I originally constructed
IMPORTANT:
So I have a problem with my code. IT WORKS OKAY, but I need help with possibly debugging or reconstructing. When I originally constructed my code, I used a different compiler (one I am comfortable with). Now when I run this through the DEV C++ compiler (the one I was supposed to use) it says that the oddValues function has too many arguments (I'll attach a picture of the errors I am seeing). How do I go around this? I want to to my function to be able to keep its arguments, if possible. I guess overall, I just need help with the debugging so that it runs in DEV C++ without running into these issues. I am fairly new to coding so I am unsure if I am doing this correctly, but I constructed this in a way that made sense to me be based off the assignment requirements. Please let me know what I am doing wrong, thank you!
Assignment Requirements:
-Write 3 Functions:
------Function 1: Ask user for age and displays whether user is a teenager or not depending on response
------Function 2: Generates random number and print's programmer's name x (random generated number) amount of times. RETURN random value back to main()
-----Function 3: Takes randomly generated value from Function 2 and outputs only the ODD values from 1 to x (randomly generated number).
Function main() must call all 3 Functions.
MY SOLUTION:
#include
#include
#include
void srand(unsigned int seed);
void userAge();
int progName();
void oddValues();
int main() {
userAge();
int aNum = progName();
oddValues(aNum);
}
void userAge(){
int results;
printf("How old are you? ");
scanf("%d", &results);
if (results = 20){
printf("Since you are %d, you are not a teenager.", results);
} else {
printf("Since you are %d, you are a teenager.", results);
}
}
int progName(){
int randomNum; //declaring local variable randomNum.
int i; // declaring local variable i.
srand(time(NULL));
randomNum = rand()%1000;
printf(" ");
printf(" I have generated the random number: %d ", randomNum);
for ( i = 1; i
printf(" %d.Rheeza", i);
return randomNum;
}
void oddValues(aNum){
int i; /
printf(" ");
printf(" Here are the odd numbers from 1 to %d: ", aNum);
for ( i = 1; i
if(i%2==0){ // checking for odds.
}
else
printf(" %d is odd", i);
}
}
ERRORS I AM SEEING WHEN I RUN THIS THROUGH DEV C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started