Click here to Skip to main content
15,911,132 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Can't create modeless dialogs Pin
hierro3-Jan-02 0:32
hierro3-Jan-02 0:32 
GeneralRe: Can't create modeless dialogs Pin
Philip Patrick3-Jan-02 0:41
professionalPhilip Patrick3-Jan-02 0:41 
GeneralRe: Can't create modeless dialogs Pin
hierro3-Jan-02 5:14
hierro3-Jan-02 5:14 
GeneralAdding to list box Pin
vin2-Jan-02 20:46
vin2-Jan-02 20:46 
GeneralRe: Adding to list box Pin
Pierre Heler-Caruel2-Jan-02 22:10
Pierre Heler-Caruel2-Jan-02 22:10 
Generaloops on last message for formatting Pin
LauraKamel2-Jan-02 19:21
LauraKamel2-Jan-02 19:21 
GeneralRe: oops on last message for formatting Pin
Michael Dunn2-Jan-02 20:24
sitebuilderMichael Dunn2-Jan-02 20:24 
Generalformatting output with VC++ Pin
LauraKamel2-Jan-02 19:17
LauraKamel2-Jan-02 19:17 
I am having trouble using setprecision(), setw(), fixed, right, left,..etc... funtions for formatting output.

I want to have a number on top of another number on top of the answer all inline with eachother on the right regardless of the length of each number.

Example of desired output:
234
x 678
------
158652

However, this is what I am getting:
234
x 678
------
158652

with this code:

#include<stdio.h>
#include<iostream>
#include<iomanip.h>

void main()
{
int a, b;
int Answer = 0;

cout << "\nEnter a three digit integer: ";
cin >> a;

cout << "Enter a second three digit integer: ";
cin >> b;

Answer = a * b;

cout << setiosflags(ios::right) << a << endl;
cout << setiosflags(ios::right) << "x " << b << endl;
cout << setiosflags(ios::right) << "------\n";
cout << setiosflags(ios::right) << Answer << endl;
}

This code seems inefficient and is not giving good results. I would be greatful for any suggestions anyone may have.

Beginning Student Programmer
GeneralReference & Pointer :: C++ Pin
valikac2-Jan-02 17:49
valikac2-Jan-02 17:49 
GeneralRe: Reference & Pointer :: C++ Pin
Christian Graus2-Jan-02 19:02
protectorChristian Graus2-Jan-02 19:02 
GeneralRe: Reference & Pointer :: C++ Pin
Nish Nishant2-Jan-02 19:17
sitebuilderNish Nishant2-Jan-02 19:17 
GeneralRe: Reference & Pointer :: C++ Pin
Christian Graus2-Jan-02 21:34
protectorChristian Graus2-Jan-02 21:34 
GeneralRe: Reference & Pointer :: C++ Pin
Nish Nishant2-Jan-02 22:12
sitebuilderNish Nishant2-Jan-02 22:12 
GeneralRe: Reference & Pointer :: C++ Pin
Nish Nishant2-Jan-02 19:14
sitebuilderNish Nishant2-Jan-02 19:14 
GeneralRe: Reference & Pointer :: C++ Pin
Nish Nishant2-Jan-02 19:16
sitebuilderNish Nishant2-Jan-02 19:16 
GeneralRe: Reference & Pointer :: C++ Pin
valikac2-Jan-02 19:28
valikac2-Jan-02 19:28 
GeneralRe: Reference & Pointer :: C++ Pin
Vimal Earnest3-Jan-02 0:52
Vimal Earnest3-Jan-02 0:52 
GeneralRe: Reference & Pointer :: C++ Pin
valikac3-Jan-02 8:25
valikac3-Jan-02 8:25 
GeneralGDI+ and RoundRect Pin
Andreas Hallberg2-Jan-02 17:03
Andreas Hallberg2-Jan-02 17:03 
GeneralRe: GDI+ and RoundRect Pin
Christian Graus2-Jan-02 17:08
protectorChristian Graus2-Jan-02 17:08 
GeneralRe: GDI+ and RoundRect Pin
Andreas Hallberg2-Jan-02 17:50
Andreas Hallberg2-Jan-02 17:50 
GeneralComplex Multiplication Pin
Roger Wright (new)2-Jan-02 16:09
Roger Wright (new)2-Jan-02 16:09 
GeneralRe: Complex Multiplication Pin
Michael Dunn2-Jan-02 20:34
sitebuilderMichael Dunn2-Jan-02 20:34 
GeneralRe: Complex Multiplication Pin
Roger Wright (new)3-Jan-02 5:45
Roger Wright (new)3-Jan-02 5:45 
GeneralMonitor messages Pin
2-Jan-02 15:51
suss2-Jan-02 15:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.