473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hi can give me idea

hem anyone can give me an idea on how to saparated digits using
looping

example

please key in any 5 digits number : 56789

and the ouput is
5678 9
5678 9
567 89
56 789
5 6789

huhu how to saparate those digin huhuhu can help???anyone?

i prefer code in c..

Sep 18 '07 #1
11 1734
In article <11************ **********@50g2 000hsm.googlegr oups.com>,
as********@yaho o.com says...
hem anyone can give me an idea on how to saparated digits using
looping

example

please key in any 5 digits number : 56789

and the ouput is
5678 9
5678 9
567 89
56 789
5 6789

huhu how to saparate those digin huhuhu can help???anyone?
Perhaps the observation that:

56789 / 10 = 5678
56789 % 10 = 9

would be helpful.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Sep 18 '07 #2
On Sep 18, 9:09 pm, Jerry Coffin <jcof...@taeus. comwrote:
In article <1190120954.547 646.112...@50g2 000hsm.googlegr oups.com>,
aslamhe...@yaho o.com says...
hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is
5678 9
5678 9
567 89
56 789
5 6789
huhu how to saparate those digin huhuhu can help???anyone?

Perhaps the observation that:

56789 / 10 = 5678
56789 % 10 = 9

would be helpful.

--
Later,
Jerry.

The universe is a figment of its own imagination.
huhu thx but can you make it clear..huhu im a beginner

Sep 18 '07 #3
Jerry Coffin wrote:
In article <11************ **********@50g2 000hsm.googlegr oups.com>,
as********@yaho o.com says...
>hem anyone can give me an idea on how to saparated digits using
looping

example

please key in any 5 digits number : 56789

and the ouput is
5678 9
5678 9
567 89
56 789
5 6789

huhu how to saparate those digin huhuhu can help???anyone?

Perhaps the observation that:

56789 / 10 = 5678
56789 % 10 = 9

would be helpful.
Or the fact that whatever you enter could just be a string and
not a number, which then can be split into two substrings at any
position "between the chars"...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 18 '07 #4
as********@yaho o.com wrote:
hem anyone can give me an idea on how to saparated digits using
looping

example

please key in any 5 digits number : 56789

and the ouput is
5678 9
5678 9
567 89
56 789
5 6789

huhu how to saparate those digin huhuhu can help???anyone?
Treat the number as text and insert spaces at appropriate places.
i prefer code in c..
Then ask in compl.lang.c and not in a C++ group.

--
Erik Wikström
Sep 18 '07 #5
On Sep 18, 9:31 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
aslamhe...@yaho o.com wrote:
hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is
5678 9
5678 9
567 89
56 789
5 6789
huhu how to saparate those digin huhuhu can help???anyone?

Treat the number as text and insert spaces at appropriate places.
i prefer code in c..

Then ask in compl.lang.c and not in a C++ group.

--
Erik Wikström- Hide quoted text -

- Show quoted text -
can u check this out..what wrong with these code huhuhu.....

#include <stdio.h>

int main(void)
{
float num;
int i, j, x ;

printf("please key in any 5 digit number:");
scanf("%f",&num );


for ( i=0 ; 5>i ; ++i){

for(j=0 ; i>j ; ++j){
printf(" ") ;
}

for( x = j+1 ; 5 >= x ; ++x){

printf("%.0f", num);
}
putchar('\n');
}

return 0;
}

what ur comment about this code??is thit mean im almost got the
answer??

Sep 18 '07 #6
On 2007-09-18 17:01, as********@yaho o.com wrote:
On Sep 18, 9:31 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
>aslamhe...@yah oo.com wrote:
hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is
5678 9
5678 9
567 89
56 789
5 6789
huhu how to saparate those digin huhuhu can help???anyone?

Treat the number as text and insert spaces at appropriate places.
i prefer code in c..

Then ask in compl.lang.c and not in a C++ group.

--
Erik Wikström- Hide quoted text -

- Show quoted text -

can u check this out..what wrong with these code huhuhu.....
Let us see what is wrong...
#include <stdio.h>
You really should use <iostreamto perform IO operations.
int main(void)
int main()
{
float num;
Using a float to store an integer, while not exactly wrong I would not
recommend it.
int i, j, x ;
Declare the variables int he innermost scope possible.
printf("please key in any 5 digit number:");
std::cout << "Please enter any 5 digits: ";
scanf("%f",&num );
std::cin >num;
for ( i=0 ; 5>i ; ++i){
for (int i = 0; i < 5; ++i)
>
for(j=0 ; i>j ; ++j){
printf(" ") ;
}

for( x = j+1 ; 5 >= x ; ++x){

printf("%.0f", num);
}
putchar('\n');
}

return 0;
}

what ur comment about this code??is thit mean im almost got the
answer??
Did you try running it before posting?

And once again, if you want to program in C, feel free to do so. But
then do not come and ask questions in here, where we discuss C++.
Whatever solution you come up with in C will most probably not be a good
solution in C++.

--
Erik Wikström
Sep 18 '07 #7
LR
as********@yaho o.com wrote:
On Sep 18, 9:31 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
>aslamhe...@yah oo.com wrote:
>>hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is
I'm going to guess that ints on your system can store any 5 digit
number. Otherwise you might have to use a string to store the digits.
I suggest that you not use float for this particular assignment.

[snip]
Ok, in another thread somewhere you posted that the actual output is,

and the ouput is
5678 9
567 89
56 789
5 6789

I'm going to assume that's correct because it makes more sense.

Write down a table of what you need.

You're going to go thru the loop 4 times.
You'll need some number of spaces before your number.
You'll need some number of digits.
You'll need some number of spaces. I'm less sure about this, so I'll
let you figure that out.
More digits.

Make a table like so:
main spaces before leading spaces trailing
index number digits digits
0 0 4 ? 1
1 2 3 ? 2
2 4 2 ? 3
3 6 1 ? 4

Now think about the relationships between those numbers, for example,
starting with a number in main index, what will yield the number in the
same row in the column spaces before number?

Elsewhere you got good advice about how to deal with the numbers in the
leading and trailing digits columns.

Don't use scanf, printf, etc. learn about streams. Learn about std::string.
>>huhu how to saparate those digin huhuhu can help???anyone?
>Treat the number as text and insert spaces at appropriate places.


>>i prefer code in c..
Oh, sorry, I didn't see that before I responded. I agree with the advice
given below.

>Then ask in compl.lang.c and not in a C++ group.
In particular the other problem you were asking about that seemed to be
part of calculating the cost of a meal, will get very different advice
from c and c++ programmers. So asking here may be less than useful for
you if you want to program in c.

OTOH, you may want to ask both c and c++ programmers and decide for
yourself which answers are more pleasing to you.

what ur comment about this code??
Needs to be better formatted.
is thit mean im almost got the
answer??
I don't know. I'm afraid that you'll have to look at the output and
decide that for yourself.

LR

Sep 18 '07 #8
On Sep 18, 9:16 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Jerry Coffin wrote:
In article <1190120954.547 646.112...@50g2 000hsm.googlegr oups.com>,
aslamhe...@yaho o.com says...
hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is
5678 9
5678 9
567 89
56 789
5 6789
huhu how to saparate those digin huhuhu can help???anyone?
Perhaps the observation that:
56789 / 10 = 5678
56789 % 10 = 9
would be helpful.

Or the fact that whatever you enter could just be a string and
not a number, which then can be split into two substrings at any
position "between the chars"...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide quoted text -

- Show quoted text -
i think it not a string take alook at the quest

Write a program in C that reads any five digit number and displays the
number in two parts diagonally as shown in the user interface screen
as shown below

Please key in any 5 digit number : 56789

5678 9
567 89
56 789
5 6789
The number displayed is separated into two parts beginning with the
rightmost unit digit.The process continues untill leftmost digit is
reached

Sep 18 '07 #9
On Sep 19, 12:04 am, LR <lr...@superlin k.netwrote:
aslamhe...@yaho o.com wrote:
On Sep 18, 9:31 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
aslamhe...@yaho o.com wrote:
hem anyone can give me an idea on how to saparated digits using
looping
example
please key in any 5 digits number : 56789
and the ouput is

I'm going to guess that ints on your system can store any 5 digit
number. Otherwise you might have to use a string to store the digits.
I suggest that you not use float for this particular assignment.

[snip]
Ok, in another thread somewhere you posted that the actual output is,

and the ouput is
5678 9
567 89
56 789
5 6789

I'm going to assume that's correct because it makes more sense.

Write down a table of what you need.

You're going to go thru the loop 4 times.
You'll need some number of spaces before your number.
You'll need some number of digits.
You'll need some number of spaces. I'm less sure about this, so I'll
let you figure that out.
More digits.

Make a table like so:
main spaces before leading spaces trailing
index number digits digits
0 0 4 ? 1
1 2 3 ? 2
2 4 2 ? 3
3 6 1 ? 4

Now think about the relationships between those numbers, for example,
starting with a number in main index, what will yield the number in the
same row in the column spaces before number?

Elsewhere you got good advice about how to deal with the numbers in the
leading and trailing digits columns.

Don't use scanf, printf, etc. learn about streams. Learn about std::string.
>huhu how to saparate those digin huhuhu can help???anyone?
Treat the number as text and insert spaces at appropriate places.
i prefer code in c..

Oh, sorry, I didn't see that before I responded. I agree with the advice
given below.
Then ask in compl.lang.c and not in a C++ group.

In particular the other problem you were asking about that seemed to be
part of calculating the cost of a meal, will get very different advice
from c and c++ programmers. So asking here may be less than useful for
you if you want to program in c.

OTOH, you may want to ask both c and c++ programmers and decide for
yourself which answers are more pleasing to you.
what ur comment about this code??

Needs to be better formatted.
is thit mean im almost got the
answer??

I don't know. I'm afraid that you'll have to look at the output and
decide that for yourself.

LR
thx these will be helpfull

Sep 18 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
2697
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
1
2596
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for topics to include in a course on object-orientation that I'm going to conduct. (I will later summarize all the replies and discussion, for the
2
1293
by: Oly | last post by:
give your opinions concerning our site,end work first year web technology www.zwin.tk in java: -navigation -stylechanger (with cookie) -pamorama -gallery
10
2040
by: sherifffruitfly | last post by:
Hi all, This isn't minimal code, but at least it gives the idea reasonably well - and yes, I'm a newb :( The point of me giving this code is that all three vars look to my eye as though they're being treated in exactly the same way, so that I end up confused about why the address-of-char doesn't get returned the way the other address-of-types do.
2
1407
by: Marco Ippolito | last post by:
Hi, I am giving a seminar on C# interop and I would like to feature an original sample class to stimulate some interest. Does anybody want to write an open-source ConsoleApp || WinApp that, given a starting English word, calls Babylon for translations in N languages and plays a game with the user assigning one point for every language/translation pair entered? (I am a licenced user for 2004 :-)
2
2035
by: Nathan | last post by:
I've spent a good part of the afternoon searching Google and the newsgroups for some sort of answer - so I apologize if I'm asking something that has already been asked and answered. I'm using ASP.Net 1.1 (unfortunately 2.0 isn't an option right now) and I'm working on the design of a security framework for other developers in our organization to use. We have a handful of different types of users that are contained in an enum called...
5
2083
by: Hasin Hayder | last post by:
I have been working with PHP for more than 3yrs (I believe still I am beginner in this category) - I was present in several interview board. Which things disappointed me most is the "lack of eagerness" to learn what comes new. Sometime developers thinks that learning Only PHP will help them to get lucrative jobs!! OMG Especially most of the time PHP developers plays multiple roles in the companies, they are developer, they are template...
1
1185
by: Ripendra007 | last post by:
hi all, i m doing one application of emailler which will send some campaign with some emailler..now i send this emailler to paricular user at that time i m storing the email id in database that i have sent this mail to particula receipient...Now the Question is i want to update my table or database when that particulr read that mail ...one thing is that when the user open that mail or say download the image that i will send with my emailler...
0
234
by: aslamhenry | last post by:
aslamhe...@yahoo.com View profile More options Sep 18, 9:09 pm Newsgroups: comp.lang.c++ From: aslamhe...@yahoo.com Date: Tue, 18 Sep 2007 06:09:14 -0700 Local: Tues, Sep 18 2007 9:09 pm Subject: hi can give me idea Reply | Reply to author | Forward | Print | Individual message | Show original | Remove | Report this message | Find messages by this
1
1050
by: chen8735 | last post by:
Create a GUI program to trace out any braces and keep track of the line having wrong closure of any braces dynamically and identify the previous line typed if error prone note some red symbol in the marigin. The marigin however must dynamically increase the line count of the coding.
0
8392
marktang
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...
0
8305
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,...
0
8726
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 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...
0
8603
tracyyun
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...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
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...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1604
bsmnconsultancy
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...

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.