Vous êtes sur la page 1sur 11

Chapter 1.

1 Introduction to computers

Classification of computer (generation of computers)


Short notes on CPU, Storage devices, input devices, output devices, ALU, Machine
language, Assembly language.
MCQs: Names of Operating system, Application softwares, Programming languages,
Higher Level Languages.

Chapter 1.2 Number Systems


Convert from binary to decimal:
(i) [1011]2
Convert from octal to decimal:
(i) [743]8
Convert from hexadecimal to decimal: (i) [53D]16
Convert from decimal to binary:
(i) [11]10
Convert from decimal to octal:
(i) [483]10
Convert form decimal to hexadecimal: (i) [1341]10

(ii) [1111.01]2 (iii) [101.10]2


(ii) [235.1]8 (iii) [23.24]8
(ii) [A8.1]16 (iii) [6.C]16
(ii) [15.25]10 (iii) [5.5]10
(ii) [157.125]10 (iii) [19.3125]10
(ii) [168.0625]10 (iii) [6.75]10

Chapter 1.3 Boolean Algebra


Q1. Write the answer of the following by using truth table:
(i) X AND Y (ii) X OR Y (iii) NOT X (iv) A +B
(v) (A B)
(vi) X
(vii) (A + B) C
(viii) A B (ix) (A + B) (x) (A + B) C
Q2. Prove the de Morgans theorem (A + B) = A B by using truth table.
Q3. Short note on
(i) NAN Gate
(ii) NOT Gate Circuit (iii) AND Gate Circuit
(iv) OR Gate Circuit (v) XOR Gate Circuit

Chapter 1.4 Basic concepts of Operating Systems


1. What is an operating system? [2]
2. Major functions of an Operating System. / Describe how an operating system coordinates
with different units of a computer during the execution of a program. [5]
3. Give one example each of Multiuser and Single User operating system. [2]
4. UNIX is a multi-user operating system Explain. [2]
5. What do you mean by Multitasking Operating System? Give an example. [2]
6. Write the difference between internal and external commands of DOS with two examples of
each and their uses. [5]
7. Short notes on the following (OR function of, OR utilities of) DOS commands:
SCANDISK, DIR/W, DIR/P, TREE/F, TREE/F MORE, ATTRIBh, ATTRIB+h, DEL,
DELTREE, COPY, PROMPT, MORE, EDIT
8. What is the difference between (i) DEL and RD (ii) RD and DELTREE (iii) DEL and
DELTREE (iv) COPY and XCOPY (v) TYPE and EDIT (vi) CHKDISK and SCANDISK
[2]
9. What is BATCH FILE and when do you use it? [4]
10. Can you recover a file which has been deleted with DEL command? [2]
11. Write the necessary command to copy all the files in A:\GCTS to C:\GCTS. [2]
12. What is the utility of the COMMAND.COM program? [2]
13. What does the following DOS command result in? C:\>DIR/W>DIRFILE. [2]

Chapter 1.5 Introduction to Computer Language C


Ques: What do you mean by constant and variable?
Ques: Why are Data Types necessary while declaring variables?
Ques: What is keyword? State the difference between a keyword and an identifier. [6]
Ans: For Keywords see the note, page 4.
Identifiers:
In programming we require to name variable, function, data definition, etc. Those names are called
identifiers. In the programming language C, an identifier is a combination of alpha numeric
characters, the first being the letter of an alphabet or an underscore, and the remaining being any
letter of the alphabet, any numeric digit, or the underline.
See note p.4 Rules of naming variables The names are identifiers.
Programs:
See the programs from Programs note Prog(1), (2), (3), (4), (5), (6), (7)
Ques: Write short note on (i) Arrays (ii) Functions (iii) Precedence rule.
Array: See Programming in C note page 20, Introduction, Array declaration, Array
Initialization.
Functions: See Programming in C note page 18, Introduction, Structure of a function,
Advantage of using function and Example 2.
Ques: Convert the following expressions to C-expression.
(a) az 2.0 (b) x 2 /( y z ) (c) loge (x + 3y )3.
(d) cos(2x y) + |x2 + y2| + ex y.

Answer to Question Paper 2011


2011 Q1(i) The boost strap program is stored in ROM (e.g. BIOS). Boot strap program is the first
small program that is first started when a computer is powered on. It helps in loading the
more complex softwares like Operating Systems. [2011]
2011 Q1(ii) The addressing capability of a processor (CPU) is dependent on width of address
bus.
2011 Q1(vi) [11111110]2 = [FE]16.
2011 Q1(vi) In C language division by zero is a semantic error, because it will occur after the
program is executed (or run).
[Hint:
Syntactic error is the error in the syntax while writing the C-code. e.g. missing a semicolon, or typing error of a
code like scanf, printf, etc.
Semantic error: A program syntax may be correct but during program execution some error may occur. This
type of error is called semantic error. e.g. improper type of variable defined, subscripts out of range in an array
variable, etc.]

