0% found this document useful (0 votes)
19 views2 pages

C Programming Projects

The document contains a series of programming tasks in C that involve displaying patterns, calculating volumes, evaluating polynomials, handling monetary amounts, and managing loan balances. Each task includes code snippets that demonstrate the required functionality, such as using printf for output and scanf for user input. The tasks progress from simple output to more complex calculations involving user interaction and financial computations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

C Programming Projects

The document contains a series of programming tasks in C that involve displaying patterns, calculating volumes, evaluating polynomials, handling monetary amounts, and managing loan balances. Each task includes code snippets that demonstrate the required functionality, such as using printf for output and scanf for user input. The tasks progress from simple output to more complex calculations involving user interaction and financial computations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Write a program that uses printf to display the following picture on the
screen.
#include int main() { printf(" *\n"); printf(" ***\n"); printf(" *****\n");
printf("*******\n"); printf(" *****\n"); printf(" ***\n"); printf(" *\n"); return 0;
}

2. Write a program that computes the volume of a sphere with a 10-meter


radius.
#include #define PI 3.14159 int main() { float radius = 10.0f; float volume; volume
= (4.0f/3.0f) * PI * radius * radius * radius; printf("Volume of sphere with radius
10 = %.2f\n", volume); return 0; }

3. Modify the program of Project 2 so that it prompts the user to enter the
radius of the sphere.
#include #define PI 3.14159 int main() { float radius, volume; printf("Enter the
radius of the sphere: "); scanf("%f", &radius;); volume = (4.0f/3.0f) * PI * radius
* radius * radius; printf("Volume of sphere = %.2f\n", volume); return 0; }

4. Write a program that asks the user to enter a dollars-and-cents amount,


then displays the amount with 5% tax added.
#include int main() { float amount, total; printf("Enter an amount: "); scanf("%f",
&amount;); total = amount + (amount * 0.05f); printf("With tax added: $%.2f\n",
total); return 0; }

5. Write a program that asks the user to enter a value for x and then displays
the value of the polynomial 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.
#include int main() { float x, result; printf("Enter value of x: "); scanf("%f",
&x;); result = 3*x*x*x*x*x + 2*x*x*x*x - 5*x*x*x - x*x + 7*x - 6; printf("Value of
polynomial = %.2f\n", result); return 0; }

6. Modify the program of Project 5 so that the polynomial is evaluated using


Horner’s Rule.
#include int main() { float x, result; printf("Enter value of x: "); scanf("%f",
&x;); result = ((((3*x + 2)*x - 5)*x - 1)*x + 7)*x - 6; printf("Value of polynomial
(Horner's Rule) = %.2f\n", result); return 0; }

7. Write a program that asks the user to enter a U.S. dollar amount and then
shows how to pay that amount using the smallest number of $20, $10, $5,
and $1 bills.
#include int main() { int amount, twenties, tens, fives, ones; printf("Enter a
dollar amount: "); scanf("%d", &amount;); twenties = amount / 20; amount = amount %
20; tens = amount / 10; amount = amount % 10; fives = amount / 5; amount = amount %
5; ones = amount; printf("$20 bills: %d\n", twenties); printf("$10 bills: %d\n",
tens); printf("$5 bills: %d\n", fives); printf("$1 bills: %d\n", ones); return 0; }

8. Write a program that calculates the remaining balance on a loan after the
first, second, and third monthly payments.
#include int main() { float loan, rate, payment, monthly_rate; printf("Enter amount
of loan: "); scanf("%f", &loan;); printf("Enter interest rate: "); scanf("%f",
&rate;); printf("Enter monthly payment: "); scanf("%f", &payment;); monthly_rate =
(rate / 100.0f) / 12.0f; loan = loan - payment + loan * monthly_rate;
printf("Balance remaining after first payment: $%.2f\n", loan); loan = loan -
payment + loan * monthly_rate; printf("Balance remaining after second payment:
$%.2f\n", loan); loan = loan - payment + loan * monthly_rate; printf("Balance
remaining after third payment: $%.2f\n", loan); return 0; }

You might also like