Getting Started With C: ++ What Is Computer? List The Primary Components of A Computer System
Getting Started With C: ++ What Is Computer? List The Primary Components of A Computer System
Getting Started With C: ++ What Is Computer? List The Primary Components of A Computer System
JHANG
Department of Computer Science
A Computer System
requires different hardware
components to perform the
functions of input, processing,
output, storage.
PRIMARY COMPONENTS
A list of primary components of a Computer System is:
Input Devices Processing Devices
Output Devices Storage Devices
QUESTION NO.02:-Explain the term Hardware and Software.
HARDWARE
The physical components of the Computer system are called Computer
hardware. These parts are seen and touched. Monitor, keyboard and Printers
are the examples of the Computer Hardware.
SOFTWARE
A set of instructions grouped into programs that make the Computer to
function in desired ways is called software.
A Computer System becomes useful when both Software and Hardware
are properly combined.
QUESTION NO.03:-Define the following terms Data, Information and Program.
DATA
The collections of facts or figures in raw form that are not used for
decision-making purpose are called data. These raw facts are entered into
GOVERNMENT POSTGRADUATE COLLEGE 2
JHANG
Department of Computer Science
JHANG
Department of Computer Science
++
QUESTION NO.05:-What is the structure of C -Language program?
STRUCTURE OF C-LANGUAGE PROGRAM
The format or way according to which a computer program is written is
called the structure of C++-Language program. The structure of C++ Program
consists of 3 main parts. These parts are given below.
Preprocessor Directives. The main( ) function.
C statements.
++
EXPLANATION
In order to explain the above written three parts, consider the small
program written in C++ language.
Header File
# include<conio.h> Preprocessor
# include<iostream.h> Directives
void main ( ) Main Function
{ Begin
clrscr( );
cout<<" Muhammad Saleem Raza "<<endl;
cout<<"M.Sc. Computer Science "<<endl;
cout<<"University of Agriculture Faisalabad"<<endl; Statements
getch ( );
Statements
} End
Terminator
Escape Sequence used to move cursor to the start of new line.
JHANG
Department of Computer Science
Q.07:-What are header files? For what purpose they are used?
HEADER FILES
Header files are the part of C++ compiler and contain the definitions of the
standard library functions. The preprocessor Directive "include" is used to
add header files into the program. The name of the header file is written
between two angle brackets (<>) after "include" Directives. The header file
can also be written in double quotes.
C++ language has number of header files in which Library Functions are
defined. A header file must be included at the start of program before calling
its function in the program. For Example math.h header file contains the
definitions of the mathematical functions available in C++ language. So in
order to use the mathematical formulae in the program, it is necessary to
add this header file in the program. Syntax of including header file in the
program is given:
#include< Header file name> or
#include "Header file name"
Q.08:-Write a note on main ( ) function in the C++ program.
THE main ( ) FUNCTION
The main( ) function indicates the beginning of the program written in
the C++ language. The main( ) function must be included in every C++
program. When a C++ language program is executed, the control directly goes
to the main ( ) function and starts executing the statements written with in
the main( ) function.
JHANG
Department of Computer Science
JHANG
Department of Computer Science
Compilers
Compilers convert high-level language code to machine (object) code in
one session. Compilers can take a while, because they have to translate high-
level code to lower-level machine language all at once and then save the
executable object code to memory. A compiler creates machine code that
runs on a processor with a specific Instruction Set Architecture (ISA), which
is processor-dependent.
Interpreters
Another way to get code to run on your processor is to use an
interpreter, which is not the same as a compiler. An interpreter translates
code like a compiler but reads the code and immediately executes on that
code, and therefore is initially faster than a compiler. Thus, interpreters are
often used in software development tools as debugging tools, as they can
execute a single in of code at a time. Compilers translate code all at once and
the processor then executes upon the machine language that the compiler
produced. If changes are made to the code after compilation, the changed
code will need to be compiled and added to the compiled code (or perhaps
the entire program will need to be re-compiled.) But an interpreter, although
skipping the step of compilation of the entire program to start, is much
slower to execute than the same program that’s been completely compiled.
Assemblers
An assembler translates a program written in assembly language into
machine language and is effectively a compiler for the assembly language,
but can also be used interactively like an interpreter. Assembly language is a
low-level programming language. Low-level programming languages are less
like human language in that they are more difficult to understand at a glance;
you have to study assembly code carefully in order to follow the intent of
execution and in most cases, assembly code has many more lines of code to
represent the same functions being executed as a higher-level language. An
assembler converts assembly language code into machine code (also known
as object code), an even lower-level language that the processor can directly
understand.
Q.12:-Write a note on different features of C++
Features of C ++
JHANG
Department of Computer Science
• Portability
• Powerful
• Rich Library
• Platform Dependent
• Object Oriented
• Case Sensitive
• Compiler Based
• Use of Pointers
• Memory Management
Simple
Every C++ program can be written in simple English language so that it
is very easy to understand and developed by programmer.
Platform dependent
A language is said to be platform dependent whenever the program is
execute in the same operating system where that was developed and
compiled but not run and execute on other operating system. C++ is platform
dependent language.
GOVERNMENT POSTGRADUATE COLLEGE 8
JHANG
Department of Computer Science
When we can copy .exe file to any other computer which contain
window operating system then it works properly, because the native code of
application an operating system is same.
Powerful
C++ is a very powerful programming language, it has a wide verity of
data types, functions, control statements, decision making statements, etc.
GOVERNMENT POSTGRADUATE COLLEGE 9
JHANG
Department of Computer Science
JHANG
Department of Computer Science
Compiler based
C++ is a compiler based programming language that means without
compilation no C++ program can be executed. First, we need compiler to
compile our program and then execute.
Syntax based language
C++ is a strongly tight syntax based programming language. If any
language follow rules and regulation very strictly known as strongly tight
syntax based language. Example C, C++, Java, .net etc. If any language not
follow rules and regulation very strictly known as loosely tight syntax based
language.
Example HTML.
Efficient use of pointers
Pointers is a variable which hold the address of another variable,
pointer directly direct access to memory address of any variable due to this
performance of application is improve. In C++ language also concept of
pointer are available.
Advantage of C++ Programming Language
• Abstract data type defining is very good
++
• C language is efficient having less compiled time.
• It is much suitable for large projects.
Q.13:-Define Debugging. What are the different types of errors in the Computer program?
DEBUGGING
Errors occurring in the program are called Bugs. The process of
detecting and removing errors in the program is called Debugging.
TYPES OF ERROR
There are two types of errors in the Computer Program. These errors
are:
GOVERNMENT POSTGRADUATE COLLEGE 11
JHANG
Department of Computer Science
Syntax Errors
Logical Errors
Run Time Errors
SYNTAX ERRORS
Rules for writing statements in Computer Programming language are
called syntax of the language. Program statements are written strictly
according to these rules. A single mistake in these rules causes an error.
This error is called Syntax Error. Compiler detects these errors. It does not
compile the program that contains syntax errors. These errors are easy to
locate and remove.
LOGICAL ERRORS
Errors occurring in the logic of the Computer Program are called
Logical Errors. Compiler cannot detect these errors. A program with logical
errors runs correctly but it provides wrong results. These errors are most
difficult to locate and remove. To detect the logical errors, all units of the
program are examined separately.
Run-Time Errors:
Errors which occur during program execution(run-time) after
successful compilation are called run-time errors. One of the most common
run-time error is division by zero also known as Division error. These types
of error are hard to find as the compiler doesn’t point to the line at which
the error occurs.