2011 Q1(vii) 2s complement of 1000 0010 is (c) 0111 1110


[Hint: 1000 0010 (=x) is an eight bit binary number.
The formula for 2s complement of x = x* = (2Nx) = 28[1000 0010]2 = [256]10 [1000 0010]2
= [1 0000 0000 1000 0010] = 0111 1110. The easiest way to calculate x* is as follows
1 0000 0000
1000 0010
0111 1110
]

2011 Q1(viii) A do-while loop is useful when we want that statement within a loop must be
executed (a) only once.
[Hint: A do-while loop allows codes / statements to be executed once based on a given condition. E.g.
Do B
While (A = TRUE)
End While ]

2011 Q1(ix) The output of the following code is


For (i1;i<=5;i++)
{
if (i % 2)
Continue
Printf(%d,i);
}

Hints
i starts from 1 upto 5 with an increment of 1 (i.e. i=i+1)
The value of (i % 2) = the remainder after dividing i by 2
If i is even then (i%2 ) = 0
If i is odd then (i%2) = 1
If (i%2) is 1 (i.e. true) then Continue the loop without
executing Printf(%d,i)
If (i%2) is 0 (i.e. false) then Printf(%d,i)
Therefore the final result is if i is odd then dont print.
If i is even then print i. Therefore the answer will be
2,4.

2011 Q1(x) Which of the following is an external command in DOS? Ans. (a) Edit.
[Hint: See Chapter 1.4: Basic concepts of operating systems/p2-3 ]

2011 Q1(xi) Size of (5.2) will return Ans. (b) 5.


[Hint: Size of the string (5.2) is the number of characters in the string. (i) (, (ii) 5 (iii) . (iv) 2 (v) ). That is
5 characters. ]

2011 Q1(xii) Kernal in Unix is the b) core OS part.

2011 Q4. Write a C program to input a number and calculate the sum of individual digits present in
that number and also print the number in reverse order.
Example: Input 123
Output Sum of individual digits: 6
Reverse of the number: 321.
Solution:
#include<stdio.h>
#include<conio.h>
void main( )
{
clrscr( );
int num, remainder=1, quotient, sum=0, rev=0;
printf("Enter the number");
scanf("%d",&num);

//Enter the number e.g. 123

while (num != 0)
//Till num is not equal to 0
{
remainder = num % 10;
//num%10 is the remainder e.g. 123%10 = 3
sum = sum + remainder;
// sum = 0 + 3
rev = rev * 10 + remainder;
//create the reverse number
quotient = num/10;
//num/10 is the quotient, e.g. 123/10=12
num = quotient;
//put the value of quotient into num, i.e. num=12
}
print("Sum of the digits:%d",sum);
printf("\nThe reverse of the number:", rev);
getch( );
//Wait for a keyboard action to come out from the DOS screen
}
2011 Q7(a) What is an array? How to initialize an array?
Ans: See Chapter 1.5: Introduction to computer language p20-21.

2011 Q7(b) What are the limitations of an array?


An array is a static data structure. After declaring an array it is impossible to change its size.
Thus sometime memory spaces are misused.
Each elements of array are of same data type as well as same size. We cannot work with
elements of different data type.
In an array the task of insertion and deletion is not easy because the elements are stored in
contiguous memory location.
Array is a static data structure thus the number of elements those can be stored in it are
somehow fixed.
2011 Q7(c) What is the scope of a variable?
Variables in C can be declared in three regions of the program. These regions are called scopes of
the variables. There are three scopes:
1. Inside a function or a block which is called local variable
2. In the definition of function parameters which is called formal parameters
3. Outside of all functions which is called global variables

Example:
#include <stdio.h>
#include<conio.h>
int g;
int add(int x, int y);
void main ( ) {
int a = 10, b = 20;
g = add(a, b);
printf(%d, g);
getch();
}
add (int m, int n) {
int s;
s = m + n;
return (s);
}

// Global variable declaration


// int x and int y are formal parameter declaration
// Main function
// Local variable declaration
//Calling the function add with two parameters a and b

//Function add with two formal parameters


//Here s is a local variable

2011 Q8(a)What is the difference between automatic and register storage class? Discuss
when they are used. [5]
Ans.
Storage
Class
Automatic
Register

Where the
variable is
stored
Memory
(RAM)
CPU
Registers

Initial value
of the
variable
Default value
is garbage
value
Default value
is garbage
value

Scope of the
variable

