COMP132 Computer Programming

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In computer architecture, what is the primary role of the operating system?

  • To act as a compiler for high-level programming languages.
  • To manage the computer's resources and provide an interface for applications. (correct)
  • To directly manipulate hardware components for specific tasks.
  • To function as a linker for combining object code.

What is the crucial difference between main memory (RAM) and secondary memory (e.g., a hard drive) in a computer system?

  • Main memory is used for permanent data storage, while secondary memory is volatile.
  • Secondary memory directly executes programs, while main memory only stores data.
  • Main memory provides faster access and stores active programs, while secondary memory offers larger, persistent storage. (correct)
  • There is no difference; the terms are interchangeable.

Which of the following accurately describes the role of a compiler in the context of programming?

  • It translates assembly language into machine code.
  • It translates high-level language code into machine code or an intermediate representation. (correct)
  • It combines different object files into a single executable program.
  • It manages the computer's hardware resources.

What are the key features that define a high-level programming language?

<p>Abstraction from machine details, readability, and ease of use. (B)</p> Signup and view all the answers

What role does the linker play in the software development process?

<p>Combining object code files and libraries into an executable program. (B)</p> Signup and view all the answers

Which of the following is the correct order of steps to run a C++ program?

<p>Compiling, linking, executing (D)</p> Signup and view all the answers

What is the significance of the iostream header in C++ programming?

<p>It provides standard input and output functionalities. (A)</p> Signup and view all the answers

What is the purpose of comments in C++ code?

<p>To provide explanations and improve the program's readability. (A)</p> Signup and view all the answers

Which of the following is NOT a valid C++ identifier?

<p>1stVariable (B)</p> Signup and view all the answers

What does it mean for C++ to be a 'case-sensitive' language?

<p>Uppercase and lowercase letters are treated as distinct characters. (A)</p> Signup and view all the answers

In C++, what is the primary function of a 'data type'?

<p>To specify the kind of data a variable can hold. (A)</p> Signup and view all the answers

Which of the following is a primitive data type in C++?

<p>Int (A)</p> Signup and view all the answers

Which of the following primitive data types can be modified by signed and unsigned?

<p><code>char</code> (B)</p> Signup and view all the answers

In C++, what is the difference between declaring and defining a variable?

<p>Declaration introduces the variable's name and type, while definition allocates memory and can assign an initial value. (B)</p> Signup and view all the answers

What is the primary characteristic of a local variable in C++?

<p>It only exists within the block it is declared. (D)</p> Signup and view all the answers

What distinguishes a static variable from an instance variable in C++?

<p>A static variable is shared among all objects of the class, while each object has its own copy of instance variables. (A)</p> Signup and view all the answers

Consider the code: #define SIZE 10. What is SIZE?

<p>A preprocessor definition. (A)</p> Signup and view all the answers

Which header file is essential for using stringstream in C++?

<p><code>sstream</code> (B)</p> Signup and view all the answers

Which of the following correctly describes the use of getline() function?

<p>Primarily to read a line of text from an input stream (D)</p> Signup and view all the answers

Which is an assignment operator?

<p>= (A)</p> Signup and view all the answers

What is the result of the expression x += 5 if x is initially 10?

<p>15 (B)</p> Signup and view all the answers

What does cout << "Total: " << total << endl; do?

<p>outputs the string literal &quot;Total: &quot; followed by the variable total and a new line (A)</p> Signup and view all the answers

Which library does cout belong to?

<p>Both A and B (B)</p> Signup and view all the answers

How can you add a single line comment in C++?

<p>//comment (C)</p> Signup and view all the answers

How can you add a multi-lined comment in C++?

<p>/<em>comment</em>/ (A)</p> Signup and view all the answers

What does the following operation mean? <<

<p>Output or insertion operator (B)</p> Signup and view all the answers

Which is an example of an arithmetic operator

<ul> <li>(B)</li> </ul> Signup and view all the answers

Which of the following is a valid conditional statement in C++?

<p>if (x &gt; y) (B)</p> Signup and view all the answers

What is the purpose of the else keyword in an if-else statement?

<p>To specify a block of code to execute if the condition is false. (D)</p> Signup and view all the answers

Which of the following best describes a 'nested if statement'?

<p>An <code>if</code> statement inside another <code>if</code> statement. (D)</p> Signup and view all the answers

What happens if the break statement is omitted from a case in a switch statement?

<p>Execution continues to the next <code>case</code>. (A)</p> Signup and view all the answers

What should be included in the parentheses of a switch statement

<p>a variable (C)</p> Signup and view all the answers

What is the outcome of the following conditional logic: int x = 5; if (x > 10) cout << "Greater than 10"; else if (x < 5) cout << "Less than 5"; else cout << "Between 5 and 10";?

<p>&quot;Between 5 and 10&quot; (A)</p> Signup and view all the answers

What statement applies to the data-type of the expression in the switch statement?

<p>Should result in a constant value (B)</p> Signup and view all the answers

