Calculate No. of Notes: Denominations 10, 50, and 100 in Given Amount

  • Thread starter Thread starter mkbh_10
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on a C program designed to calculate the number of notes of denominations 10, 50, and 100 for a given amount. The user encounters an error with the scanf function, specifically in the line where the amount is read. The correct syntax for the scanf function requires the address operator '&' before the variable 'p', which is missing in the user's code. The corrected line should read 'scanf("%d", &p);' to properly store the input value.

PREREQUISITES
  • Basic understanding of C programming syntax
  • Familiarity with input/output functions in C, specifically scanf
  • Knowledge of arithmetic operations and variable assignments
  • Experience with debugging common programming errors
NEXT STEPS
  • Review C programming input/output functions, focusing on scanf and printf
  • Learn about debugging techniques in C to identify and fix runtime errors
  • Explore arithmetic operations in C to understand how to manipulate variables
  • Study best practices for variable declaration and initialization in C
USEFUL FOR

Beginner C programmers, students learning programming fundamentals, and anyone interested in debugging C code related to financial calculations.

mkbh_10
Messages
217
Reaction score
0
I am using this program to calculate the no. of notes of denomination 10,50&100 in a given amount but i am getting error as soon as i enter the amount ?

#include<stdio.h>
#include<conio.h>

main ()
{
int a,b,c,a1,b1,c1;
int p;

printf ("enter the amount to be withdrawn Rs p \n");

scanf(" %d",p);

a=10;
b=50;
c=100;


a1= p-(b+c)/a;
b1= p-(a+c)/b;
c1= p-(a+b)/c;



printf("the number of notes of type a1 = %d",a1);
printf("\n");
printf("the number of notes of type b1 = %d",b1);
printf("\n");
printf("the number of notes of type c1 = %d",c1);
getch();

}


What is the error , it compiles the prog successfully but after that shows error
 
Technology news on Phys.org
scanf("%d",&p);
 

Similar threads

Replies
14
Views
3K
Replies
7
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
47
Views
5K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K