Life of the variable

When it is used

Local to the
block

Within the block in


which the variable is
defined
Within the block in
which the variable is
defined

Can only be used within


functions as local
variables.
Used in the case of
frequently used
variables because these
are stored in CPU
registers. e.g. counters.

Local to the
block

2011 Q8(c)What is the difference between interpreter and compiler? What are local variable
and global variable? Explain with example. [5]
Ans: Difference between interpreter and compiler
Compiler and interpreter are programs that run the instructions written in a certain programming
language and convert them into the machine code that a computer can understand.
Compiler
More time is required for analyzing and processing
of the program.
The resulting code of the compiler is in the form of
machine code or binary format.
In case of compiler, the resulting code is executed by
the computer hardware.
The execution of the program is fast in the compiler.
Examples: C, ForTran, PASCAL, etc.

Interpreter
Lesser time is required for analyzing and processing
of the program.
The resulting code is in the form of the intermediate
code.
In an interpreter; another program interprets the
resulting code.
The program execution speed is comparatively low.
BASIC is an interpreter.

Ans:
Local variable

A local variable is a variable which is either a variable declared within the function or is an
argument passed to a function. If we declare variables in a function then we can only use them
within that function.
Global variable
A global variable is a variable which is accessible in multiple scopes. It is important to note that
global variables are only accessible after they have been declared. Global variables can be seen
from all functions.
#include <stdio.h>
#include <conio.h>
int g;

//g is a global variable

int add(int x, int y);


local variable..

//int x and int y are defined within the function add( ) so they are

