This is my code C++ for my assignment. Please help me to convert it to C code. Thank you!
#include <iostream>
using namespace std;
float f1(float a){
float s;
if (a<250)
s=a*0.11;
else
s=250*0.11+(a-250)*0.17;
return s;
& }
float f2(float a){
& return f1(a)*1.1;
& }
int main(void)
{
float a;
cout<<"enter the number of kilowatt hours consumed : ";
cin>>a;
cout<<"total amount: "<<f2(a)<<endl;
system ("PAUSE");
}
See more: C
Add two polynomials
Given two polynomials A and B, write a program that adds the given two polynomials A and B
Output
Print the addition of polynomials A and B.
If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.Explanation
Sample Input 1:-
6
0 -20
1 23
2 30
3 19
4 6
5 17
9
0 -100
5 -89
6 -20
7 -1
1 20
2 4
3 99
4 -45
8 12
Sample Output 1:-
12x^8 - x^7 - 20x^6 - 72x^5 - 39x^4 + 118x^3 + 34x^2 + 43x - 120
Note :- Need Space between - and + operators
Sample Input 2:-
4
0 5
1 0
2 10
3 6
3
0 1
1 2
2 4
Sample Output 2:-
6x^3 + 14x^2 + 2x + 6
Note:- Need Space between - and + operators
Sample Input 3:-
5
0 -2
3 6
4 7
1 -3
2 -1
5
0 1
1 2
2 -4
3 3
4 5
Sample Output 3:-
12x^4 + 9x^3 - 5x^2 - x - 1
Note:- Need Space between - and + operators
Write
a program that declares two classes. The parent class is called Simple that has two data members’ num1 and num2 to store two numbers. It also has four member functions.
·
The add() function adds two numbers and displays the result.
·
The sub() function subtracts two numbers and displays the result.
·
The mul() function multiplies two numbers and displays the result.
The div() function divides two numbers
and displays the result.
The child class is called Complex that overrides all four functions. Each function
in the child class checks the value of data members. It calls the corresponding
member function in the parent class if the values are greater than 0. Otherwise it displays error message.
Consider a computer with the following characteristics: total of 256Mbyte of main memory; block size of 8 bytes; and cache size of 128 Kbytes.
i. Design a direct-mapping address structure.
ii. Design an associative-mapping address structure.
iii. Design a two-way set-associative-mapping address structure.
iv. For the main memory addresses of F0010ABH, F012356H, and 00CABBEH, give the corresponding tag, cache line address, and word offsets for a direct-mapped cache.
v. For the main memory addresses of F0010ABH, F012356H, and 00CABBEH, give the corresponding tag and offset values for a fully-associative cache.
vi. For the main memory addresses of F0010ABH, F012356H, and 00CABBEH, give the corresponding tag, cache set, and word offset values for a two-way set-associative cache.
Suppose that the input is:
38 35 71 14 -1
What is the output of the following code? Assume all variables are properly declared.
sum = console.nextInt();
num = console.nextInt();
for (j = 1; j <= 3; j++)
{
num = console.nextInt();
sum = sum + num;
}
System.out.println("Sum = " + sum);
Final Value with Appreciation
Given principal amount
principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.
Quick Tip
The formula to calculate the final value with appreciation is,
finalValue = principal * (1 + time * appreciation / 100)
the fibonacci sequence is a set of numbers that starts with a zero, followed by a one and proceeds based on the rule that each number( called a Fibonacci number) is equal to the sum of the first two numbers. the Fibonacci sequence is denoted by F(n), where n is the first term in the sequence. the following equation is obtained when n= 0, where the first two terms are 0 and 1 , and each subsequent number is the sum of the previous two numbers
using counter-loop structure, write a program segment to accept the weight of 100 students. the program counts and displays the number of students whose weight is more than 75 kilograms
Area of Largest Rectangle in Histogram
Given an list of integer
The input will be a single line containing space-separated integers, denoting the heights of the bars.
The output should be a single line containing the area of the largest rectangle in the rectangle.
For example, if the given list of numbers are
2 1 5 6 2 3 , when they are drawn adjacent to each other according to their heights, the histogram will be like The largest rectangle can be found in between 5 and 6, which is 10.
Sample Input 1
2 1 5 6 2 3
Sample Output 1
10
Sample Input 2
65 87 96 31 32 86 57 69 20 42
Sample Output 2
248
Parking lot charges rs.30.00as a minimum fee to park a vehicle for upto 3hours.an additional charge of re 5.00 per hour will be added if exceed three hours.for 24hours the parking fee are 80.00 write a program to define an array and read the vehicle registration bumber,and hiurs parked for each customer and calculate the parking for n customer and display the output