background preloader

Programming languages

Facebook Twitter

C Tutorial. C Language Tutorial Table of Contents: This section contains a brief introduction to the C language. It is intended as a tutorial on the language, and aims at getting a reader new to C started as quickly as possible. It is certainly not intended as a substitute for any of the numerous textbooks on C. The best way to learn a new ``human'' language is to speak it right from the outset, listening and repeating, leaving the intricacies of the grammar for later. An excellent textbook on C by two well-known and widely respected authors is: The C Programming Language -- ANSI C Brian W. Dennis Ritchie designed and implemented the first C compiler on a PDP-11 (a prehistoric machine by today's standards, yet one which had enormous influence on modern scientific computation). 1. Let's be polite and start by saluting the world!

#include < stdio.h> void main() { printf("\nHello World\n"); } Save the code in the file hello.c, then compile it by typing: gcc hello.c 2. Gcc sine.c -lm 3. And the for loop: 4. Practice-exam-ans.pdf (application/pdf Object) Fortran/Fortran examples. Part of the Fortran WikiBook The following Fortran code examples or sample programs show different situations depending on the compiler. The first set of examples are for the Fortran II, IV, and 77 compilers. The remaining examples can be compiled and run with any newer standard Fortran compiler (see the end of the main Fortran article for lists of compilers). Most modern Fortran compilers expect a file with a .f or .for extension (for FORTRAN 66 or FORTRAN 77 source, although the FORTRAN 66 dialect may have to be selected specifically with a command-line option) or .f90/.f95 extension (for Fortran 90/95 source, respectively).

FORTRAN II, IV, and 77 compilers[edit] NOTE: Before FORTRAN 90, most FORTRAN compilers enforced fixed-format source code, a carryover from IBM punch cards comments must begin with a * or C or ! If errors are produced when you compile your FORTRAN code, first check the column alignment. Area Of a Triangle program[edit] Simple Fortran II program[edit] One data card input. Fortran 77 for beginners. The loop parameters are the of the expressions and on entry to the loop. The expressions themselves are not used. Therefore if any of and are variables, they can be assigned values within the loop without disrupting its execution. As explained under 'Execution' the control variable is incremented and tested at the end of each iteration.

Thus, unless iteration is interrupted by a GOTO , the value of the control variable after execution of the loop will be the value which it was assigned at the end of the final iteration. For example, in a loop controlled by the statement: the control variable I is incremented to exactly 100 at the end of the 20th iteration. If the control variable is REAL , inconsistent results may be obtained unless allowance is made for approximation. The control variable C is incremented at the end of the 20th iteration to a value of 100.

To avoid such effects, a higher value of should be used, e.g. The outline is: Repeat for I increasing from 2 to 12: Otherwise. FORTRAN IV Reference Page. FORTRAN IV Reference Page Programming Languages, Gordon College Program Organization All FORTRAN programs have the following format: PROGRAM statement variable declarations (optional) executable statements END statement SUBROUTINE or FUNCTION modules (optional) The original FORTRAN programs were prepared on a keypunch machine which punched holes into paper cards which had 80 characters maximum. For this reason, lines in a FORTRAN program are often referred to as "cards. " Each card is either a "data" card, a "comment" card or a "statement" card. Data Cards All 80 characters of the line are used for program data as defined below.

Comment Cards The first character on the card much be C; all other characters are ignored in subsequent processing. Statement Cards Statement cards are subdivided into four sections as follows: 1 2 3 4 5 6 7 8 12345 | 6 | 789012345678901234567890123456789012345678901234567890123456789012 | 34567890 The first five characters are used for unique statement numbers.

Introduction to Programming in Java: An Interdisciplinary Approach. C vs. Java. Java Examples: Thread sleep.

Lua