BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering

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

BSc.(Hons.) Business Information Systems. BSc. (Hons.) Computer Science with Network Security. BSc. (Hons) Computer Applications

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

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

Pemrograman Dasar. Basic Elements Of Java

The C Programming Language course syllabus associate level

Informatica e Sistemi in Tempo Reale

2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)

The programming language C. sws1 1

I PUC - Computer Science. Practical s Syllabus. Contents

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

The string of digits in the binary number system represents the quantity

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

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

Chapter 4: Computer Codes

Introduction to Java

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

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

Numbering Systems. InThisAppendix...

Number Representation

As previously noted, a byte can contain a numeric value in the range Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

The Answer to the 14 Most Frequently Asked Modbus Questions

Introduction to Python

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

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Answers to Review Questions Chapter 7

Computer Science 281 Binary and Hexadecimal Review

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Variables, Constants, and Data Types

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

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Tutorial on C Language Programming

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

About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer

FEEG Applied Programming 5 - Tutorial Session

Chapter 2: Elements of Java

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

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

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

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

CP Lab 2: Writing programs for simple arithmetic problems

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

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

C++ Programming Language

Unit title: Computer Games: Programming (SCQF level 6)

Systems I: Computer Organization and Architecture

Base Conversion written by Cathy Saxton

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

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

Fundamentals of Programming

C++ Language Tutorial

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Secrets of printf. 1 Background. 2 Simple Printing. Professor Don Colton. Brigham Young University Hawaii. 2.1 Naturally Special Characters

Lecture 2. Binary and Hexadecimal Numbers

2011, The McGraw-Hill Companies, Inc. Chapter 3

Computer Programming Tutorial

arrays C Programming Language - Arrays

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Chapter 2 Introduction to Java programming

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

In this Chapter you ll learn:

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

DNA Data and Program Representation. Alexandre David

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Chapter One Introduction to Programming

Introduction to Java. CS 3: Computer Programming in Java

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

1 Abstract Data Types Information Hiding

4.1. Title: data analysis (systems analysis) Annotation of educational discipline: educational discipline includes in itself the mastery of the

Data Storage: Each time you create a variable in memory, a certain amount of memory is allocated for that variable based on its data type (or class).

Solution for Homework 2

SECTION C [short essay] [Not to exceed 120 words, Answer any SIX questions. Each question carries FOUR marks] 6 x 4=24 marks

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

AP Computer Science Java Subset

Crash Dive into Python

Lecture 2 Notes: Flow of Control

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

C PROGRAMMING FOR MATHEMATICAL COMPUTING

CSI 333 Lecture 1 Number Systems

Binary Representation

VB.NET Programming Fundamentals

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.

5 Arrays and Pointers

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

El Dorado Union High School District Educational Services

Programming Microcontrollers in C

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

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

CS 106 Introduction to Computer Science I

Object Oriented Software Design

COMPUTER SCIENCE. Paper 1 (THEORY)

Transcription:

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering Cohort: BCNS/07/FT- BIS/07/FT- BIS/06/FT -BM/07/FT BSE/07/FT/PT- BSE/06/FT BSE/05/PT Examinations for 2007-2008 / Semester 1 Resit Examinations for 2006-2007 / Semester 1 MODULE: PROGRAMMING ESSENTIALS MODULE CODE: PRG101/PROG1101/BISE011 Duration: 2 Hours 15 minutes Instructions to Candidates: 1. Answer all questions using C as programming language. 2. Questions may be answered in any order but your answers must show the question number clearly. 3. Always start a new question on a fresh page. 4. All questions carry equal marks. 5. Total marks 100. This question paper contains 4 questions and 7 pages. Page 1 of 7

ANSWER ALL QUESTIONS QUESTION 1: (25 MARKS) (a) (i) Name and describe the four basic data types in C. (ii) Name and describe the four basic types of constants in C. (iii) What is an escape sequence in C? What is its purpose in C programs? (6 marks) (b) (i) Briefly describe the five arithmetic operators in C. (ii) Describe the two equality operators included in C. How do they differ from relational operators? (iii) What are arguments and how are they written? How is a call to a library function written if there are no arguments? (9 marks) (c) A C program contains the following declarations and initial assignments: int i = 7, j = 6; float x = 0.009, y = -0.03; char c = c, d = d ; Now, determine the value of each of the following expressions. (i) (3 * i 2 * j) % (2 * d c) (ii) 2 * ((i / 5) + (4 * (j 3)) % (i + j -2)) (iii) (i 3 * j) % (c + 2 * d) / (x y) (iv) 2 * x + y = = 0 (v) (x > y) && (i > 0) && (j < 5) [Note:- ASCII value of c =99, d =100] (10 marks) Page 2 of 7

