I'm using Borland's c++ compiler. I'm trying to develop a program to compute a GPA of 5 students in a class. My variables are RegNo, StuName, CosTitle, and CosScore. I want to display the result in a tabular form but the whole thing seems impossible for me.

Please could you help me out?  

The trick to doing this in DOS is setting the output field length. Most of the time when you print out a number, the length of the number gets printed and the program moves on. However, you can force the program to set with width of the output field (i.e. when you print the number) so that it will always be the same size, such as 10 characters. By doing this, you can print the student's name on a new line, then print out the values of the three variables, and each output field can be 10 characters long. Then you move onto the next line, print out the student's name, and print the variables again. I haven't done this in a long time, but I know you have to use setwidthw(# of characters) before the output field. There is some more coding to it then this, but like I said it has been too long. :( I hope this helps though and gets you pointed in the right direction.

Best Of Luck,


All Answers

Answers by Expert:

Ask Experts


Alan F.


Having problems with any basic or intermediate parts of C++? I can answer those questions for you using simple English. I have been taking C++ in school for a couple years, so I still remember what it was like to be a beginner (especially with C++, which is a difficult language)!


I have a C++ web page that discuses the basics of C++. The address is: http://www.afweb.net/complang/

©2017 About.com. All rights reserved.