LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2010, 04:38 AM   #1
vjramana
Member
 
Registered: Sep 2009
Posts: 89

Rep: Reputation: 0
how to put blank spaces in between list of numbers generated in FORTRAN


Dear Sir/Madam,

I have two sets of data. 1,2,3,4 and 6,7,8 and I have written a fortran code to put them in order as below:
**********************************************
program gap
implicit none
!
integer:: i, j
do i = 1,4
do j = 6, 8
print*, i, j
end do
end do
end program gap
**********************************************

When I execute this program I get the output as below:

1,6
1,7
1,8
2,6
2,7
2,8
3,6
3,7
3,8
4,6
4,7
4,8

BUT I want the out put as below:

1,6
1,7
1,8

2,6
2,7
2,8

3,6
3,7
3,8

4,6
4,7
4,8

I want a space once every row loop has finish.I am dont know how to write the data as shown above using the fortran code in this post.
Could anyone help ?

Thanks in advance.
Vijay.M
 
Old 08-25-2010, 05:19 AM   #2
giammy
Member
 
Registered: Feb 2010
Posts: 36

Rep: Reputation: 20
Quote:
Originally Posted by vjramana View Post
Dear Sir/Madam,

I have two sets of data. 1,2,3,4 and 6,7,8 and I have written a fortran code to put them in order as below:
...

I want a space once every row loop has finish.I am dont know how to write the data as shown above using the fortran code in this post.
Could anyone help ?

Thanks in advance.
Vijay.M
Hi,

is has been many many years from when I wrote my last fortran program,
so check the syntax: the solution is just add a print after the first end do.

Code:
program gap
implicit none
!
integer:: i, j
do i = 1,4
   do j = 6, 8
     print*, i, j        
   end do
   print "\n"   <---- check the syntax to print a new line ( \n is used in C, my main language :-()
end do
end program gap
 
1 members found this post helpful.
Old 08-26-2010, 12:35 AM   #3
vjramana
Member
 
Registered: Sep 2009
Posts: 89

Original Poster
Rep: Reputation: 0
Yes

I typed

print*, " "


and it works.

Thank you so much.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] SED - how to remove blank spaces carolflb Linux - Newbie 2 01-30-2010 06:02 AM
Looking for a comprehensive list of g++ generated warnings magham_rajesh Linux - General 0 06-19-2006 10:16 AM
Problem with SED and blank spaces BigLarry Programming 2 06-10-2004 04:57 AM
How are the numbers generated? pe2338 Linux - General 1 09-24-2003 10:00 AM
Terminal - Xtra Spaces Generated RH 8 gakusei Linux - Software 3 02-16-2003 06:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration