Updates balance in a structure. - C++ Data Type

C++ examples for Data Type:struct

Description

Updates balance in a structure.

Demo Code

#include <iostream>
using namespace std;
#include <iomanip>
struct customer_rec
{
   char cust_name[25];
   double balance;
   float dis_rate;
} ;// w  w w.  j  av a2 s .  c o m
void main()
{
   struct customer_rec customer = {"Steve Thompson", 431.23, .25};
   cout << "Before the update, " << customer.cust_name;
   cout << " has a balance of $" << setprecision(2) << customer.balance << "\n";

   customer.balance *= (1.0-customer.dis_rate);
   cout << "After the update, " << customer.cust_name;
   cout << " has a balance of $" << customer.balance << "\n";
   return;
}

Result


Related Tutorials