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

Programming Reviewer 2

The document discusses fundamentals of programming including identifiers, data types, operators, and conditional statements. Identifiers must follow naming rules and can include letters, digits, and symbols. Common data types include integers, floating point numbers, characters, and Booleans. Operators are used to perform operations, and conditional statements allow program control flow based on logical tests.

Uploaded by

Kelvs
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Programming Reviewer 2

The document discusses fundamentals of programming including identifiers, data types, operators, and conditional statements. Identifiers must follow naming rules and can include letters, digits, and symbols. Common data types include integers, floating point numbers, characters, and Booleans. Operators are used to perform operations, and conditional statements allow program control flow based on logical tests.

Uploaded by

Kelvs
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Fundamentals

• Identifiers
• Data Types
• Operators

Identifiers - Names have been given to variables, constants, and methods that appear inside the
program.

There are some rules that must be followed in naming identifiers:

• You can use letters, digits, underscore, and dollar signs


• It must start with a letter, underscore, or dollar sign.
• It can be of any length.
• It cannot be a command keyword and has No white space.
Data Types - Description of specific data that can be stored in a variable, the amount of memory
the item occupies, and the operations it can be performed.

BASIC DATA TYPES

Whole Number
The whole numbers are defined as the positive integers including zero does not contain any
decimal or fractional part.

short (16 bits / 2 bytes) - Stores whole numbers from -32,768 to 32,767
int (32 bits / 4 bytes) - Stores whole numbers from -2,147,483,648 to 2,147,483,647
long (64 bits / 8 bytes) - Stores whole numbers from 9,223,372,036,854,775,807 to
-9,223,372,036,854,775,808

Floating Point
A floating-point number is one where the position of the decimal point can "float" rather than
being in a fixed position within a number.

float (32 bits / 4 bytes) - Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits
double (64 bits / 8 bytes) - Stores fractional numbers. Sufficient for storing 15 decimal digits

Character
char (8 bits / 1 byte) - Stores a single character

Boolean - That has one of two possible values (usually denoted true and false) which is
intended to represent the two truth values of logic and Boolean.

Format Specifier - are used in C for input and output purposes. Using this concept, the compiler
can understand what type of data is in a variable during taking input using the scanf() function
and printing using the printf() function.
Scanf() - The scanf() function allows you to accept input from standard in, which for us is
generally the keyboard.
Operators - used to perform operations on variables and values.
- Relational Operators
- Logical Operators

Relational Operators - Define some kind of relation between two entities.

Logical Operators - To connect two or more expression


WHAT IS A PROGRAMMING LANGUAGE?

A programming language is a tool that allows programmers to write commands or programs


that can easily be understood by a person and translated into codes that are communication
that programmers use to develop machine-readable. This is the form of communication
applications, scripts, or other sets of instructions for a computer to execute.

HISTORY OF C PROGRAMMING

To appreciate programming languages, you will need to review the other languages that
preceded them. Programmers write a set of instructions called programs using various
programming languages. Some programs are directly understandable by computers, while
others require separate programs to translate instructions into machine code. The first
programming languages were invented even before the modern computer was made.

In the beginning, to program the computer, one must understand the binary language or
commonly known as machine language, which relates to electric switching 0 for off and 1 for
on.

First modern computers were created during the 1940s, and by that time programmers are
coding using the assembly language. To convert assembly language into a language that is
readable by the computer, an assembler is used. The assembler is the world's first software
tool.
In the 1950s, IBM developed FORTRAN (Formula Translating System), a language that is used
for scientific processing. This programming language is so powerful that it is even used in
supercomputers. FORTRAN remained one of the popular programming languages 50 years after
its invention.

BV 1959, Conference on Data Systems Languages created COBOL, a programming language for
business use. The aim was to make programming languages English-like so that both
programmers and management could read them.

