# I need help!!!

 Jagan Dwarampudi · January 9, 2015 It's my 'C' code to find Simple and Compound Interest but it says ERROR. Please help me Boston. This is my code and it's not full.#include #include int main(){    int SI, CI, principal, amount, time, rate;    char decision;    printf("Calculate Your Simple or Compound Interest !!! \n\n");    printf("\nWhat is the Principal Amount? \n");    scanf(" %d", &principal);    printf("\nWhat is the Time Period? \n");    scanf(" %d", &time);    printf("\nWhat is the Rate of interest? \n");    scanf(" %d", &rate);    printf("\nWhich type of intrest? \n");    scanf(" %s", decision);    if( decision == simple ) {        SI = (principal * time * rate) / 100;        amount = SI + principal;        printf("\n Your SI is = Rs.%d \n", SI);        printf("\n Your total Amount is = Rs.%d \n", amount);    }    return 0;}

## Replies

- page 1

 Lazar Bulic · January 26, 2015 You spelling is wrong EOF != E0F Check your code! You just need #include c student · January 26, 2015 what do you mean it doesn't work?? Lazar Bulic · January 26, 2015 He wrote E0F using 0 (NULL) character instead of EOF with alphabet character O c student · January 26, 2015 i don't understand how that even happens... Lazar Bulic · January 26, 2015 To prevent more confusion he should remember what EOF stands for so he can't make mistake EOF = End Of Fileand for = STandarD Input Output = STandarD LIBrary c student · January 9, 2015 you have quite a few errors which need to be fixed...your floating point numbers are declared as integers, meaning they will round to the nearest integer.  any variable which may contain a floating point number has to be declared as float or double.  their respective conversion should be %f for float, or %lf for double.``double SI, amount, rate;``your string variable decision is of type char (one character).  it can be fixed by making it an array and then scanning it in:``char decision[10]; // 10 must include the null terminator as well as the string````fgets (decision, 9, stdin); // scanning it in with max 9 characters to prevent buffer overflows``when you compare strings, you cannot compare them directly as you have attempted.  try using strcmp() located in the string.h header file:``if (strcmp (decision, "simple") == 0) { /* your code here */ }`` Marek Ďurkovič · January 25, 2015 Hello guys, I just wanted a little help; I bought a book "C Programming language" and codes there dont work in Code::Blocks...It always finds some error and I don't know how to deal with that...Is it problem when it is ANSI C99? I don't know what to do, because I'm newbie, I searched Google a lot but I didn't find my answer. If you know what is wrong, I would appriciate help :-) Thank you. c student · January 26, 2015 i'm assuming that's k&r's book.  what errors are you getting? Marek Ďurkovič · January 26, 2015 Yeah, it's from Kerninghan and Ritchie...but anyways, for example: when I tried this code it written this error:``#include #include main(){int z;while ((z = getchar()) != E0F)    putchar(z);}``"control reaches end of non-void function". In the book, they write every code has been tried and it works, but for some reason my codes doesn't work...always some kind of error, even when my friends checked if I have some gramatic problem in it, they said it's good and with no errors, so I'm assuming that something is wrong in Code::Blocks. c student · January 26, 2015 you have a non-return type main.``int main () { /* your code here */ return 0;}``
• 1
• 2

## C

120,762 followers