void main( ) {
clrscr( );
int a, b, c;
//a, b, c are local variables
a = 1;
b = 2;
c = a + b;
printf(%d", c);
//The display will be 3
getch( );
}
2011 Q9(a) What do you mean by an operating system? What are the advantages of an UNIX
operating system? [7]
Ans. See note of Chapter 1.4 for the first question.
Advantages of UNIX operating system
1. Full multitasking with protected memory: Multiple users can run multiple programs each at
the same time without interfering with each other or crashing the system.
2. Very efficient virtual memory: Many programs can run with a modest amount of physical
memory.
3. Access controls and security: All users must be authenticated by a valid account and
password to use the system. All files are owned by particular accounts. The owner can
decide whether others have read or write access to his files.
4. A rich set of small commands and utilities that do specific tasks well -- not cluttered up with
lots of special options.
5. Ability to string commands and utilities together in unlimited ways to accomplish more
complicated tasks -- not limited to preconfigured combinations or menus, as in personal
computer systems.
6. A powerfully unified file system. Everything is a file: data, programs, and all physical
devices. Entire file system appears as a single large tree of nested directories, regardless of
how many different physical devices (disks) are included.
7. A lean kernel that does the basics for you but doesn't get in the way when you try to do the
unusual.
8. Available on a wide variety of machines - the most truly portable operating system.
9. Optimized for program development, and thus for the unusual circumstances that are the
rule in research.
6

2011 Q9(b) What is virtual memory? What are its advantages? [5]
Virtual memory is a feature of an operating system that enables a process to use a memory (RAM)
address space that is independent of other processes running in the same system
If a computer lacks the random access memory (RAM) needed to run a program or operation, OS
uses virtual memory to compensate.
Virtual memory combines the computers RAM with temporary space on the hard disk. When
RAM runs low, virtual memory moves data from RAM to a space called a paging file. Moving data
to and from the paging file frees up RAM to complete its work. The more RAM a computer has, the
faster the programs will generally run.
2011 Q9(c) Explain the difference between shell and kernel. [3]
Both shell and kernel are parts of an operating system. These both parts are used for performing
any operation on the system.
When a user gives a command for performing any operation, the request first goes to the Shell
part of the OS. It translates the Human Program into the Machine Language. Then the request in
the form of machine language will be transferred to the kernel (another sets of programs).
Therefore shell is called just an interpreter.
Kernal is the heart of an Operating System. When the kernel receives a request (in machine
language) from the Shell it will process the request and output the result by printer, or monitor,
etc.
Application Programs Shell of OS Kernel of OS
2011 Q11(a) Write a program in C to calculate the value of the series. [5]
1+1/(1+2) + 1/(1+2+3) + ..+ 1/(1+2+3++N)
#include<stdio.h>
#include<conio.h>
void main( ){
clrscr( );
int i, N, sum=0, totsum=0;
printf(Put N:);
scanf(%d, &N);

//Declare the variable type and initialize them


//Enter the value of N

for (i=1; i<=N; i++){


sum = sum + i;
//Create the series of denominator, i.e. (1+2) ..
totsum = totsum + 1/sum;
//Creates 1/(1+0) + 1/(1+2) + ..
}
prinf(Total sum =%d,totsum); //Output of the whole series
getch( );
}

2011 Q11(b) Define algorithm. Explain with example. Mention the five important peoperties
of an algorithm. [5]
The abbreviated statements in English (or in other natural language) that specify the steps to be
performed in solving the problem are called the program design language (PDL) statements or
pseudocode.
The finite set of PDL statements, which describe the logic for solving a specific problem, is
called an algorithm and the process of defining PDL statemtns is called the algorithm
development.
An algorithm has five notable features:
1.
2.
3.
4.
5.

It has a finite number of inputs.


It terminates after a finite number of steps.
The actions specified in each step are precise and unambiguous.
All operations specified can be done exactly and in a finite amount of time and
Uit has one or more outputs derived from the inputs by applying the algorithm.

Algorithm of Problem
1. Input X1, X2, X3.
2. Compare X1 with X2.
3. If X1 is larger than X2, compare X1 with X3.
If X1 is larger than X3, report X1 as the largest;
Otherwise, report X3 as the largest.
4. If X1 is not larger than X2, compare X2 with X3.
If X2 is larger than X3, report X2 as the largest;
Otherwise, report X3 as the largest.
5. End
2011 Q11(c) Write a menu driven program using function (call by reference) to find the
following. [5]
(i) Factorial
(ii) Odd / Even
(iii) Prime
#include<stdio.h>
#include<conio.h>
void factorial( );
void evenodd( );
void prime( );

//Declaration of function for calculating the factorial


//Declaration of function for checking a number if even or odd
//Declaration of the function to check a prime number

void main( ){
//The main function holding the menu
clrscr( );
int i, option;
printf(MENU);
printf(1. Determine the factorial\n);
printf(2. Determine number whether it is odd or even\n);
printf(3. Check whether a number prime number\n);
printf(Type the number: );
scanf(%d, &option);
8

switch (option) {
case 1:
factorial( ); break;
case 2:
oddeven( ); break;
case 3:
prime( ); break;
default:
menu( ); break;

}
//switch ends here
//main function ends here

void factorial( ){
int N, prod=1;
printf(Enter a number to calculate its factorial);
scanf(%d, N);
for (i=1; i<=N; i++){
prod = prod * i;
}
//for loop ends here
printf (\nFactorial(%d) = %d, N, prod );
}//factorial function ends here

//display: Factorial(5)=120

void evenodd( ){
int N;
prinf(Enter a number: );
scanf(%d, N)

if (N%2 = = 0){
//no remainder, i.e. even number
printf(%d is an even number, N);
}
else
{
printf(%d is an odd number, N);
}
//function evenodd( ) ends here

void prime( ){
int n, i, result = 1;
//result = 1 means n is a prime number
printf(Enter a number\n);
scanf(%d, &n);
for (i=2; i <= n 1; i++){
if(n%i = = 0){
result = 0;
break;
}
}

//no remainder means divisible


//means not a prime number
//come out from the for loop

if (result = = 1){
//if result = =1 then n is a prime number
printf(%d is a prime number, n);
}
else {
//otherwise the number n is prime
printf(%d is a not a prime number, n);
}
//function prime( ) ends here
Question Paper of 2012

Q1(i) Which of the following operators takes only integer operands?


(a) +

(b) *

(c) /

(d) %

Ans. (d) %
[Hint: % is an operand to calculate the remainder of two integers e.g. 7%4 = 3; dividing 7 by 4 produces a
remainder of 3 ]

Q1(ii) C is a language
(a) procedural (b) object-oriented
Ans. (a) procedural

(c) both (a) & (b)

(d) none of these

[Hint: Just memorize it, otherwise we shall require to know the Object Oriented Programming. C++ is an
Objected Oriented Programming language ]

Q1(iii) 1 nibble is equal to


(a) 4 bits
(b) 8 bits
Ans. (a) 4 bits

(c) 12 bits

(d) 16 bits

[Hint: 1 byte = 8 bits and 1 nibble = 4 bits i.e. part of a byte. ]

Q1(iv) The Grey code for decimal 7 is


(a) 0111
(b) 1011
(c) 0100
Ans. (c) 0100

(d) 0101

[Hint: Out of Syllabus no need of studying]

Q(v) 7BA (Hexadecimal) = .(Binary)


(a) 011110111010
(b) 010011110111
Ans. (a) 011110111010

(c) 011101111001

(d) 101110111001

[Hint: First convert Hexadecimal Decimal Binary


[7BA]16 = 7x162 + 11x161 + 10x160 = 1792 + 176 + 10 = [1978]10.
2 |1978
]

10

11

Vous aimerez peut-être aussi