What type of decision results from the logical || operator?

<p>results in <code>True</code> if either expression is true (A)</p> Signup and view all the answers

Which of the following is a valid file extension for source files?

<p>*cpp (B)</p> Signup and view all the answers

What code is generated by the compiler program?

<p>Object code (A)</p> Signup and view all the answers

What is the proper syntax #include ?

<p>This line is ok unless there is an error in the code. (B)</p> Signup and view all the answers

Flashcards

Program

A set of instructions for a computer to follow.

Hardware

The physical machines that make up a computer installation.

PC (Personal Computer)

A relatively small computer designed for one person.

Workstation

Larger, more powerful PC, suitable for industrial tasks.

Signup and view all the flashcards

Mainframe

Large computer shared by many users, requires support staff.

Signup and view all the flashcards

Network

Connects computers to share resources and information.

Signup and view all the flashcards

Input Device

Device allowing input of information into a computer.

Signup and view all the flashcards

Output Device

Device allowing output of information from computer to you.

Signup and view all the flashcards

Memory

Computer's method of storing data for immediate use.

Signup and view all the flashcards

Main Memory

Important memory that stores programs being executed.

Signup and view all the flashcards

Memory Locations

A long list of numbered locations (bytes).

Signup and view all the flashcards

Bit

Digit that is zero or one.

Signup and view all the flashcards

Byte

Eight bits.

Signup and view all the flashcards

Address

Number that identifies a byte.

Signup and view all the flashcards

Secondary Memory

Stores information permanently.

Signup and view all the flashcards

RAM (Random Access Memory)

Main memory, allows direct access.

Signup and view all the flashcards

Sequential access

Needs sequential searching.

Signup and view all the flashcards

CPU (Central Processing Unit)

Processor, brain of computer.

Signup and view all the flashcards

Operating System

Allocates computer's resources.

Signup and view all the flashcards

Program

Set of instructions for computer.

Signup and view all the flashcards

Data

Input to computer.

Signup and view all the flashcards

Running a program

Giving a program and data for computer.

Signup and view all the flashcards

Execute the program

Execute the program on the data.

Signup and view all the flashcards

High-level languages

Resemble human languages.

Signup and view all the flashcards

Low-level language

Language computer understands.

Signup and view all the flashcards

Assembly language

Add two numbers, put result.

Signup and view all the flashcards

Machine language

Form of zeros & ones.

Signup and view all the flashcards

Compiler

Translates high to machine language.

Signup and view all the flashcards

Source program (source code)

Input program for compiler.

Signup and view all the flashcards

Object program (object code)

Output program produced by compiler.

Signup and view all the flashcards

Linker

Combines program pieces.

Signup and view all the flashcards

// comment

Inserting comments.

Signup and view all the flashcards

Namespace std

Groupings of elements in the standard C++ library.

Signup and view all the flashcards

Using namespace std

Give elements access to the std namespace.

Signup and view all the flashcards

Variable

Memory portion allocated for to store values.

Signup and view all the flashcards

Identifier

Name identifying a variable.

Signup and view all the flashcards

Reserved Words

Keywords.

Signup and view all the flashcards

Case Sensitive

It distinguishes variables named in capitals to non-capitals.

Signup and view all the flashcards

Data Type

Define to restrict the type of data to be stored..

Signup and view all the flashcards

Primitive Data Types

Built-in data variables.

Signup and view all the flashcards

Study Notes

  • Technological University of the Philippines Visayas is located in Talisay, Negros Occidental
  • The learning module provides information about Computer Programming using COMP132
  • The module is for education purposes only and not for sale or reproduction
  • The Technological University of the Philippines seeks to be a premier state university recognized for excellence in engineering and technology in the ASEAN region
  • The University aims to provide higher and advanced education and training in industries and technology, leading to certificates, diplomas, and degrees
  • It is committed to quality higher education, relevant research, and extension projects while adhering to core values like transparency, unity, professionalism, integrity, accountability, nationalism, and shared responsibility

Table of Contents Overview

  • The course description details computer systems operation, information storage and communication
  • Course outcomes including understanding computer systems from a programmer's viewpoint, recognizing hardware/software continuity, and employing Boolean operators
  • General class rules and grading system
  • Learning guides for weeks 1-4 with topics, competencies and technical information
  • List of cited References
  • About the Authors

Course Description

  • Provides a programmer's view of how computer systems execute programs, store information, and communicate
  • Discussions include information representation in computers, computer organization structure, I/O and memory systems
  • Covers instruction sequencing, machine-level code, compiler optimization, performance evaluation, computer arithmetic, memory management, networking, and concurrent computation
  • Includes recent developments in software, operating systems, networks, the internet, and computing

Course Outcomes

  • Develop a detailed understanding of computer systems from a programmer's perspective, covering machine and assembly languages up to operating services.
  • Recognize hardware/software continuity to create reliable products
  • Identify types of data communications, their performance ranges, and device access coordination.
  • Represent numerical and non-numerical data using standard encoding methods.
  • Derive logical operations using Boolean operators.
  • Appreciate instruction set architecture (ISA), machine-level instruction functionality, resource use, and the relationship to micro-architecture.

