Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 231 Weeks Ago, 3 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
#include <stdio.h>
Â
int main ()
{
/* variable definition: */
int intValue, menuSelect,Results;
double dblValue, dblResults;
intValue = 1;
// While a positive number
while (intValue > 0)
{
printf ("Enter a positive Integern: ");
scanf("%d", &intValue);
if (intValue > 0)
{
dblValue = intValue;
printf ("Enter 1 to calculate Square, 2 to Calculate Cube, 3 to Shrink n: ");
scanf("%d", &menuSelect);
if (menuSelect == 1)
{
// Call the Square Function
Results = Square(intValue);
printf("Square of %d is %dn",intValue,Results);
}
else if (menuSelect == 2)
{
// Call the Cube function
Results = Cube(intValue);
printf("Cube of %d is %dn",intValue,Results);
}
else if (menuSelect == 3)
{
// Call the Shrink function
dblResults = Shrink(dblValue);
printf("Shrink of %d is %fn",intValue,dblResults);
}
else
printf("Invalid menu item, only 1, 2 or 3 is acceptedn");
}
}
return 0;
}
/* function returning the Square of a number */
int Square(int value)
{ return value*value;
}
/* function returning the Cube of a number */
int Cube(int value)
{ return value*value*value;
}
// function returning the Shrink of a number
double Shrink(double value)
{ return value/2;
}
Â
Â
I got the above code from a pdf from this site and it works great in the pictures, but won't run even when i copy and paste it over. I have attached the errors I'm getting from the Ideone.com site so you can help me fix it. I want to understand what is happening, not just be given the right answers.
Attachments:----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly