๐Ÿ”’ Closed C Programming Problem

Status
Not open for further replies.
hello po nakuha ko na po may extrang parenthesis lang sa ((x-(twenty20*20))-(ten10*10))/5
Oh nice may na miss lang pala. So ipractice mo mag code ng dahandahan para madali mo ma debug ang mga ganitong simpleng error. Like itest mo muna unang formula bago mo ipasok yung pangalawa and so on.

Like kung gagawa ka ng kite stArt ka muna sa skeleton.
 
Pagdating sa printf statement, yung compiler substitutes yung macros mo (#define's) sa "%d" format specifier. Akala mo yung input galing sa scanf ang ipapalit dahil pareho silang x variable. Mali. Bale ang nangyayari x/20 pa din.

Rather than making them macros, bakit di mo nalang gawing functions with return values?
 
Pagdating sa printf statement, yung compiler substitutes yung macros mo (#define's) sa "%d" format specifier. Akala mo yung input galing sa scanf ang ipapalit dahil pareho silang x variable. Mali. Bale ang nangyayari x/20 pa din.

Rather than making them macros, bakit di mo nalang gawing functions with return values?
naayos ko na po sa int, dapat pala ang mga values ay kung ano lang iinput wag doble doble. tas may extrang semicolon pa din po
 
C:
#include <stdio.h>
#define twenty20 x/20
#define ten10 (x-(twenty20*20))/10
#define five5 ((x-(twenty20*20))-(ten10*10))/5
#define one1 ((x-(twenty20*20))-(ten10*10))-(five5*5)/1
int main(void)
{
    int x;//twenty20, ten10, five5, one1;
    printf("Please enter your dollar amount so we can divide it by $20, $10, $5, and $1 \n");
    scanf("%d", &x);
    printf("This is your distribution of dollars you put in: %d \n", twenty20);
    printf("This is your distribution of dollars you put in: %d \n", ten10);
    printf("This is your distribution of dollars you put in: %d \n", five5);
    printf("This is your distribution of dollars you put in: %d \n", one1);
    return 0;
}

tinry ko yan. gumana naman
 
Status
Not open for further replies.

About this Thread

  • 24
    Replies
  • 1K
    Views
  • 11
    Participants
Last reply from:
fazz12

Online now

Members online
1,010
Guests online
1,026
Total visitors
2,036

Forum statistics

Threads
2,275,386
Posts
28,962,708
Members
1,232,737
Latest member
beverly28
Back
Top