Brand new to programming other than Visual BASIC and HTML... is there a list of programs that's like half-required to download to start programming in C/C++ [and JAVA]?
I'm guessing this is for simple interest (i.e. you have to pay off the interest accrued each year) instead of compound interest.
Check how you are handling the interest. Some of the calculations don't look right to me around your monthly payment comment around line 30.
The function is doing something or it wouldn't retun any value.What is the value of the loan? $100
For how long will you have the loan? 5
What percentage is your APY? 10
198.709
198.709
198.709
198.709
198.709
#include <stdio.h>
#include <math.h>
int main()
{
printf("This program will accept a whole number and return it's factorial.\n Please enter a whole number: ");
int number;
scanf("%d", &number);
while (number % 1 != 0)
{
printf("This value is not a whole number. please type a whole number: ");
scanf("%d", &number);
}
int total = number;
int count;
for (count = number - 1; count > 0; count--);
{
total = total * count;
}
printf("The factorial of %d is %d.\n", number, total);
getchar();
return 0;
}
...
int number;
char input[250];
fgets(input, sizeof input, stdin);
while (sscanf(input,"%d",&number) != 1)
{
printf("This value is not a whole number. please type a whole number: ");
scanf("%s", &input);
sscanf(input, "%d", &number);
}
...
troncoso@TroncosoUbuntu:~/Documents$ ./fact
This program will accept a whole number and return it's factorial.
Please enter a whole number: 5.2
5! = 120.
troncoso@TroncosoUbuntu:~/Documents$
This is some sample output I get when I run your code:
The function is doing something or it wouldn't retun any value.
int intCheck(char value[])
{
int length = strlen(value);
int num, count;
printf("%d", length);
for (count = 0; count <= length; count++)
{
if (value[count] < 0 || value[count] > 9)
{ return 0; }
else
{ continue; }
return atoi(value);
}
int main(int argc, char *argv[])
{
int count;
char num[256];
int total = 1, hold = 0, add;
printf("Enter a value: ");
scanf("%c", num);
while (intCheck(num) == 0)
{
printf("Invalid input. Please enter a whole number: ");
scanf("%d", &num);
}
int main()
{
double number;
int count;
unsigned long total;
char input[256];
printf("This program will accept a whole number and return it's factorial.\nPlease enter a whole number: ");
scanf("%lf",&number);
while (number - (1 * trunc(number/1)) != 0)
{
printf("This value is not a whole number. please type a whole number: ");
scanf("%lf", &number);
int intCheck(char value[])
{
int length = strlen(value);
int count, num;
//printf("length: %d, value: %s\n", length, value);
for (count = 0; count < length; count++)
{
//printf("value[count]: %c, count: %d\n",value[count], count);
if (value[count] < 48 || value[count] > 57)
{ return 0; }
}
num = atoi(value);
return num;
}