computer programming module, Assignments of Computer science

computer programming module week 1 to week 4

Typology: Assignments

2022/2023

Uploaded on 01/29/2023

KarenMaeAbejuro
KarenMaeAbejuro 🇵🇭

4 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMPUTER COMMUNICATION DEVELOPMENT INSTITUTE
SIKATUNA ST., OLD ALBAY, LEGAZPI CITY
TEL. NO. 7421570
MODULES FOR
ONLINE LEARNING MANAGEMENT
SYSTEM
(A.Y 2021 – 2022)
Subject:
ACT-C 102 – FUNDAMENTALS OF
PROGRAMMING (Comprog 1)
Bachelor of Science in Information Technology/Information System & Computer Science Department
Page 1 of 19
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download computer programming module and more Assignments Computer science in PDF only on Docsity!

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570

MODULES FOR

ONLINE LEARNING MANAGEMENT

SYSTEM

(A.Y 2021 – 2022)

Subject:

ACT-C 102 – FUNDAMENTALS OF

PROGRAMMING (Comprog 1)

Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Noted by: Approved by: Engr. Jay A. Dadea, MIT Ramon Severo. Ll. Moraleda. LLB School Dean Administrator TABLE OF CONTENT Page Title Page......... 1 Course Description........ 3 Objectives......... 3 Learning Outcome........ 3 WEEK 1 – (What is computer programming?) History of computer programming...... 3 Definition of computer programming.... 4 Importance of computer programming.... 6 Purpose of computer programming.... 6 WEEK 2 – (Imperative and Declarative Programming Language) Imperative Programming Language.... 8 Declarative Programming Language...... 9 Imperative vs. Declarative...... 10 WEEK 3 – (Data Types) Definition........ 12 Common Data Types...... 13 Importance of Data Types...... 14 WEEK 4 – (C++ Operators) Different types of C++ Operators..... 17 Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Programmable devices have existed for centuries. As early as the 9th century, a programmable music sequencer was invented by the Persian Banu Musa brothers, who described an automated mechanical flute player in the Book of Ingenious Devices. In 1206, the Arab engineer Al-Jazari invented a programmable drum machine where a musical mechanical automaton could be made to play different rhythms and drum patterns, via pegs and cams. In 1801, the Jacquard loom could produce entirely different weaves by changing the "program" – a series of pasteboard cards with holes punched in them. Code-breaking algorithms have also existed for centuries. In the 9th century, the Arab mathematician Al-Kindi described a cryptographic algorithm for deciphering encrypted code, in A Manuscript on Deciphering Cryptographic Messages. He gave the first description of cryptanalysis by frequency analysis, the earliest code-breaking algorithm. The first computer program is generally dated to 1843, when mathematician Ada Lovelace published an algorithm to calculate a sequence of Bernoulli numbers, intended to be carried out by Charles Babbage's Analytical Engine. Data and instructions were once stored on external punched cards, which were kept in order and arranged in program decks. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 SAMPLE PUNCHED CARD In the 1880s Herman Hollerith invented the concept of storing data in machine-readable form. Later a control panel (plug board) added to his 1906 Type I Tabulator allowed it to be programmed for different jobs, and by the late 1940s, unit record equipment such as the IBM 602 and IBM 604, were programmed by control panels in a similar way, as were the first electronic computers. However, with the concept of the stored-program computer introduced in 1949, both programs and data were stored and manipulated in the same way in computer memory. DEFINITION OF COMPUTER PROGRAMMING Computer programming (often shortened to programming) is a process that leads from an original formulation of a computing problem to executable computer programs. Programming involves activities such as analysis, developing understanding, generating algorithms, verification of requirements of algorithms including their correctness and resources consumption, and implementation (commonly referred to as coding) of algorithms in a target programming language. Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: analysis, generating algorithms, profiling algorithms' accuracy and resource consumption, and the implementation of algorithms in a chosen programming language (commonly referred to as coding). The source code of a program is written in one or more languages that are intelligible to programmers, rather than machine code, which is directly executed by the central processing unit. The purpose of programming is to find a sequence of instructions that will automate the performance of a task (which can be as complex as an operating system) on a computer, often for Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Purpose of programming is to make human life better and easier. It does so because the computer programs can perform a set of tasks once we define them clearly. Hence we can use a computer to solve our day to day problems by providing it clear instructions rather than solving it by ourself. This saves a lot of human time and energy so that we can concentrate on other challenging tasks that cannot be automated. Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: analysis, generating algorithms, profiling algorithms' accuracy and resource consumption, and the implementation of algorithms in a chosen programming language (commonly referred to as coding). The source code of a program is written in one or more languages that are intelligible to programmers, rather than machine code, which is directly executed by the central processing unit. The purpose of programming is to find a sequence of instructions that will automate the performance of a task (which can be as complex as an operating system) on a computer, often for solving a given problem. Proficient programming thus often requires expertise in several different subjects, including knowledge of the application domain, specialized algorithms, and formal logic. Tasks accompanying and related to programming include: testing, debugging, source code maintenance, implementation of build systems, and management of derived artifacts, such as the machine code of computer programs. These might be considered part of the programming process, but often the term software development is used for this larger process with the term programming, implementation, or coding reserved for the actual writing of code. Software engineering combines engineering techniques with software development practices. Reverse engineering is a related process used by designers, analysts and programmers to understand and re-create/re-implement. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Synthesis and Conclusions: The lesson presented is about the history of Programming from where it starts and when it starts. The lesson above also talks about the definition of computer programming, it’s purpose and importance in our daily life. Activity/Exercise:

  1. What are the benefits of computer programming in everyday life?
  2. What is the importance of computer programming? Explain in your own words.
  3. In your own opinion, how does computer programming help you in your everyday life? Chapter 1 – Imperative and Declarative Programming Language Course Description: The course's main objective is to teach students the difference of Imperative and Declarative Programming Language. The lesson also gives the student the knowledge on how an imperative and declarative programming language works. Objectives:
    1. To learn the meaning of imperative and declarative programming language
    2. For the student to be able to differentiate imperative to declarative programming language. Week #: 2 Learning Outcomes: At the end of the session, the student is expected to:
    3. Explain the difference between imperative and declarative programming languages.
    4. List down all the important details about the topic.
    5. Analyze and understand the advantages and disadvantages of the imperative and declarative programming language. Discussion: IMPERATIVE PROGRAMMING LANGUAGE Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 accomplish it as a sequence of the programming language primitives (the how being left up to the language's implementation). This is in contrast with imperative programming, which implements algorithms in explicit steps. Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming may greatly simplify writing parallel programs. Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, functional programming, and configuration management systems. Imperative vs. Declarative Imperative programming contrasts with declarative programming, in which how a problem is solved is not specifically defined, but instead focuses on what needs to be solved. Declarative programming provides a constant to check to ensure the problem is solved correctly, but does not provide instructions on how to solve the problem. The exact manner in which the problem is solved is defined by the programming language’s implementation through models. Declarative programming is also called model-based programming. Functional, domain-specific (DSL) and logical programming languages fit under declarative programming, such as SQL, HTML, XML and CSS. A simplified example to distinguish between an imperative and declarative approach is to think of giving driving directions. An imperative approach would provide step by step instructions on how to arrive at a given destination. A declarative approach would provide the address of the destination, without concern about how it’s found. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 The models from which declarative programming gets its functions are created through imperative programming. As better methods for functions are found through imperative programming, they can be packaged into models to be called upon by declarative programming. Imperative programming languages differ from declarative languages on one fundamental point: imperative programming focuses on the “how”, declarative programming on the “what” but what does that mean? Imperative programming languages are composed of step-by-step instructions (how) for the computer. They describe explicitly which steps are to be performed in what order to obtain the desired solution at the end. By contrast, in declarative programming, the desired result (what) is described directly. This becomes clearer when using a cooking analogy for illustration: imperative languages provide recipes; declarative languages contribute photos of the finished meal. In declarative languages, the source code remains very abstract in terms of the specific procedure. To get to the solution, an algorithm is used which automatically identifies and applies appropriate methods. This approach has numerous advantages: Programs can be written much more quickly, and applications are also very easy to optimize. If a new method is developed in the future, the abstract instructions in the source code mean that the algorithm can easily utilize the newer method. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Objectives:

  1. To learn what is a data type.
  2. To learn the difference between each data type. Week #: 3 Learning Outcomes: At the end of the session, the student is expected to:
  3. Explain the importance of data type.
  4. List down all the importance about the topic.
  5. Identify and understand the differences of each data type. Discussion: DATA TYPES OVERVIEW A data type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support various types of data, including integer, floating point, character or string, and Boolean. Definition In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support basic data types of integer numbers (of varying sizes), floating- point numbers (which approximate real numbers), characters and Booleans. A data type constrains the values that an expression, such as a variable or a function, might take. This data type defines the operations that can be done on the data, the meaning of the data, and the way Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 values of that type can be stored. A data type provides a set of values from which an expression (i.e. variable, function, etc.) may take its values. Our interactions (inputs and outputs) with a program are treated in many languages as a stream of bytes. These bytes represent data that can be interpreted as representing values that we understand. Additionally, within a program, we process this data in various ways such as adding them up or sorting them. Data types are used within type systems, which offer various ways of defining, implementing, and using them. Different type systems ensure varying degrees of type safety. Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Common data types Integer An integer data type represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers and different programming languages. Character Stores strings of letters, numbers, and symbols. Data types CHARACTER (CHAR) and CHARACTER VARYING (VARCHAR) are collectively referred to as character string types, and the values of character string types are known as character strings. String Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 concept of a “type-less” variable, for example. Furthermore, the type of a value determines what operations are allowed on it. An operation allowed on one type might not be allowed on another. Our interactions (inputs and outputs) with a program are treated in many languages as a stream of bytes. These bytes represent data that can be interpreted as representing values that we understand. Additionally, within a program, we process this data in various ways such as adding them up or sorting them. This data comes in different forms. Examples include:

  • your name – a string of characters
  • your age – usually an integer
  • the amount of money in your pocket – usually a value measured in dollars and cents (something with a fractional part) A major part of understanding how to design and code programs is centered in understanding the types of data that we want to manipulate and how to manipulate that data. Common data types include: Data Type Represents Examples integer whole numbers floating point (real) fractional numbers string A sequence of characters "Hello world!" Boolean logical true or false true , false The common data types usually exist in most programming languages and act or behave similarly from language to language. Additional complex and/or composite data types may exist and vary from language to language. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 Conclusion and Synthesis: The lesson presented above tackles the importance of data types in a different programming language. This lesson also discusses the uses of each data type and how to use them when it comes to programming. Activity/Exercise:

  1. What are the difference between the given data types?
  2. Define what is a data type in your own opinion.
  3. Research about the other data type use in the programming language and define them. Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 ● Logical Operators ● Bitwise Operators ● Assignment Operators INCREMENT AND DECREMENT OPERATORS Increment and decrement operators are unary operators that add or subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and post-) of each operator with slightly different semantics. The increment operator increases, and the decrement operator decreases, the value of its operand by 1. The operand must have an arithmetic or pointer data type, and must refer to a modifiable data object. Pointers values are increased (or decreased) by an amount that makes them point to the next (or previous) element adjacent in memory. ● The pre-increment and pre-decrement operators increment (or decrement) their operand by 1, and the value of the expression is the resulting incremented (or decremented) value. ● The post-increment and post-decrement operators increase (or decrease) the value of their operand by 1, but the value of the expression is the operand's value prior to the increment (or decrement) operation. LOGICAL OPERATORS Bachelor of Science in Information Technology/Information System & Computer Science Department

