dragon_lover50
2013-11-13 10:07:56 UTC
Sadly however I'm not sure how to do this with functions (Figured an array would be simpler but apparently the point of the assignment is to get us to work with functions). I missed a few classes during functions, i'm trying to learn from the book but its a little difficult.
My jumbled mess of code is this (yes, I know most of it probably doesn't even make sense, i'm terrible at this). It compiled but I cant seem to get it to call the function with the question in it after I input the proper digit... It needs anywhere between 4 or 5 questions but I cant even get one to work so far. It needs a lot of help. :/
Thank you!!
// Libraries
#include
#include
// Function Prototype
int funcnum1(int num1);
int funcnum2(int num2);
int funcnum3(int num3);
int funcnum4(int num4);
int funcnum5(int num5);
// Global Variables
int num1 = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int num5 = 0;
int main()
{
// Local main variables
int num1 = 1; // for use with current and additional future functions
int num2 = 2;
int num3 = 3;
int num4 = 4;
int num5 = 5;
// main Process
printf("\nPlease pick a topic:");
printf("\n1: History\n");
printf("\n2: Science\n");
printf("\n3: Health\n");
printf("\n4: Astronomy\n");
printf("\n5: Geology\n");
scanf("%d", &num1);
scanf("%d", &num2);
scanf("%d", &num3);
scanf("%d", &num4);
scanf("%d", &num5);
funcnum1(num1);
printf("\nYou are back in main.\n");
printf("The sum passed back to main is %d\n", num1);
funcnum2(num2);
printf("\nPlease pick another topic\n");
printf("The sum passed back to main is %d\n", num2);
system ("pause");
return 0;
}
int funcnum1(int num1)
{
int a1 = 1;
int a2 = 2;
int a3 = 3;
if (num1=1)
printf("\nIn what year did Napolean die?");
printf("\n1:1800\n");
printf("\n2:1777\n");
printf("\n3:1821\n");
scanf("%d", &a1);
scanf("%d", &a2);
scanf("%d", &a3);
if ( num1 = a1 )
printf( "You are correct!" );
return num1;
}
int funcnum2(int num2)
{
int input=0;
printf("\n Another question goes here.\n");
scanf("%d",&input);
return num2;
}