General Guidelines/Class Rules

  • Make-up exams/quizzes require prior professor approval and exceptional circumstances, following university policy for excused absences
  • Students cannot leave the classroom once class starts unless it is extremely necessary, otherwise they will be marked as absent
  • Strict compliance expected with dress code, and rules on class tardiness and attendance
  • Cell phones and e-gadgets must be silenced during class
  • Late homework/projects not accepted, honesty and integrity are expected, with academic dishonesty leading to failure

Grading System

  • Average of examinations accounts for 30% of final grade
  • Average of weekly assessment is worth 70%
  • Prelim Grade comprises 70% of weekly assessments (Weeks 1-4) and 30% of Midterm Exam Grade
  • Midterm Grade is made up of 70% weekly assessments (Weeks 5-10) and 30% Midterm Exam Grade
  • End Term Grade uses 70% weekly assessments (Weeks 11-14) with 40% End Term Exam Grade
  • Final Grade calculates to be the average of Prelim Grade, Midterm Grade, as well as End term Grade divided by 3
  • Passing grade for the course is 5.0

Learning Guide

  • Week 1 topics include: Major Components of a Computer Systems, Overview of Computer System Organization, Data Representation, Binary Operations, Arithmetic Sequential, Boolean Logic
  • Upon completion of this Learning Module, one will be able to:
    • Identify the major components of a computer system
    • Describe the Computer System Organization
    • Discuss the Data Representation

Major Components of a Computer System

  • A program is a list of instructions for a computer
  • A computer's programs are referred to as its software
  • Hardware refers to the physical machines making up a computer installation
  • Software aids in computer and program tasks
  • PCs, workstations, and mainframes are the three main classes of computers
  • A PC (personal computer) is relatively small, used by one person
  • A workstation acts as a large and far more potent PC
  • Mainframes are large computers typically with shared users requiring specialist support
  • Network contain multiple connected computers to share information, printers and other resources
  • For learning programming, the basic computer configuration is the same across PCs, mainframes, and workstations
  • The input device(s), the output device(s), the processor, main memory, as well as the secondary memory are key hardware components in computer systems
  • Keyboard and mouse serve as input devices

Software

  • Communicate with a computer via the operating system
  • An operating system allocates computer resources to tasks
  • Common operating systems include UNIX, DOS, Linux, Windows, Macintosh, and VMS
  • Input for computer consists of program and data
  • Program gives a set of instructions for the computer to perform with some type of processing of the data
  • 'Data' broadly means computer information
  • When a program runs or executes, the computer follows instructions on the supplied data
  • Compilers translate high-level language into a machine language to be understood and executed
  • The input of a compiler is called a source program (or source code), and the translated version that is produced is called an object program of object code
  • The linker combines the object code for all program pieces, with the object code that the compiler produced
  • Charles Babbage designed the first programmable computer, with Ada Augusta often called the first computer programmer

Learning Guide Week 2

  • Consists of the following topics, Basics of C++, Structure of a program, Data Types, and Variables
  • Upon completion of this Learning Module, one will be able to:
    • Identify the basic program structure of C++
    • Use comments for program readability
    • Differentiate Data types from Variables
    • Use Data types and naming variables properly
    • Identify and differentiate the three(3) types of variables
  • Typical first program beginner will write is "Hello World", which simply prints "Hello World" to your computer screen
  • "//" - indicates a comment by the programmer for explanation
  • "#include " directs preprocessor for input and output operations
  • "int main ()" - initializes a function
  • Functions are a group of code statements given a name
  • main is a special primary function, which executes code within
  • "{ and }" opens up and closes the function for definition
  • "std::cout << "Hello World!"; - indicates an expression in C++
  • std::cout which identifies the standard character output device (usually, this is the computer screen).
  • insertion operator (<<), which indicates that what follows is inserted into std::cout.
  • ("Hello world!") - is the content inserted the output into the standard output
  • (;) Semicolon Character which marks the end of the statement, and is a syntax requirement
  • It would be the same meaning or effect if written "int main(){std::cout << "Hello World!"; }
  • "//" is a line comment, whereas "/* block comment */" is a block comment that can incorporate multiple lines

Variables And Types

  • Includes the explicit qualification such as using declarations
  • std namespace all elements can be defined without the use f prefix
  • Coding, compiling, as well as executing multiple lines of code, obtains a simple text sentence
  • Variables are essential to any form of programming in regard to producing outcomes and saving work
  • Can add two numbers at the same time using various variables or memory
  • We can now define variable as a portion of memory to store a value
  • A valid identifier is a sequence of one or more letters, digits, or underscore characters (_). However cannot begin with a digit.
  • The C++ language is a "case sensitive" language

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Use Quizgecko on...
Browser
Browser