In 1964, just 5 years after, John G. Kemeny and Thomas E. Kurtz invented a new programming
language called BASIC (Beginner's All-purpose Symbolic Instruction Code). The said language is
designed for timesharing and was intended to make programming easier for those with a less
technical background.

One of the common examples of languages inspired by BASIC is Microsoft Visual Basic.

During 1968-1969, Nikolaus Wirth designed Pascal, a popular programming language at that
time. Pascal was intended to be a teaching tool.
In the 1970s, Ken Thompson and Dennis Ritchie developed another language called B in Bell
Laboratories, which was inspired by FORTRAN. It was used to code systems and other
language software. Moreover, another language was developed by Ritchie, which is the C
programming language derived from B and Pascal.

This language is still popular today. A lot of widely used programming languages are based on
C. Examples of them are C++, Java, Python, and PHP.

Dennis M. Ritchie (September 9, 1941-c. October 12, 2011)


An American computer scientist. He created the C
programming language and, with long-time colleague Ken
Thompson, the Unix operating system at the Bell Telephone
Laboratories and B programming language.
Ken Thompson (born February 4, 1943) An American pioneer of
computer science. He designed and implemented the original Unix
operating system. He also invented the B programming language, the
direct predecessor to the C programming language, and was one of
the creators and early developers of the Plan 9
operating system.

The first use of C programming

• C was invented to write an operating system called UNIX.


• Cis a successor of the B language which was introduced in 1972.
• The language was formalized in 1988 by the American National Standard Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System Programming Language.
. Most of the state-of-the-art software has been implemented using C.

Operating System - The software supports a computer's basic functions, such as scheduling
tasks, executing applications, and controlling peripherals.

Compilers
- C coding
- Dev c++
Documentation Section - It is the section in which you can give comments to make the program
more interactive.

Preprocessor directives Section

Link section - This section involves the use of header files that are to be included necessarily in
the program.
- Give instruction to the compiler to preprocess the information before the actual
compilation starts.
- All preprocessor directives begin with #.
- Preprocessor directives are not statements, so they do not end with a semicolon (;).

Definition section - This section involves the variable definition and declaration in C.

Global declaration Section - This section is used to define the global variables to be used in the
programs, which means you can use these variables throughout the program.

Global variables are declared outside any function, and they can be accessed (used) on any
function in the program. Local variables are declared inside a function and can be used only
inside that function. The scope of a variable refers to where a variable is visible or accessible.

Function prototype declaration section - This section gives information about a function that
includes, the data type or the return type, the parameters passed, or the arguments.
Main function - It is the major section from where the execution of the program begins. The
main section involves the declaration and executable section.

USER-DEFINED - A function provided by the user of a program or environment, in a context


where the usual assumption is that functions are built into the program or environment.

PRE-DEFINED FUNCTIONS - A pre-defined function is built into the software and does not need
to be created by a programmer. Pre-defined functions often exist to carry out common tasks,
such as: finding an average number. determining the length of a string
Parts of C Program (Anatomy)

#include <stdio.h> - This command is a preprocessor directive in C that includes all standard
input output files before compiling any C program so as to make use of all those functions in
our C program.

int main() - This is the line from where the execution of the program starts. The "main()"function
starts the execution of any C program.

{(Opening bracket) - This indicates the beginning of any function in the program (Here it
indicates the beginning of the main function).

/* some comments */ - Whatever is inside /*---*/ are not compiled and executed; they are only
written for user understanding or for making the program interactive by inserting a comment
line. These are known as multiline comments. Single line comments are represented with the
help of 2 forward slashes"--"

printf("Hello World") - The printf() command is included in the C stdio.h library, which helps to
display the message on the output screen.

getch() - This command helps to hold the screen.

return 0 -This command terminates the C program and returns a null value, that is, O.

} (Closing brackets) - This indicates the end of the function .(Here it indicates the end of the
main function).

CONDITIONAL STATEMENTS

To specify the flow of program control, the order in which the instructions in a program must be
executed. They make it possible to make decisions, to perform tasks repeatedly, or to jump from one
section of code to another.

CONDITIONAL STATEMENT
- is used to carry out a logical test and then take one of two possible actions depending on the
outcome whether true or false.
Where: Boolean expression is a combination of Relational operators and Logical operators
(conditional operators) resulting in a value of true or false.

If Statement
- Executes a block of code if an expression is true.

You might also like