0% found this document useful (0 votes)
121 views

Cobol Programming Language: Hello, World

C is a general-purpose programming language developed in the early 1970s and widely used for system software and applications. It influenced many later languages with its syntax of expressions and statements. Hello world prints "Hello, world!" when run. BASIC is an easy to use language designed for non-scientists in 1964. A sample BASIC program prints stars based on user input. PL/I is a language for scientific and systems programming introduced in the 1960s, with features like recursion and string handling.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

Cobol Programming Language: Hello, World

C is a general-purpose programming language developed in the early 1970s and widely used for system software and applications. It influenced many later languages with its syntax of expressions and statements. Hello world prints "Hello, world!" when run. BASIC is an easy to use language designed for non-scientists in 1964. A sample BASIC program prints stars based on user input. PL/I is a language for scientific and systems programming introduced in the 1960s, with features like recursion and string handling.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ADD YEARS TO AGE

COBOL PROGRAMMING LANGUAGE


COBOL is one of the oldest programming languages. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments. COBOL programs are in use globally in governmental and military agencies and in commercial enterprises, and are running on operating systems such as IBM's z/OS and z/VSE, the POSIXfamilies (Unix/Linux etc.), and Microsoft's Windows as well as ICL's VME operating system and Unisys' OS 2200. In 1997, the Gartner Group reported that 80% of the world's business ran on COBOL with over 200 billion lines of code in existence and with an estimated 5 billion lines of new code annually.

The equivalent construct in many procedural languages would be age = age + years This syntax is similar to the compound assignment operator later adopted by C: age += years The abbreviated conditional expression IF SALARY > 8000 OR SUPERVISOR-SALARY OR = PREV-SALARY is equivalent to IF SALARY > 8000 OR SALARY > SUPERVISOR-SALARY OR SALARY = PREV-SALARY

Hello, world
An example of the "Hello, world" program in COBOL: IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. PROCEDURE DIVISION. DISPLAY 'Hello, world'. STOP RUN. Like any widespread programming language, there are various dialects of COBOL. Some compilers, for example, allow the use of double quotes in addition to standard single quotes: DISPLAY "Hello, world".

program average

! Read in some numbers and take the average

FORTRAN PROGRAMMING LANGUAGE


Fortran (previously FORTRAN) is a generalpurpose, imperative programming language that is especially suited to numeric computation and scientific computing. Originally developed by IBM at their campus in south San Jose, California in the 1950s for scientific and engineering applications, Fortran came to dominate this area of programming early on and has been in continual use for over half a century in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, computational physics and computational chemistry. It is one of the most popular languages in the area of high-performance computing and is the language used for programs that benchmark and rank the world's fastest supercomputers.

! As written, if there are no data points, an average of zero is returned ! While this may not be desired behavior, it keeps this example simple

implicit none

real, dimension(:), allocatable :: points integer real negative_average=0. :: number_of_points :: average_points=0., positive_average=0.,

write (*,*) "Input number of points to average:" read (*,*) number_of_points

allocate (points(number_of_points))

write (*,*) "Enter the points to average:" read (*,*) points

! Take the average by summing points and dividing by number_of_points if (number_of_points > 0) average_points = sum(points) / number_of_points ! Now form average over positive and negative points only if (count(points > 0.) > 0) then positive_average = sum(points, points > 0.) / count(points > 0.) end if if (count(points < 0.) > 0) then negative_average = sum(points, points < 0.) / count(points < 0.) end if deallocate (points)

! Print result to terminal write (*,'(a,g12.4)') 'Average = ', average_points write (*,'(a,g12.4)') 'Average of positive points = ', positive_average write (*,'(a,g12.4)') 'Average of negative points = ', negative_average

end program average

Recall from the beginning of this text the demonstration program duplicated below: #include <stdio.h>

C PROGRAMMING LANGUAGE
In computing, C (/si/, like the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 atBell Labs. Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system. C is one of the most widely used programming languages of all time, and there are very few computer architectures for which a C compiler does not exist. Many later languages have borrowed directly or indirectly from C, including: C#, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C Shell. The most pervasive influence on these languages has been syntactical, and they tend to combine the recognizable expression and statementsyntax of C with underlying type systems and data models that can be radically different. C++ started as a preprocessor for C and is currently nearly a superset of C.

int main(void) { printf("Hello, world!\n"); return 0; } If you compile and run this program, you will see the sentence below show up on your screen:

Hello, world!

A typical application might be like this: #include "stdio.h" int main(void) { int a; printf("Please input an integer value: "); scanf("%d", &a); printf("You entered: %d\n", a); return 0; } The correct usage would be:

scanf("%s", a);

printf("This sentence will print out exactly as you see it...");


And once it is contained in a proper main() function, it will show:

This sentence will print out exactly as you see it...

Sample

BASIC PROGRAMMING LANGUAGE


BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use; the name is an acronymfrom Beginner's All-purpose Symbolic Instruction Code. The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire,USA to provide computer access to non-science students. At the time, nearly all use of computers required writing custom software, which was something only scientists and mathematicians tended to do. The language and its variants became widespread on microcomputers in the late 1970s and 1980s, when it was typically a standard feature, and often part of the firmware of the machine. BASIC remains popular in numerous dialects and new languages influenced by BASIC such as Microsoft Visual Basic. In 2006, 59% of developers for the .NET Framework used Visual Basic .NET as their only programming language.

10 INPUT "What is your name: ", U$ 20 PRINT "Hello "; U$ 30 INPUT "How many stars do you want: ", N 40 S$ = "" 50 FOR I = 1 TO N 60 S$ = S$ + "*" 70 NEXT I 80 PRINT S$ 90 INPUT "Do you want more stars? ", A$ 100 IF LEN(A$) = 0 THEN GOTO 90 110 A$ = LEFT$(A$, 1) 120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30 130 PRINT "Goodbye "; U$ 140 END The resulting dialog might resemble:

What is your name: Mike Hello Mike How many stars do you want: 7 ******* Do you want more stars? yes How many stars do you want: 3 *** Do you want more stars? no Goodbye Mike

PL/1 PROGRAMMING LANGUAGE


PL/I ("Programming Language One", pronounced "pee-el-one") is a procedural, imperative computer programming language designed for scientific, engineering, business and systems programming applications. It has been used by various academic, commercial and industrial organizations since it was introduced in the 1960s, and continues to be actively used as of 2011. PL/I's principal domains are data processing, numerical computation, scientific computing, and systems programming; it supports recursion,structured programming, linked data structure handling, fixed-point, floating. point, complex, character string handling, and bit string handling. The language syntax is English-like and suited for describing complex data formats, with a wide set of functions available to verify and manipulate them.

Hello world program


Hello2: proc options(main); put list ('Hello, world!'); end Hello2;

Search for a string


/* Read in a line, which contains a string, /* and then print every subsequent line that contains that string. */ find_strings: procedure options (main); declare pattern character (100) varying; declare line character (100) varying; declare (line_no, end_file) fixed binary; end_file = 0; on endfile (sysin) end_file = 1; get edit (pattern) (L); line_no = 1; do while (end_file = 0); if index(line, pattern) > 0 then put skip list (line_no, line); line_no = line_no + 1; get edit (line) (L); end; end find_strings;

You might also like