473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reg: Program to get the output as 05 for the same input but not as 5

Hi

Can anyone give me a code regarding this. If I give input as 05 I should get the same (05)output but not just 5

output should be like
input: 05
output: 05

not like this
input: 05
output: 5



Thanks in advance
Nov 17 '08 #1
4 1440
weaknessforcats
9,208 Expert Mod 8TB
You don't say whether you are using C or C++.

For C++, research cout.fill().
Nov 17 '08 #2
JosAH
11,448 Expert 8TB
... and for C look at the "%02d" format string.

kind regards,

Jos
Nov 17 '08 #3
Thank you very much...Now I am getting the output...but not the required one..
In a same input if at all I need to give values like 05, 005, 5, 0005 now if I am giving "%02d" then the output I got is 05, 05, 5, 05.
So I changed to "%03d" and now I am getting 005, 005, 5, 005 but not as same as the input values.
I need the output to be as same as input because I am using lots of data(11350)at a time which has any of the above values
Sorry for not mentioning the Language...I am writing program in C lang....

Regards
Siva
Nov 18 '08 #4
JosAH
11,448 Expert 8TB
If any number of zeros can be prepended to your number(s) then a simple "%02d"
format string won't help you. Better leave the input as strings (char*) and copy
them verbatim to the output.

kind regards,

Jos
Nov 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >>...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
8
by: G Patel | last post by:
I wrote the following program to remove C89 type comments from stdin and send it to stdout (as per exercise in K&R2) and it works but I was hoping more experienced programmer would critique the...
13
by: Sree | last post by:
If the program (myprog) is run from the command line as myprog 1 2 3 , What would be the output? main(int argc, char *argv) { int i; for(i=0;i<argc;i++) printf("%s",argv); }
10
by: JulianP | last post by:
Hi I am working on a Turtle Program and I have put in all the fancy schmancy stuff in I just cant seem to figure out how to print the T, which is my turtle, on the screen. Here is the code for my...
2
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how...
1
by: nick777 | last post by:
Hope the Community can bear with me as I muddle with the vocabulary since I am not really sure if I am going about this the correct way. My question is as follows: If I had some sample data in...
0
by: sivadhanekula | last post by:
Hi all, I have to do a project in excel by usung vb. The coding part is done and I am getting the output in .CSV format. when doing project in the main excel sheet I will be having 3 sheets and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.