Hello group,
I am feeling pretty good about this program. I am just learning and
am trying to get the basics down. I would like to ask if someone
could tell me how to right justify the BALANCE column in my program's
output.
===============
Here is my code:
===============
#include <stdio.h>
int main (void)
{
int i;
int accountNumber[10];
char lastName[10][30];
float accountBalance[10];
printf("Enter account number, last name, and balance.\n");
printf("Enter -999 to end input.\n");
for (i = 0; i < 10; i++)
{
printf("? ");
scanf ("%i", &accountNumb er[i]);
if (accountNumber[i] == -999)
{
printf("\n");
break;
}
scanf("%s", lastName[i]);
scanf("%f", &accountBala nce[i]);
} /* End for loop */
printf("%-15s%-15s%-15s\n","ACCOUNT ","LAST NAME","BALANCE" );
for(i = 0; (i < 10) && (accountNumber[i] != -999); i++)
{
printf("%-15d%-15s%-15.2f", accountNumber[i],
lastName[i], accountBalance[i]);
printf("\n");
}
printf("\n\n");
return 0;
} /* End main */ 2 18744 jw****@berkeley .edu wrote: Hello group,
I am feeling pretty good about this program. I am just learning and am trying to get the basics down. I would like to ask if someone could tell me how to right justify the BALANCE column in my program's output.
=============== Here is my code: ===============
#include <stdio.h>
int main (void) {
int i; int accountNumber[10]; char lastName[10][30]; float accountBalance[10];
printf("Enter account number, last name, and balance.\n"); printf("Enter -999 to end input.\n");
for (i = 0; i < 10; i++) {
printf("? "); scanf ("%i", &accountNumb er[i]);
if (accountNumber[i] == -999) { printf("\n");
break; }
scanf("%s", lastName[i]); scanf("%f", &accountBala nce[i]);
} /* End for loop */
printf("%-15s%-15s%-15s\n","ACCOUNT ","LAST NAME","BALANCE" );
Use: printf("%-15s%-15s%15s\n","ACC OUNT","LAST NAME","BALANCE" ); for(i = 0; (i < 10) && (accountNumber[i] != -999); i++) {
printf("%-15d%-15s%-15.2f", accountNumber[i], lastName[i], accountBalance[i]);
Use: printf("%-15d%-15s%15.2f", accountNumber[i],
lastName[i], accountBalance[i]); printf("\n"); }
printf("\n\n");
return 0;
} /* End main */
Using the - modifier in the format left justifies the result within
the field. Removing it causes right justification.
Rgds,
Shanmu.
Shanmu,
Wow do I feel silly. I kept looking around the Internet for how to do
it. No wonder I couldn't find it considering it happens by default.
Oh well, thanks for helping me out. :o) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Leonard |
last post by:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.
|
by: David Holmes |
last post by:
Hi
Acc 97 is it possible to right justify numbers in a list box
Thanks in advance
Dave Holmes
|
by: Kevin R |
last post by:
Hi All,
I am using
for(i = . . . . .)
sw.WriteLine(string.Format("{0} {1}", num1, num2));
and I am getting
12 123
|
by: Tina |
last post by:
Is there any way to get the text property to right justify in controls like
Hyperlink buttons and labels?
Thanks,
T
|
by: John Wilson |
last post by:
Here's a dumb question from a learner:
In a datagrid in a web page, how do I right justify a column of figures?
I bet its easy once you know.
John Wilson
| |
by: JG |
last post by:
I'm new obviously to html and I'm looking for a way
put an image on the right side of the page opposite
text on the left. How does one do this? I've heard
of text wrapping of an image but not sure if this is
what I really want, and further don't know how to do
that either.
Appreciate any info.
|
by: tshad |
last post by:
I have a datagrid that I cannot get to right justify a money amount (which
is just a label). No matter what I do - it still right justifies it.
<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right" >
<itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
|
by: eighthman11 |
last post by:
Hello everyone, I'm using Access 2000 and SQL 8.0
This maybe easy but I can't figure it out. I have a linked access
table to a SQL server table. I use this table on a Grid on an Access
form. There is a field on the grid for the Equipment Number the field
is called Equipment (I know original).
The data type for this field is varchar with a length of 10 and the
data is rigth justified in the table
on the SQL Server.
|
by: samueltilden |
last post by:
I have Infragistics 2007, Volume 3:
I have a UltraStatusBar with two UltraStatusPanels:
1. Left Panel and
2. Right Panel
I want the Right Panel to appear on the right and to have its text
right justified. The RightPanel.SizingMode = Spring does not seem to
work as the comparable option does with Microsoft's regular
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |