1. Write a program to calculate the simple interest by accepting the Principal amount ,rate per annum and time.(SI = pnr/100) 2. Write a program to accept the profit and cost price of a product and find the profit percentage.
Answers
Answer:
Explanation:
#include <stdio.h>
int main()
{
float principle, rate, sinterest;
int time;
printf("Enter Principle Amount, Rate %% per Annum and Time\n");
scanf ("%f %f %d", &principle, &rate, &time);
sinterest = (principle * rate * time)/ 100.0;
printf ("Principle Amount = %5.2f\n", principle);
printf ("Rate %% per Annum = %5.2f%\n", rate);
printf ("Time = %d years\n", time);
printf ("Simple Interest = %5.2f\n", sinterest);
}
2
// C++ implementation to find Cost price
#include <iostream>
using namespace std;
// Function to calculate cost price with profit
float CPwithProfit(int sellingPrice, int profit)
{
float costPrice;
// required formula to calculate CP with profit
costPrice = (sellingPrice * 100.0) / (100 + profit);
return costPrice;
}
// Function to calculate cost price with loss
float CPwithLoss(int sellingPrice, int loss)
{
float costPrice;
// required formula to calculate CP with loss
costPrice = (sellingPrice * 100.0) / (100 - loss);
return costPrice;
}
// Driver code
int main()
{
int SP, profit, loss;
SP = 1020;
profit = 20;
cout << "Cost Price = " << CPwithProfit(SP, profit) << endl;
SP = 900;
loss = 10;
cout << "Cost Price = " << CPwithLoss(SP, loss) << endl;
SP = 42039;
profit = 8;
cout << "Cost Price = " << CPwithProfit(SP, profit) << endl;
return 0;
}