Hi there, I get stuck when I think I understand my classes every time and it never fails, I am getting REAL tired of it. Maybe someone can fill in my teachers BLANKS!
This code isn't working. All I get when I run it is 0's
Code:
#include <stdio.h>
#include <string.h>
/**************/
/*Brandi Savoy*/
/*asgn06.c */
/*Monday Night*/
/**************/
#define PROGRAMMER "Brandi Savoy"
void name();
void eoj();
int readnum(int x);
int square(int x);
int cube(int x);
int add(int x, int y);
int subt(int x, int y);
void main()
{
int num1, num2, sqrt1, sqrt2, cub1, cub2, tot, diff;
readnum(num1);
readnum(num2);
sqrt1 = square(num1);
sqrt2 = square(num2);
cub1 = cube(num1);
cub2 = cube(num2);
tot = add(num1, num2);
diff = subt(num1, num2);
name();
printf("\nThe square of num1 is:\t\t\t\t\t %d\n\n", sqrt1);
printf("The square of num2 is:\t\t\t\t\t %d\n\n", sqrt2);
printf("The cube of num1 is:\t\t\t\t\t %d\n\n", cub1);
printf("The cube of num2 is:\t\t\t\t\t %d\n\n", cub2);
printf("The total of num1 and num2 is:\t\t\t\t %d\n\n", tot);
printf("The difference between num1 and num2 is:\t\t %d\n\n", diff);
printf("Press ENTER to continue");
fflush(stdin);
getchar();
}
int readnum(int x)
{
int rn;
name();
printf("key in an integer:");
fflush(stdin);
scanf("%d", &rn);
return rn;
}
int square(int x)
{
return x * x;
}
int cube(int x)
{
return x * x * x;
}
int add(int x, int y)
{
int ad = x + y;
return ad;
}
int subt(int x, int y)
{
int sb = x - y;
return sb;
}
void name()
{
system("clear");
printf("%s\n\n\n", PROGRAMMER);
}
void eoj()
{
name();
printf("EXECUTION COMPLETED... Press ENTER to contiune.\n");
getchar();
}
Thanks in advance