Dollars & Cents
Write a C++ program to add two dollars and cents.
INPUT & OUTPUT FORMAT:
Input consists of 4 integers. First two inputs correspond to the value of the first dollar and cent. Next two inputs correspond to the value of the second dollar and cent. Output should print the sum of dollar and cent.
SAMPLE INPUT:
30
10
140
99
SAMPLE OUTPUT:
171
9
Answers
Answer:
Solved by Expert Tutors
Subscribe to view the full answerSubscribe to unlock
Ask a new question
Question
Write a C++ program to add two dollars and cents. INPUT & OUTPUT FORMAT:
Input consists of 4 integers. First two inputs correspond to the value of the first dollar and cent. Next two inputs correspond to the value of the second dollar and cent. Output should print the sum of dollar and cent.
SAMPLE INPUT:
30
10
140
99
SAMPLE OUTPUT:
171
9
Step-by-step answer
amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit a
Answer:
#include<iostream>
using namespace std;
int main()
{
int d1,c1,d2,c2;
cin>>d1>>c1>>d2>>c2;
int D=d1+d2;
int C=c1+c2;
while(C>100)
{
D=D+(C/100);
C=C%100;
break;
};
cout<<D<<"\n"<<C;
return 0;
}
Explanation: