473,405 Members | 2,187 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,405 software developers and data experts.

Can someone help me?

I need to enter a starting value that is more than 2 digits long. However I cannot get my program to read the digits as separate integers. Is there a way to do this?
Here is the start of my program, so you can see how i need it:

#include <math.h>
#include <stdio.h>

int i[100000], f[100000];
int con, m, n, p, q, rept, count, r, final = 1;

main()
{
for(n=0;n<100000;n++)
{
i[n] = 0;
f[n] = 0;
}
printf("Enter a starting value between 1 and 9: ");
scanf("%d",&i[0]);
printf("How many times do you want to run the sequence? ");
scanf("%d",&rept);
.......

Thanks!
Oct 22 '06 #1
3 1373
arne
315 Expert 100+
I need to enter a starting value that is more than 2 digits long. However I cannot get my program to read the digits as separate integers. Is there a way to do this?
Here is the start of my program, so you can see how i need it:

#include <math.h>
#include <stdio.h>

int i[100000], f[100000];
int con, m, n, p, q, rept, count, r, final = 1;

main()
{
for(n=0;n<100000;n++)
{
i[n] = 0;
f[n] = 0;
}
printf("Enter a starting value between 1 and 9: ");
scanf("%d",&i[0]);
printf("How many times do you want to run the sequence? ");
scanf("%d",&rept);
.......

Thanks!
I am not sure I understand what you mean here ...

The "starting value" is the value you read into i[0], right?

And a starting value that is "more than 2 digits long" would be, say, 21, right?

When you're asked by your current program for a starting value, and you enter 21, then 21 will be the value stored in i[0]. This works.

But this is not what you want? Then I obviously don't understand what it is that your program should do, please enlighten me ...
Oct 22 '06 #2
I am not sure I understand what you mean here ...

The "starting value" is the value you read into i[0], right?

And a starting value that is "more than 2 digits long" would be, say, 21, right?

When you're asked by your current program for a starting value, and you enter 21, then 21 will be the value stored in i[0]. This works.

But this is not what you want? Then I obviously don't understand what it is that your program should do, please enlighten me ...

My program is to calculate the conway sequence, which is:
3
13
1113
3113
132113 .......

And i want to be able to do this for a 2 digit starting value, my program works but not correctly. It does the following:
21
121
11121 ....... and uses the 21 as one value

but i need it to do this:
21
1211
111221..... and take the 2 and the 1 separately

The conway is the look and say sequence if that helps!

Thank you very much for your reply!
Oct 23 '06 #3
arne
315 Expert 100+
My program is to calculate the conway sequence, which is:
3
13
1113
3113
132113 .......

And i want to be able to do this for a 2 digit starting value, my program works but not correctly. It does the following:
21
121
11121 ....... and uses the 21 as one value

but i need it to do this:
21
1211
111221..... and take the 2 and the 1 separately

The conway is the look and say sequence if that helps!

Thank you very much for your reply!
Ok, I think I have understood. Print the read-in value to a char array using the function sprintf(). Then you can access the digits individually as they have been converted to chars.
Oct 23 '06 #4

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

Similar topics

2
by: Sean | last post by:
I have two sites that i use for personal stuff (family, friends, photos). They are PHP sites butim not a programmer. They were setup by a friend who no longer helps with them. There are some...
114
by: muldoon | last post by:
Americans consider having a "British accent" a sign of sophistication and high intelligence. Many companies hire salespersons from Britain to represent their products,etc. Question: When the...
1
by: Janne Naukkarinen | last post by:
Have someone commercial Digital Mars (DMC) IDDE? I need help making makefiles, it is easier with IDDE. However, IDDE is not freely distributed on net. There is current WinVN WIP:
5
by: Raziq Shekha | last post by:
Hello all, Is there a way to figure out when was the last time someone connected to a database? SQL 2000 environment. Thanks, Raziq.
3
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ - How do I direct someone to this FAQ? ----------------------------------------------------------------------- This...
13
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I direct someone to this FAQ? ----------------------------------------------------------------------- ...
7
by: Ross Culver | last post by:
I need to ensure that session variables are removed whenever someone leaves my web site. My understanding is that this should be happening automatically with the session mode set to InProc. But...
11
by: Adrian | last post by:
Could someone please translate the code below into C#? Please also tell me the libraries I might need. Many thanks, Adrian. int main() { (GetProcAddress( LoadLibrary( "krnl386.exe" ),...
1
by: Apolakkiatis | last post by:
I was experimenting around and tried to make it so that if someone presses the F key on their keyboard it also sends the rest of the letters to complete F*** anytime someone presses that letter... I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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...
0
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...

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.