100% found this document useful (1 vote)
451 views3 pages

ICS 2102: C Programming Exam Guide

This document is an examination paper for the course ICS 2102: Introduction to Computer Programming at Jomo Kenyatta University, covering various topics in C programming. It includes multiple questions on program execution steps, program structure, characteristics, variable rules, and practical programming tasks. The exam consists of five questions, with the first being compulsory and requiring both theoretical explanations and coding exercises.

Uploaded by

kiribalaura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
451 views3 pages

ICS 2102: C Programming Exam Guide

This document is an examination paper for the course ICS 2102: Introduction to Computer Programming at Jomo Kenyatta University, covering various topics in C programming. It includes multiple questions on program execution steps, program structure, characteristics, variable rules, and practical programming tasks. The exam consists of five questions, with the first being compulsory and requiring both theoretical explanations and coding exercises.

Uploaded by

kiribalaura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

W1-2-60-1-6

JOMO KENYATTA UNIVERSITY


OF
AGRICULTURE AND TECHNOLOGY
UNIVERSITY EXAMINATIONS 2015/2016
FIRST YEAR SECOND SEMESTER EXAMINATION FOR THE DEGREE
OF BACHELOR OF BUSINESS INFORMATION TECHNOLOGY/
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY

ICS 2102: INTRODUCTION TO COMPUTER PROGRAMMING

DATE: DECEMBER 2015 TIME: 2 HOURS


INSTRUCTIONS: ANSWER QUESTION ONE (COMPULSORY) AND
ANY OTHER TWO QUESTIONS

QUESTION ONE (COMPULSORY) (30 MARKS)

a) Discuss the steps that are followed when executing a C program. [5 marks]

b) The basic structure of a C program comprises of different elements.


Discuss these elements. [5 marks]
i) Preprocessor Statement
ii) Main ( )
iii) Declaration and Statement
iv) User defined functions
v) A pair of curly braces { }

c) Explain any FIVE characteristics of a C program. [5 marks]

d) Differentiate between the following set of programming terms: [4 marks]


i) Variable and Identifier
ii) Operand and operator

e) What are the rules for constructing variable names? [4 marks]

f) Write a C program to find Gross salary, given Gs = bs + da + ta;


da = (10 x bs)/100, ta = (12 x bs)100. [5 marks]

g) Explain the following terms as used with regards to functions. [2 marks]


i) Call by reference
ii) Call by value

1
QUESTION TWO (20 MARKS)

a) List atleast an advantage and disadvantage of madine language,


and thereafter go ahead and give one advantage of introducing
assembly language. [3 marks]

b) What is a variable? [1 mark]

c) Contrast the features of a compiler and interpreter as used in high


level languages. [4 marks]

d) Write a program in C to convert the temperature from centigrade


to Fahrenheit; given formula s f = (1.8 x c) + 32. [6 marks]

e) Write a C program to calculate sum of 5 subjects and find percentage. [6 marks]

QUESTION THREE (20 MARKS)

a) What do the below character combinations mean. [4 marks]


i) ‘\t’
ii) ‘\n’
iii) ‘\f’
iv) ‘\a’

b) Write a program to read four numbers and print the greatest of


the given four numbers. [4 marks]

c) Use the If the else statement to write a program to read a year and
find whether the given year is leap or not the general Format used
to create frames in a HTML document. [6marks]

d) Write a program in C to display Name of student, Reg. No.,


Academic year, Course of student. [6 marks]

QUESTION FOUR (20 MARKS)

a) Use the for loop to write a C program to print sum of natural


number from 20 -30. [6 marks]

b) What are the steps taken in the execution of the for statements. [3 marks]

c) Write a program in C language to accept a number and print the


mathematical table of the given number. [6 marks]

d) Use the switch statement to write a program that accepts 5 single


digit numbers and prints them in words. [5 marks]

2
QUESTION FIVE (20 MARKS)

a) What are the rules for writing the switch statement. [5 marks]

b) Write a program to accept values into 3 x 2 array and print. [5 marks]

c) Why do we need user defined functions in C programming? [4 marks]

d) Write a program to accept two numbers and print the sum of two
numbers using functions. [6 marks]

Common questions

Powered by AI

Key characteristics of a C program include simplicity, portability, efficiency, structured language, and rich set of operators. Simplicity and portability make C easy to write and work on multiple platforms, efficiency ensures fast execution, structured language supports organized code, and a rich set of operators provides extensive functionality .

Machine language, being directly understood by computers, provides high efficiency in execution but is challenging for human readability and error-prone during programming. Assembly language, meanwhile, offers a more understandable syntax closer to human language and enables easier debugging, though at the expense of a slight decrease in execution efficiency compared to machine language .

Variable names in C must begin with a letter or an underscore, followed by letters, numbers, or underscores. They are case-sensitive and cannot be a keyword or reserved word. Additionally, variable names should be descriptive and meaningful for readability .

The basic structure of a C program consists of preprocessor statements, the main function, declarations and statements, user-defined functions, and a pair of curly braces. Preprocessor statements handle preprocessing tasks, the main function is the entry point, and declarations and statements define variables and logic. User-defined functions encapsulate reusable code, and curly braces define the scope of code blocks .

A compiler translates the entire high-level source code into machine code before executing it, resulting in a faster runtime. An interpreter, conversely, translates each line of source code individually and sequentially, which allows immediate execution but may result in slower overall performance. Compilers typically provide better performance optimization .

The steps in executing a C program include editing the code, compiling the program, linking the compiled code, and executing the executable file. During the compilation step, the code is translated from high-level C into machine code. Linking resolves function calls to library routines, and the final step involves executing the resulting binary file .

The switch statement in C must use an integer or a character as its control expression. Each case must end with a break statement unless intentional fall-through is desired. Cases and the default section label specific outcomes. The switch considers the control expression's value and executes the matching case block's code .

User-defined functions in C are used to break down a program into manageable and reusable blocks of code. They enhance modularity, improve readability, and allow code reusability by defining specific tasks or computations that can be reused multiple times within a program, thus simplifying debugging and maintenance .

In C programming, a variable is a named storage that holds a value which can be modified during program execution, while an identifier is a name given to entities like variables, functions, and arrays. Identifiers are used to identify program elements, whereas variables specifically refer to memory locations .

The distinction between 'call by reference' and 'call by value' in C function calls significantly impacts memory and data manipulation. 'Call by value' passes a copy of arguments thus preserving the original variable, ideal for value protection. 'Call by reference' allows the function to modify the original data, enabling direct manipulation of variable contents, essential for functions requiring data updates .

You might also like