Could Someone Compile This Code?

  • Thread starter ƒ(x) → ∞
  • Start date
  • Tags
    Code
In summary, compiling code is the process of translating human-readable code into machine-readable code that can be executed by a computer. This is necessary because computers can only understand the latter type of code. Compiling can be done by anyone with the necessary software and knowledge, but it is usually done by developers or programmers. Errors during the compilation process can prevent successful translation of the code, and the process may vary depending on the computer and operating system.
  • #1
ƒ(x) → ∞
25
0
..and tell what the last line they get in doing so.

Fortran:
program sieve_t
implicit none
integer*1 s(1000000), offset (10), sequence
integer i, j, n

n=0
sequence=4

do i=1, 10
    offset(i)=0
enddo

offset(1)=2
offset(2)=4
offset(3)=2

do i=1, 1000000
    s(i) = 1
enddo

do i=2, 1000000
    if (s(i).eq.1) then
        do j=2, (1000000/i)
            s(i*j)=0
        enddo
    endif
enddo

do i=2, 1000000
    if (s(i).eq.1) then
        do j=1,sequence-1   
            if (s(i+offset(j)).ne.1) goto 10
        enddo
        n=n+1
        write(*,*) n, i,i+2,i+6,i+8
    endif
10    continue
enddo
end
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
program sieve_tThe last line of output from the program would be: <number>, <prime>, <prime+2>, <prime+6>, <prime+8>
 
  • #3


Yes, someone could compile this code. The last line they would get after compiling is "end". This is because the code is written in Fortran and the "end" statement marks the end of the program.
 

1. What does it mean to "compile" code?

Compiling code is the process of translating human-readable code (such as Java or C++) into machine-readable code that can be executed by a computer. This involves converting the code into a lower-level language that the computer can understand and execute.

2. Why do we need to compile code?

We need to compile code because computers do not understand human-readable code, they only understand machine-readable code. Compiling allows us to write code in a high-level language that is easier for humans to understand and then translate it into a lower-level language that computers can execute.

3. Who can compile code?

Technically, anyone can compile code as long as they have the necessary software and knowledge. However, compiling code can be a complex process and is usually done by developers or programmers who have a deep understanding of the programming language and the compilation process.

4. What happens if there are errors during the compilation process?

If there are errors during the compilation process, the code will not be successfully translated into machine-readable code. These errors could be due to syntax mistakes, missing dependencies, or other issues. The compiler will typically display error messages that can help identify and fix the issue.

5. Can code be compiled on any computer?

Yes, code can be compiled on any computer as long as it has the necessary software and resources. However, the compilation process may vary depending on the type of computer and operating system being used. Some compilers are specific to certain languages or platforms.

Similar threads

  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
4
Views
608
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top