Computer >> 컴퓨터 >  >> 프로그램 작성 >> C 프로그래밍

할당 연산자를 사용하여 세금으로 금액을 계산하는 C 프로그램

<시간/>

문제

금액을 달러로 입력하고 18%를 세금으로 추가하여 금액을 표시하는 C 프로그램을 작성하십시오.

해결책

식당 직원이 고객의 모든 청구서에 18%의 세금을 추가한다고 가정해 보겠습니다.

세금 계산에 적용되는 논리는 -

값=(돈 + (돈 * 0.18));

금액에 18%를 곱한 금액을 합산하면 레스토랑 직원이 고객으로부터 세금과 함께 금액을 받을 수 있습니다.

예시

#include<stdio.h>
int main(){
   float money,value;
   printf("enter the money with dollar symbol:");
   scanf("%f",&money);
   value=(money + (money * 0.18));
   printf("amount after adding tax= %f\n",value);
   return 0;
}

출력

enter the money with dollar symbol:250$
amount after adding tax= 295.000000

예시

백분율을 변경하여 동일한 프로그램을 고려합시다 -

#include<stdio.h>
int main(){
   float money,value;
   printf("enter the money with dollar symbol:");
   scanf("%f",&money);
   value=(money + (money * 0.20));
   printf("amount after adding tax= %f\n",value);
   return 0;
}

출력

enter the money with dollar symbol:250$
amount after adding tax= 300.000000