[go: up one dir, main page]

0% found this document useful (0 votes)
366 views5 pages

CSC 221

This document provides an overview of programming languages and concepts. It discusses low-level languages like machine language and assembly language that computers can directly understand versus high-level languages that require translation. Translators like assemblers, compilers, and interpreters are described that convert between language levels. Object-oriented programming concepts are introduced, and C and C++ are given as examples of structural and object-oriented languages respectively. Assignments are provided to write programs demonstrating basic concepts.

Uploaded by

helon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
366 views5 pages

CSC 221

This document provides an overview of programming languages and concepts. It discusses low-level languages like machine language and assembly language that computers can directly understand versus high-level languages that require translation. Translators like assemblers, compilers, and interpreters are described that convert between language levels. Object-oriented programming concepts are introduced, and C and C++ are given as examples of structural and object-oriented languages respectively. Assignments are provided to write programs demonstrating basic concepts.

Uploaded by

helon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSC 221

Introduction to programming in C/C ++


Types of languages
1. High level language
2. Low level language eg
⁃ machine language
⁃ Assembly language
Machine language does not refer to editor or a compiler because it’s the language computer can
directly understand.
⁃ It uses binary numbers.
⁃ It is a machine dependent code.
⁃ They are difficult to debug, run and write.
⁃ It’s occupies space.
Assembly language: This uses symbolic or mnemonic code.
⁃ This language uses a translator called assembler.
⁃ Assembly language is also machine dependent language.
⁃ It’s is also difficult to learn and debug therefore it is error prone.
⁃ Assembly language can also be classified by some authors as middle language.
⁃ It is also the foundation of other programming language.
⁃ It’s also a structural program.
High level language is a language that uses human readable code. The codes of high level can only
be understood by the writer.
The machine don’t understand high level language directly therefore it require a translator.
Examples
⁃ Python
⁃ Java
⁃ Java script
⁃ PHP
⁃ Swift
Translator : This is a software that convert a language from one language to another.I.e high to
high( cross complication), high -low, low to high.
Types of translator
1. Assembler
2. Compiler
3. Interpreter
Assembler : It is a software that convert all symbolic mnemonic codes at once into machine code/
object code.
⁃ Therefore the assemble is very fast In its complication but difficult to debug.
⁃ assembler is a end code as machine dependent.
⁃ It only complies assembly language.
Complier is a software or a translate that convert all high level sources codes into machine code or
object codes .
⁃ Therefore a Complier is very fast in its compilation end.
⁃ It is also machine dependent for it end compile code .
⁃ It is not a universal code (N- code).
⁃ Machine code came from compilable then assembly code.
⁃ It is also prone and difficult to debug
Examples of programs that uses compiler: C, C++, C#, Pascal.
Interpreter
This is a software that convert high level language into a bye-code. This conversation is done line
by line or sentence by sentence.
⁃ The interpreter is very slow in its compilation but easy to debug and less error prone.
⁃ It’s produces an end code in which is universal not machine dependent.
Examples of language that run in interpreter:
1. Java
2. Python
3. BASIC ( Beginners all purpose symbolic instruction code)
4. Visual Basic
5. JavaScript
6. FORTAN
Language comes in 2 categories base on its uses which are :
1. General purpose e.g Machine learning, BASIC, PASCAL, etc
2. Special purpose e.g Java, FORTRAN, etc
High level language is broken into 2 :
1. Structural programming language
2. Object oriented programming language
Examples of structural programming language are :
⁃ BASIC language
⁃ C language
⁃ PASCAL
⁃ FORTRAN
⁃ Math lab ( confirm online )
Examples of Object oriented programming language are:
⁃ Java
⁃ C++
⁃ Python
⁃ C#
⁃ . Net
⁃ VB Net
C language is under structural, object orientated programming language
Features of Object oriented programming language
Note there are two types which are :
1. Static Object oriented programming language:These are ones that require object to be
declared before its usage e.g C++, Java ,C#,.Net, VisualBasic and VB Net etc.
2. Dynamic Object oriented programming language: These are once that does not
necessarily need an object to be declared before usage. They are Python,
Features
object, class, inheritance, polymorphism, data hiding and message passing .
C language
# include <Stdio.h>
( ) global class or main class
Int main void(){
// hi it is my first c- program
Printf(“”)
Scanf(“”)
Return 0;
}
C++ language
# include <10 stream>
Using namespace std;
Int main void(){
Cout<<“ “;
Con>>” ‘;
Return 0;
}

Stdio.h=(Standard input output for high language strings)


Note: OOP have 2 classes
1. Global/local class
2. Main/sub class

Global class: Is a place where the main function for the sub class is written .

Int main void is the part of the program that embodifies or Carries the local executable codes. It is
the place where the code to run is written.
There are two type of comments in all static OOP . Comment can be written at any portion of the
program, comment are not part of the program . It’s mainly for readers, direction or guides not a
program , may/ may not contain a comment and for the clarity of any reader of the code, it is good
to include comments.
Types of comments
1. Single line / expression comment : it is written using // .
2. Multiple lines / multiple expressions comment : This kind contain two or more expressions
but of expressions/*⸻⸺-*/
Print: it is used to display result of a executed code
Scanf : Scanf is used as users input code , the user can make changes in the code … Scanf (“”)
return 0 : return 0 is an instruction code in c language that after execution has been performed and
the code has success run, it instantly compiler to return the void value by telling the programmer tu
press any key to restart or continue.
It’s important that every written code in c must include the curly brace of the return 0;
Note : every expression in c language or others object oriented program ( the static type must end
in semi colon ) .
Example :
Int main void( ){
// writing my first programming
Int a;
Int b;
Int c;
a+b=c;
printf(“%d,c”,c);

return 0;
}

A character set is defined as any alphabet digit or symbols used in representing an information in a
programming language is called character set.
It’s also symbols called Identifiers.
Data type
There are 4 kinds of data type :
1. Basic built in data type eg float, Int , Boolean, character, double
2. Enumeration data type
3. Derived data type eg pointer , array structure
4. Void data type. eg void
5. Constant
Work done
Write a code to calculate the multiple of 3 numbers
Assignment
Write a program to calculate average of 3 numbers , if this numbers were float.
Assignment
Name the features of OOP .

Work
1. Write a program to show two numbers which is bigger

2. Write a program to calculate the area of a trapezium ..

3. Write a program that will do incremental .

4. Write a program that will do a while loop

Write a code to take user input to calculate the area of a trapezium

Write a while do loop to display a count >= 30. Using a = 3

Assignments
⁃ Write a short note on the following small talk simula , C++, c language, Java , C# ,.net ,
VB. Net , Visual Basic , fortan and cobol
⁃ Write short note on two classes of OOP with examples .

You might also like