How To Add Up An Amount Of Money In C++
C Exercises: Read an amount and break the amount into smallest possible number of banking company notes
C Bones Declarations and Expressions: Practice-16 with Solution
Write a C program to read an corporeality (integer value) and break the amount into smallest possible number of banking company notes.
Annotation: The possible banknotes are 100, 50, 20, 10, 5, 2 and 1.
C Lawmaking:
#include <stdio.h> int main() { int amt, full; printf("Input the amount: "); scanf("%d",&amt); total = (int)amt/100; printf("In that location are: "); printf("\n%d Note(southward) of 100.00\n", total); amt = amt-(total*100); total = (int)amt/l; printf("%d Note(s) of fifty.00\n", total); amt = amt-(total*50); full = (int)amt/20; printf("%d Note(south) of 20.00\northward", total); amt = amt-(total*20); full = (int)amt/x; printf("%d Note(south) of 10.00\n", total); amt = amt-(full*10); total = (int)amt/5; printf("%d Note(s) of 5.00\n", total); amt = amt-(total*5); full = (int)amt/2; printf("%d Notation(s) of 2.00\n", total); amt = amt-(total*ii); full = (int)amt/1; printf("%d Note(south) of 1.00\northward", total); return 0; } Sample Output:
Input the amount: 375 There are: 3 Note(s) of 100.00 1 Annotation(due south) of 50.00 1 Notation(southward) of 20.00 0 Note(s) of x.00 1 Note(s) of 5.00 0 Note(south) of two.00 0 Notation(s) of 1.00
Flowchart:
C Programming Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a C program to calculate the distance between the 2 points.
Next: Write a C program to catechumen a given integer (in seconds) to hours, minutes and seconds.
What is the difficulty level of this exercise?
Examination your Programming skills with w3resource'south quiz.
C Programming: Tips of the Day
Return a 'struct' from a function in C
Yous can return a structure from a function (or use the = operator) without whatever issues. It's a well-defined part of the linguistic communication. The merely problem with struct b = a is that you didn't provide a consummate type. struct MyObj b = a will piece of work just fine. Yous can pass structures to functions every bit well - a construction is exactly the same equally whatsoever congenital-in type for purposes of parameter passing, return values, and assignment.
Here's a simple demonstration plan that does all three - passes a structure as a parameter, returns a construction from a function, and uses structures in assignment statements:
#include <stdio.h> struct a { int i; }; struct a f(struct a 10) { struct a r = x; render r; } int principal(void) { struct a ten = { 12 }; struct a y = f(x); printf("%d\n", y.i); return 0; } The next example is pretty much exactly the same, but uses the built-in int type for sit-in purposes. The two programs have the same behaviour with respect to pass-past-value for parameter passing, assignment, etc.:
#include <stdio.h> int f(int ten) { int r = x; return r; } int main(void) { int x = 12; int y = f(10); printf("%d\n", y); return 0; } Ref : https://flake.ly/3m0EsmI
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practise, Solution
- Java Regular Expression: Exercises, Exercise, Solution
- Scala Programming Exercises, Practise, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Bundle exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Packet Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Athwart - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework
Source: https://www.w3resource.com/c-programming-exercises/basic-declarations-and-expressions/c-programming-basic-exercises-16.php
Posted by: goffrinnaligge.blogspot.com

0 Response to "How To Add Up An Amount Of Money In C++"
Post a Comment