Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:49:32+00:00 2026-06-02T10:49:32+00:00

I would like to have a clean formatted output, but the result is not

  • 0

I would like to have a clean formatted output, but the result is not exactly as clean as I want. Below is my function which shows the output, followed by the output. I am using Dev-C++. Thank you for your help.

void student::show(string name, int age, double GPA)
{
  cout<<name<<setw(7) <<age<<setw(7) <<GPA <<setw(7) <<endl;

}



******************output*******************************************



Timaya     24   2.65
 albert     29   2.43
zamounda     27   3.94
charles     26   2.78
 moumou     33   2.39
francois     24   3.07
   john     20   2.59
   papa     21   2.67
   peti     29   3.65
francoise     26   3.76
  iness     28   2.65
  elise     35   2.76
------------------------------------
-------------------------------------
GPA of the class:2.94
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:49:34+00:00Added an answer on June 2, 2026 at 10:49 am

    Since setw sets the width for the next output value, not for the previous one, you should move setw calls to before the items being formatted:

    cout << setw(20) << name << setw(7) << age << setw(7) << GPA << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a clean recursive function to generate the same result
I have a clean Eclipse Java SDK. I would like to make it suitable
I would like to have a field which is updated on every change(insertion, modification),
I would like to have a regular expression which clears an HTML field when
I have one Date column, formatted '17/03/2012'. I would like to be able select
I would like to have a clean up of my Firefox favorites as its
I would like to have a clean C# class that authenticates from Active Directory.
I would like to have a nice clean LINQ code that can get an
I would like to have Ctrl-l for clear in my Bash. How can you
So in my project i would like have a nice treeview that has images.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.