im making a highest number program with counter and a multiplication program with array and im not sure where im going wrong, the highest number always comes out at 0, and in the multiplication the number always gets * by 12 (the ending number), thanks for any help on this problem! and sorry its a bit of a mess lol
Code:
#include "stdafx.h"
#include <stdlib.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int main ()
{
int choice = 0;
int multi = 0;
int x = 0;
int x1 = 0;
int x2 = 0;
int highest = 0;
int num1 = 0;
int num2 = 0;
int total = -1;
printf("Math Menu\n\n");
printf("\n1:Highest Number\n");
printf("2:Muliplication Table\n");
printf("\nPlease select (1 or 2):\t");
scanf("%c",&choice);
system ("cls");
switch (choice)
{
case '1':
printf("Highest Number Calc\n\n");
do{
printf("\nPlease Input a number or input -999 to finish\n");
int highest(int, int);
scanf("%d", &num1);
total = total + 1;
}while (num1 != -999);
printf("%d, is the highest number and there where %d, numbers inputed", highest, total);
break;
int highest(int num1, int num2);
{
if (num1 < num2)
return (num2);
if (num1 > num2)
return (num1);
}
case '2':
printf("Please Input a Number for your Multiplication Table: ");
scanf("%d", &x1);
int multiray[12];
for(x = 0;x < 13; x++)
multiray[x] = x;
(x2 = x*x1);
for(x = 0;x < 13; x++)
printf("%d x %d = %d\n", multiray[x], x1, x2);
break;
default:
printf("\nInvalid selection\n");
} // end switch
getch();
return 0;
}