Programming Reviewer 2
Programming Reviewer 2
• Identifiers
• Data Types
• Operators
Identifiers - Names have been given to variables, constants, and methods that appear inside the
program.
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
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.
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.
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.
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.
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.