QUESTION 2: (25 MARKS) (a) (i) What is the purpose of the scanf function? How is it used within a C program? (ii) What is the purpose of the printf function? How is it used within a C program? (iii) In what ways does the control string within a printf function differ from the control string within a scanf function? (b) A C program contains the following statements: #include <stdio.h> int i, j, k; Write an appropriate scanf function to enter numerical values for i, j, and k assuming the following scenarios:- (i) The values for i, j and k will be decimal integers not exceeding seven characters each. (ii) The value for i will be a decimal integer, j an octal integer and k an hexadecimal integer, with each quantity not exceeding eight characters. (iii) The values for i and j will be hexadecimal integers and k will be an octal integer. Each quantity will be seven or fewer characters. (c) A C program contains the following statements: #include <stdio.h> int i, j; long ix; short s; unsigned u; float x; double dx; char c; Write an appropriate scanf function to accommodate each of the following situations, assuming that integers will be read in as decimal quantities. (Continued) Page 3 of 7

Question 2(c) : (continued) (i) Enter values for i, j, x and dx, assuming that each integer quantity does not exceed four characters, the floating-point quantity does not exceed eight characters, and the double-precision quantity does not exceed 15 characters. (ii) Enter values for i, ix, j, x and u, assuming that each integer quantity does not exceed five characters, the long integer does not exceed 12 characters, and the floating-point quantity does not exceed ten characters. (iii) Enter values for i, u and c, assuming that each integer quantity does not exceed six characters. (9 marks) (d) A C program contains the following variable declarations: float a = 1.5, b = 0.0006, c = 2000.; Write down the output resulting from each of the following printf statements: a) printf("%f %f %f", a, b, c); b) printf( "%3f %3f %3f", a, b, c); c) printf( "%8f %8f %8f", a, b, c); d) printf("%8.4f %8.4f %8.4f", a, b, c); e) printf( "%8.3f %8.3f %8.3f", a, b, c); f) printf("%e %e %e", a, b, c); g) printf("%3e %3e %3e", a, b, c); h) printf("%12e %12e %12e", a, b, c); i) printf("%12.4e %12.4e %12.4e", a, b, c); j) printf("%8.2e %8.2e %8.2e", a, b, c); (10 marks) Page 4 of 7

QUESTION 3: (25 MARKS) (a) What is the purpose of the if-else statement? Describe the two different forms of the if-else statement. How do they differ? (b) (i) What is the purpose of the return statement? (ii) What are the 2 principal components of a function definition? (c) Write the first line of the function definition, including the formal argument declarations, for each of the situations described below:- (i) A function called sample that generates and returns an integer quantity. (ii) A function root accepts two integer arguments and returns a floating point result. (iii) A function convert accepts a character and returns a character. (iv) A function called transfer accepts a long integer and returns a character. (v) A function inverse accepts a character and returns a long integer. (5 marks) (d) (i) What is the purpose of the switch statement? (ii) Write a simple C program using the switch to prompt a user to enter any one of the three characters r or w or b. The program displays red if r is entered, it displays white if w is entered or blue if b is entered. If one of the three characters is not entered then the default case executes to print Error. (6 marks) (Continued) Page 5 of 7

Question 3 : (continued) (e) What will be the outputs generated in the following programs. Explain fully all your answers. (i) #include <stdio.h> main( ){ int i=0,x=0; while (i < 20){ if(i%5 == 0){ x += i; printf( %d, x); ++i; printf( \n x= %d, x); (4 marks) (ii) #include <stdio.h> main( ){ int i, j, k, x = 0; for(i=0; i<5; ++i) for(j=0; j<i; ++j){ k = (i + j 1); if (k % 2 == 0) x += k; else if (k % 3 == 0) x += k 2; printf( %d, x); printf( \n x = %d, x); (4 marks) Page 6 of 7

QUESTION 4: (25 MARKS) (a) (i) What are array subscripts? How are they written? What restrictions apply to the values that can be assigned to subscripts? (ii) When passing an array to a function, how must the array argument be written? How is the corresponding formal argument written? (iii) If an array is passed to a function and several of its elements are altered within the function, are these changes recognized in the calling portion of the program? Explain fully. (8 marks) (b) (c) Describe the array that is defined in each of the following. Indicate what values are assigned to the individual array elements. (i) float c[8] = {2., 5., 3., -4., 12., 12., 0., 8.; (ii) float c[8] = {2., 5., 3., -4.; (iii) int z[12] = {0, 0, 8, 0, 0, 6; (6 marks) Explain the meaning of each of the following declarations. (i) int *p; (ii) int *p[10]; (iii) int (*p)[10]; (iv) int *p(void); (v) int p(char *a); (5 marks) (d) A C program contains the following declaration. static int x[8] = {10, 20, 30, 40, 50, 60, 70, 80; (i) What is the meaning of x? (ii) What is the meaning of (x + 2)? (iii) What is the value of *x? (iv) What is the value of (*x + 2)? (6 marks) ***END OF QUESTION PAPER*** Page 7 of 7