C++ examples for Data Type:struct
Updates balance in a structure.
#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; }