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 6601419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:45:00+00:00 2026-05-25T18:45:00+00:00

Problem I am making a celsius to fahrenheit converter and vice versa. All of

  • 0

Problem

I am making a celsius to fahrenheit converter and vice versa.

All of my code works perfect but I am not sure how to make the chart the teacher wants.

The output are of 0 to 100 degrees celsius and 32 to 212 degrees fahrenheit.

Here is my code:

#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;
using std::setw;

int i;

int ftemp;
int ctemp;

int farToC(int a, int b);
int celToF(int a, int b);

int main (int argc, const char * argv[])
{
cout << "Farenheit equivalents of Celsius temperatures: " << endl;

for(i = 0; i < 5; i++)
{
    cout << "Celsius Farenheit ";
}
cout << endl;

for(i = 0; i < 101; i++)
{
    cout << setw(7) << i << setw(8) << " " << celToF(i, ftemp)<< endl;
}
cout << endl;

cout << "Celsius equivalents of Farenheit temperatures: " << endl;
for(i = 0; i < 5; i++)
{
    cout << "Fahrenheit Celsius ";
}
cout << endl;

for(i = 32; i < 213; i++)
{
    cout << setw(10) << i << setw(7) << " " << farToC(i, ctemp)<< endl;
}
cout << endl;
}

int farToC(int a, int b)
{
b = (a - 32) * 5 / 9;
return b;
}

int celToF(int a, int b)
{
b = (a * 9/5) + 32;
return b;
}

Here is my output:

Farenheit equivalents of Celsius temperatures: 
Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit 
      0        32
      1        33
      2        35
      3        37
      4        39
      5        41
      6        42
      7        44
      8        46
      9        48
     10        50 
         ...


Celsius equivalents of Farenheit temperatures: 
Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius 
        32       0
        33       0
        34       1
        35       1
        36       2
        37       2
        38       3
        39       3
        40       4
        41       5
        42       5
            ...

Here is what my teacher wants:
celsius from 0 to 100 degrees.

Farenheit equivalents of Celsius temperatures: 
Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit 
      0        32      25        77      50       122
      1        33      26        78      51       123
      2        35      27        80      52       125
      3        37      28        82      53       127
      4        39      29        84      54       129
      5        41      30        86      55       131
      6        42      31        87      56       132
      7        44      32        89      57       134
      8        46      33        91      58       136
      9        48      34        93      59       138
     10        50      35        95      60       140
    ...

And the same for fahrenheit but from 32 to 212 degrees…

I know how to align the numbers with the words using setw() but I am not sure how to do columns.

Any ideas or suggestions would be appreciated!


Solution

Thanks everyone for your help. I figured it out after thinking for a minutes!

#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;
using std::setw;

int i;
int k;

int ftemp;
int ctemp;

int farToC(int a, int b);
int celToF(int a, int b);

int main (int argc, const char * argv[])
{
cout << "Farenheit equivalents of Celsius temperatures: " << endl;

for(i = 0; i < 5; i++)
{
    cout << "Celsius Farenheit ";
}

cout << endl;

for(k = 0; k < 25; k++)
{
    for(i = 0; i < 101; i+= 25)
    {
        cout << setw(7) << i+k << setw(10) << celToF(i+k, ftemp) << " " << setw(10);
    }
    cout<< endl;
}

cout << endl;

cout << "Celsius equivalents of Farenheit temperatures: " << endl;

for(i = 0; i < 5; i++)
{
    cout << "Fahrenheit Celsius ";
}

cout << endl;

for(k = 0; k < 45; k++)
{
    for(i = 32; i < 213; i += 45)
    {
        cout << setw(10) << i+k << setw(8) << farToC(i+k, ctemp) << " "  << setw(12);
    }
    cout << endl;
}

cout << endl;
}

int farToC(int a, int b)
{
b = (a - 32) * 5 / 9;
return b;
}

int celToF(int a, int b)
{
b = (a * 9/5) + 32;
return b;
}

My output:

Farenheit equivalents of Celsius temperatures: 
Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit 
      0        32      25        77      50       122      75       167     100       212 
      1        33      26        78      51       123      76       168     101       213 
      2        35      27        80      52       125      77       170     102       215 
      3        37      28        82      53       127      78       172     103       217 
      4        39      29        84      54       129      79       174     104       219 
      5        41      30        86      55       131      80       176     105       221 
      6        42      31        87      56       132      81       177     106       222 
      7        44      32        89      57       134      82       179     107       224 
      8        46      33        91      58       136      83       181     108       226 
      9        48      34        93      59       138      84       183     109       228 
     10        50      35        95      60       140      85       185     110       230 
 ...

Celsius equivalents of Farenheit temperatures: 
Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius Fahrenheit Celsius 
        32       0         77      25        122      50        167      75        212     100 
        33       0         78      25        123      50        168      75        213     100 
        34       1         79      26        124      51        169      76        214     101 
        35       1         80      26        125      51        170      76        215     101 
        36       2         81      27        126      52        171      77        216     102 
        37       2         82      27        127      52        172      77        217     102 
        38       3         83      28        128      53        173      78        218     103 
        39       3         84      28        129      53        174      78        219     103 
        40       4         85      29        130      54        175      79        220     104         
...
  • 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-05-25T18:45:01+00:00Added an answer on May 25, 2026 at 6:45 pm

    You’re already printing aligned columns, just not enough of them.

    Start by printing out

    Farenheit equivalents of Celsius temperatures:  
    Celsius Farenheit Celsius Farenheit Celsius Farenheit Celsius Farenheit  
          0        32       0        32       0        32       0        32  
          1        33       1        33       1        33       1        33
        ...  
    

    and think about what you’d have to change in your program to print the chart you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem can be summed up by making this simple command works : nice
I have a problem making a select tag in php code dynamic. I'm creating
I have a problem making a server side generated code( <php ?> ) div
problem with making edittext scrollable there is mentioned that it is not scrollable with
I have PHP generating JSON data but I am having a problem making a
The problem: making a very simple style switcher with js (without inline event handling).
I have a problem making an advanced (for me) query. I am trying to
I've got a bit of a problem with making my data loading and filtering
I had a problem that was making the original array to change, the curious
I'm having some difficulties with the following problem: I'm making a little game where

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.