PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode?

Similar documents
Informatica e Sistemi in Tempo Reale

Chapter One Introduction to Programming

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Sources: On the Web: Slides will be available on:

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Fundamentals of Programming

Chapter 2: Elements of Java

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

AP Computer Science Java Subset

Chapter 13 - The Preprocessor

ECDL / ICDL Spreadsheets Syllabus Version 5.0

CS1010 Programming Methodology A beginning in problem solving in Computer Science. Aaron Tan 20 July 2015

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

arrays C Programming Language - Arrays

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

I PUC - Computer Science. Practical s Syllabus. Contents

Lecture 2 Notes: Flow of Control

CP Lab 2: Writing programs for simple arithmetic problems

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions

Statements and Control Flow

MAT 2170: Laboratory 3

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

The C Programming Language course syllabus associate level

Object Oriented Software Design

So far we have considered only numeric processing, i.e. processing of numeric data represented

Computer Science 281 Binary and Hexadecimal Review

Lecture 1 Introduction to Java

Excel 2003 Tutorials - Video File Attributes

Object Oriented Software Design

C++ Language Tutorial

2015 County Auditors Institute. May Excel Workshop Tips. Working Smarter, Not Harder. by David Scott,

10CS35: Data Structures Using C

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

C++ Programming Language

Access Queries (Office 2003)

Introduction to Python

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

Oracle Database: SQL and PL/SQL Fundamentals

VB.NET Programming Fundamentals

Explain the relationship between a class and an object. Which is general and which is specific?

B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011

Unordered Linked Lists

Java Basics: Data Types, Variables, and Loops

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Computer Programming I

TIP: To access the WinRunner help system at any time, press the F1 key.

INFORMATION BROCHURE Certificate Course in Web Design Using PHP/MySQL

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Tutorial on C Language Programming

McGraw-Hill The McGraw-Hill Companies, Inc.,

3 IDE (Integrated Development Environment)

Microsoft Access 2010 Part 1: Introduction to Access

Oracle Database: SQL and PL/SQL Fundamentals NEW

Chapter 2 Introduction to Java programming

Excel 2007 Tutorials - Video File Attributes

J a v a Quiz (Unit 3, Test 0 Practice)

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

COMPUTER SCIENCE 1999 (Delhi Board)

Netezza SQL Class Outline

Passing 1D arrays to functions.

Common Beginner C++ Programming Mistakes

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Microsoft Access 3: Understanding and Creating Queries

#820 Computer Programming 1A

JavaScript: Control Statements I

Oracle Database: SQL and PL/SQL Fundamentals

CS 241 Data Organization Coding Standards

Introduction to Java

Pseudo code Tutorial and Exercises Teacher s Version

Introduction to Visual C++.NET Programming. Using.NET Environment

3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs

Pemrograman Dasar. Basic Elements Of Java

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Excel: Introduction to Formulas

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

C++ INTERVIEW QUESTIONS

Check out our website!

Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

Answers to Review Questions Chapter 7

Using This Reference Manual Chapter 1 to Issue ACL Commands

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Create a New Database in Access 2010

An Introduction to the WEB Style of Literate Programming

Example of a Java program

Stacks. Linear data structures

Transcription:

PE1 Worksheet Problem solving 1) What are the four stages of problem solving by programming? What shall be done in each stage? Stage 1: Stage 2: Stage 3: Stage 4: 2) What is the top-down design strategy about? 3) What are the three control structures for writing an algorithm in pseudocode? C Programming 1) Write the preprocessor directives for the following purposes: To use input / output functions: To use math functions: To use PI in place of 3.14159: 2) What are the four common data types in C? 3) What are the criteria for valid variable/function names? 4) Give three examples of meaningful variable names. 5) Under what circumstances are single-letter variable names (e.g., i) acceptable? 6) Write a statement for declaring an integer variable result and initializing it to 0. 1

7) What are the format specifiers for the four common data types in printf()? 8) Write a statement for printing the message "Hello World!". 9) Write a statement for printing the value of a double variable area with two decimal places. 10) What are the format specifiers for the four common data types in scanf()? 11) Write a statement for reading in a value into a double variable radius. 12) What are the escape sequences for the following characters? New line: Tab: Double quote: Percent: 13) What are the five common math operators in C and their associativity? 14) Which of the operators in 13) is not a basic arithmetic operation? How does it work? Give two examples in which this operator is useful. 15) What are the four increment/decrement operators in C and their associativity? 16) How are the two increment operators in 15) different? Give one example in which they lead to different results in computation. 17) What are the five assignment shorthand operators in C and their associativity? 18) Write an assignment statement using one of the assignment shorthand operators and rewrite it into another statement without using the shorthand. 19) List the operators in 13), 15) and 17), as well as the assignment operator "=" in ascending order of precedence. 2

20) Write an arithmetic expression (without variables) in which truncation occurs. 21) Rewrite the expression in 20) in two different ways to avoid the truncation. With type-casting: Without type-casting: 22) Assuming that an int variable num has been declared, write an assignment statement to assign a value to this variable in which truncation occurs. 23) Write down the math functions that you have used so far. 24) What are the four components of a function definition? 25) How to indicate the fact that a function does not return any value? 26) Given a function header (i.e., the first line of a function definition), how to convert it into a function prototype? 27) Where shall the function prototypes and definitions be written in a program? 28) What type of information should be written in the comments before a function definition? 29) Write a statement for calling the math function pow() to compute 2 to the power of 5 and assigning it to a variable result. 30) Write an if statement which increases the value of an int variable result by 1 if an int variable value is positive. 31) What should be added to the statement in 30) if result is to decrease by 1 when value is not positive? 3

32) What should be add to statement 30) to if result is to decrease by 1 when value is negative but to become 0 when value is 0. 33) When are the braces optional in if statements? 34) What are the six common relational operators in C and their associativity? 35) What are the three common logic operators in C and their associativity? 36) List the operators in 34) and 35) in ascending order of precedence. 37) List the operators in 19) and 36) in ascending order of precedence. 38) What are the representative values for true and false in C? 39) What values are considered true and what values are considered false in C? 40) Write two conditions (without using any variables) in which short-circuit evaluation occurs. With AND operator: With OR operator: 41) Write a switch statement which checks the value of an int variable input. If it is 1, increase an int variable result by 1. If it is 2, decrease result by 1. Otherwise, set result to 0. 42) What happens if the break statements in your code for 41) are omitted? 4

43) Write three loops of different types to calculate the sum of all the digits in a given integer num. 44) When is it more natural to use one particular type of loop than others? for loop is more natural when while loop is more natural when do-while loop is more natural when 45) What is the effect of break in a loop? 46) What is the effect of continue in a loop? Programming Environment 1) What are the vim shortcuts for the following purpose? Enter insert mode Delete 1 line Enter command mode Delete n lines Quit Copy 1 line Quit without saving Copy n lines Save and quit Paste Auto-indent Copy & Paste Undo Cut & Paste Redo 5

2) What are the compiler options for the following purposes? Issue all warnings Rename executable code Use math functions 3) Read the following compilation message and identify its components. example1.c:19:18: error: 'Side1' undeclared (first use in this function) Program name: Line number: Type (Error/Warning): Reason: 6