I need help!!!

+2 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 <stdio.h>
#include <stdlib.h>

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? <Answer in years> \n");
    scanf(" %d", &time);

    printf("\nWhat is the Rate of interest? \n");
    scanf(" %d", &rate);

    printf("\nWhich type of intrest? <simple/compound> \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;

Post a Reply


- page 1
Oldest  Newest  Rating
0 Lazar Bulic · January 26, 2015
To prevent more confusion he should remember what EOF stands for so he can't make mistake :D

EOF = End Of File

and for

<stdio.h> = STandarD Input Output
<stdlib.h> = STandarD LIBrary 
0 c student · January 26, 2015
i don't understand how that even happens...
0 Lazar Bulic · January 26, 2015
He wrote E0F using 0 (NULL) character instead of EOF with alphabet character O
0 c student · January 26, 2015
what do you mean it doesn't work??
0 Lazar Bulic · January 26, 2015
You spelling is wrong EOF != E0F Check your code! 
You just need
0 Marek Ďurkovič · January 26, 2015
Man it still doesn't work, i don't know about this....Can you give me another program where I can code and compilate it? Something that works with ANSI C99...
0 c student · January 26, 2015
eof is represented by -1 or you can:

#define EOF -1
0 Marek Ďurkovič · January 26, 2015
0 c student · January 26, 2015
you have a non-return type main.

int main () {
/* your code here */
return 0;
0 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 <stdio.h>
#include <stdlib.h>
int z;

while ((z = getchar()) != E0F)


"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.
  • 1
  • 2



One of the most popular languages of all time.

Bucky Roberts Administrator