output is wrong if i am putting value of principal=100, rate = 4, year=1 then simple interest will be 4

ABHISHEK KUMAR SINHA
#include <stdio.h>

int main()
{
  float principle;
  float rate;
  float year;
  float si = (principle*rate*year)/100;

  printf("what is the principal amount\n");
  scanf("%f", &principle);
  printf("what is the rate\n");
  scanf("%f", &rate);
  printf(" and for how many years\n");
  scanf("%f", &year);
  printf("Then si is %f", si);
  return 0;
}
what is the principal amount
100
what is the rate
4
and for how many years
1
Then si is -0.000000

I am getting simple interest as 0.00000 not 4 why?

balu

you need to calculate the simple interest after the principle, rate and year are populated

#include <stdio.h>

int main()
{
float principle;
float rate;
float year;
// float si = (principle*rate*year)/100; //wrong . you need to calculate after the principle, rate and year are populated
float si;
    printf("what is the principal amount\n");
    scanf("%f", &principle);
    printf("what is the rate\n");
    scanf("%f", &rate);
    printf(" and for how many years\n");
    scanf("%f", &year);
    si = (principle*rate*year)/100;
    printf("Then si is %f", si);
    return 0;

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I am getting wrong output in SelectionSort

Log4j is hanging my application what am I doing wrong?

HTML output tag putting on wrong line

In this code, Why am I getting wrong output only for input value of 4.2 while it is working well for other values?

Limit year value to be only 4 digits long

Calculating Simple Interest and output into tabular form

What am I doing wrong when signing my request? AWS SignatureV4 and PHP

Why am I getting alert of "Wrong login details." 4 times as I have 4 user in database

CS50 PSet4 - Blur Filter, I am getting black image as an output

Why am I getting this single output wrong?

Neo4j Cypher has ultra-restrictive pattern comprehension - or am I using it wrong?

Loan Interest Rate Returning Wrong Value?

What am I doing wrong with this simple click function?

How 30%4 output is 2 but if I write 30*4/100 output is 1

i am getting an error - Subquery returned more than 1 value. What is wrong with my query

Trying to understand PSR-4 autoloading through a console app. What am I doing wrong?

I need to convert the interest rate to a decimal value

What I am doing wrong with S3 PUT request using AWS Signature Version 4

Using a Loop in PHP to output the month-to-month interest that the user earns based on the principal and interest rate

simple javascript addition, where am I going wrong?

i am trying to parse json with swift 4, please tell me what is wrong in it?

I am trying to center a text with 4 lines, I am looking for a simple solution. The end result is in the image below

Breaking my code by putting Dictionaries in a list. What am I doing wrong?

Why am I getting the wrong output for this program?

What am I doing wrong in this for loop for Web Scraping with bs4?

What am i doing wrong in creating and calling this simple class function?

Write a program to find the difference between Simple Interest and Compound Interest when Principal, Rate and Time are given

I am seeing 4th character in output after using substr(0,3) on input characters

What am I doing wrong in this simple Python code?