SIKATUNA ST., OLD ALBAY, LEGAZPI CITY TEL. NO. 7421570 A logical operator is a symbol or word used to connect two or more expressions such that the value of the compound expression produced depends only on that of the original expressions and on the meaning of the operator. Common logical operators include AND, OR, and NOT. Within most languages, expressions that yield Boolean data type values are divided into two groups. One group uses the relational operators within their expressions and the other group uses logical operators within their expressions. The logical operators are often used to help create a test expression that controls program flow. This type of expression is also known as a Boolean expression because they create a Boolean answer or value when evaluated. There are three common logical operators that give a Boolean value by manipulating other Boolean operand(s). Operator symbols and/or names vary with different programming languages. ARITHMETIC OPERATORS The basic arithmetic operations are addition, subtraction, multiplication and division, although arithmetic also includes more advanced operations, such as manipulations of percentages, square roots, exponentiation, logarithmic functions, and even trigonometric functions, in the same vein as logarithms (prosthaphaeresis). Arithmetic expressions must be evaluated according to the intended sequence of operations. There are several methods to specify this, either—most common, together with infix notation— explicitly using parentheses and relying on precedence rules, or using a prefix or postfix notation, which uniquely fix the order of execution by themselves. Any set of objects upon which all four arithmetic operations (except division by zero) can be performed, and where these four operations obey the usual laws (including distributivity), is called a field. An arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. They are used in common arithmetic and most computer languages contain Bachelor of Science in Information Technology/Information System & Computer Science Department