8.Modify the program - 7 to fill the unused spaces with @ signs.

 /*J_4_P_8

Modify the program 7  to fill the unused spaces with @ signs.

*/

#include <iostream.h>

#include <iomanip.h>

#include <string.h>

#include <conio.h>


class item

{

        char name[40];

        int code;

        float cost;


public:

        void get_data(char *n, int c, float co)

        {

                strcpy(name, n);

code = c;

cost = co;

}

void display();

};


void item::display()

{

cout.precision(2);

cout << setfill('@');

cout.setf(ios::fixed,ios::floatfield);

cout.setf(ios::showpoint);

cout.setf(ios::left, ios::adjustfield);

cout << setw(40) << name << code;

cout.setf(ios::right, ios::adjustfield);

cout << setw(15) << cost << endl;

}


void main()

{

clrscr();

item a[5];

cout << setfill('@');

a[0].get_data("Tarbo C++", 1001, 250.95);

a[1].get_data("C primer", 905, 95.7);

a[2].get_data("algorithm", 1111, 120.5);

a[3].get_data("principle of electronics", 2220, 150.85);

a[4].get_data("solution of balagurusamy", 6666, 145.00);

cout << setw(10) << "name" << setw(34) << "code" << setw(15) << "cost" << endl;

for (int i = 0; i < 60; i++)

cout << "=";

cout << endl;

for (i = 0; i < 5; i++)

a[i].display();

getch();

}


Comments

Popular posts from this blog

7.Write a program to read a list containing item name, item code and cost interactively and produce a three-column output as shown below. NAME CODE COST Turbo C++ 1001 250.95 C Primer 905 95.70 ------------- ------- ---------- ------------- ------- ---------- Note that the name and code are left-justified and the cost is right-justified with a precision of two digits. Trailing zeros are shown.

Quetion 6 : Consider the "in-order-issue/in-order-completion" execution sequence shown in f In Figure Decode OWE Execute 12 12 12 14 16 13 16 13 15 15 16 Write 024/06/02 11 3 4 11 12 13 13 N 15 16 a. Identify the most likely reason why I could not enter the execute fourth cycle. stage until the [2] b. Will "in-order issue/out-of-order completion" or "out-of-order issue/out-of-order completion" fix this? If so, which? Explain

8.odd and even number using if else.