C++ struct Updates balance in a structure
#include <iostream> using namespace std; #include <iomanip.h> struct customer_rec { char cust_name[25]; double balance; float dis_rate; } ;/*from www . j a v a 2 s .com*/ 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; }