Hi,
I have this code:
#include <stdio.h>
void main()
{
int i,n=40;
float a=0,b=1;
for (i=1;i<=n;i++)
{
printf("%.0f\n",a);
printf("%.0f\n",b);
a+=b;
b+=a;
}
getch();
}
It present Fibonacci serial of 40 elements. Now I need to divide it to
groups of 6 in each row.
Please help me do it.
Cheers.
* 4 1157
Ronen Kfir <ro****@tauex.tau.ac.il> spoke thus: #include <stdio.h> void main()
^^^^
Wrong. main() returns int.
{ int i,n=40; float a=0,b=1;
Why are these floats?
for (i=1;i<=n;i++) { printf("%.0f\n",a); printf("%.0f\n",b);
printf( "%.0f %.0f", a, b );
if( i%3 == 0 )
printf( "\n" );
a+=b; b+=a; }
getch(); }
Printing the last newline if needed is left as an exercise.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
In <b0*************************@posting.google.com> ro****@tauex.tau.ac.il (Ronen Kfir) writes: #include <stdio.h> void main() { int i,n=40; float a=0,b=1; for (i=1;i<=n;i++) { printf("%.0f\n",a); printf("%.0f\n",b); a+=b; b+=a; }
getch(); }
It present Fibonacci serial of 40 elements. Now I need to divide it to groups of 6 in each row.
Please help me do it.
No way, until you read the FAQ and modify your program accordingly.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de ro****@tauex.tau.ac.il (Ronen Kfir) wrote in message news:<b0*************************@posting.google.c om>... I have this code:
#include <stdio.h> void main()
int main (void)
main() *always* returns int
{ int i,n=40; float a=0,b=1; for (i=1;i<=n;i++) { printf("%.0f\n",a); printf("%.0f\n",b); a+=b; b+=a; }
getch();
non-standard call
}
It present Fibonacci serial of 40 elements. Now I need to divide it to groups of 6 in each row.
maintain a count of how many elements you've printed so far. When it gets
to six print a newline and reset the counter.
--
Nick Keighley This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dot Kom |
last post by:
I've got this text file full of lines like:
A*1King Richard Dale*3Welton Orchard Rd*4Petersburg*5257-1234Î
the columns are defined by the *#, so that line would break apart
like:
A*1King...
|
by: Raaijmakers, Vincent (IndSys, GE Interlogix) |
last post by:
Ok, perhaps a question on a newbie level.
I try to create a simple 'write to a console application' where all the items in a string
do have a variable size:
items =
Well, actually, I need to...
|
by: Crypt Keeper |
last post by:
I am trying to write a program that asks user for several input items,
then takes those items into a class that will manipulate the data and
then return a line of output. I am able to input the...
|
by: Cesar A. K. Grossmann |
last post by:
Hi
I'm trying to build a parser for a file I create. The file format is as
follow:
IDENTIFIER = NUMBER STRING STRING;
COMPOSITE = STRING { ITEM };
ITEM = NUMBER IDENTIFIER|COMPOSITE
|
by: Aaron |
last post by:
Hello,
I have a small application that I need to save data from 7 text boxes in to
a csv file. This will entail btnNext_Click function that will create a new
csv file and enter the 7 data fields...
|
by: Stimp |
last post by:
I'm populating a dropdown list with non-consecutive values (well the
last 3 values are non-consecutive anyway).. What's a shorter way of
writing the following?...
ddLetMaxPrice.Items.Insert(0,...
|
by: tizmagik |
last post by:
Database consists of the following 4 tables with respective
attributes:
CUSTOMER(C#, CUSTOMER NAME, ADDRESS), the key is
ITEM(I#, ITEM NAME, MANUFACTURER, YEAR), the key is
BOUGHT(C#, I#,...
|
by: rmr531 |
last post by:
First of all I am very new to c++ so please bear with me. I am trying
to create a program that keeps an inventory of items. I am trying to
use a struct to store a product name, purchase price,...
|
by: hemant.gaur |
last post by:
I have an application which writes huge number of bytes into the
binary files which is just some marshalled data.
int len = Data.size(); //arrary size
for (int i = 0; i < len; ++i)...
|
by: kimiraikkonen |
last post by:
Hi,
I can read from a text file and insert text file's contents into a
listbox whose format is line by line using this code:
Dim reader As String
reader = My.Computer.FileSystem.ReadAllText("c:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |