Unit - L: List and Explain The Functions of Various Parts of Computer Hardware and Software
Unit - L: List and Explain The Functions of Various Parts of Computer Hardware and Software
Unit - L: List and Explain The Functions of Various Parts of Computer Hardware and Software
Q1.List and explain the functions of various parts of computer hardware and software.
B. Application Software:
It is directly responsible for helping users to solve their problems.
Application software is broken in to two classes.
i. General - Purpose Software
ii. Application - Specific Software
Each circle is an interface point. The inner core is hardware. The user is
represented by the outer layer. To work with the system , the typical user
uses some form of application software. The application software in turn
interacts with operating system ( OS ), which is part of system software layer.
The System software provides the direct interaction with the hardware.
The opening at the bottom of the figure is the path followed by the
user who interacts directly with the Operating System when necessary.
B. Compiling Programs:
The code in a source file on the disk must be translated in to
machine language.
This is the job of compiler which translates code in source file stored
on disk in to machine language. The C compiler is actually two
separate programs: the preprocessor and the translator.
The preprocessor reads the source code and prepares it for the compiler.
It scans special instructions known as preprocessor commands.
These commands tell the preprocessor to take for special code libraries,
make substitutions in the code. The result of preprocessing is called
translation unit. The translator reads the translation unit and writes
resulting object module to a file that can be combined with other
precompiled units to form the final program.
An object module is the code in machine language. This module is not ready
for execution because it does not have the required C and other functions included.
C. Linking Programs:
C programs are made up of many functions.
Example: printf ( ) , cos ( )… etc.
Their codes exists else where , they must be attached to our program.
The linker assembles all these functions , ours and the systems, in to a
final executable program.
D. Executing Programs :
Once our program has been linked, it is ready for execution.
To execute a program, we use operating system command, such as
run to load the program in to main memory and execute it.
Getting program in to memory is the function of an Operating System
programs called loader.
Loader locates the executable program and reads it in to memory.
In a typical program execution, the program reads data for processing,
either from user or from file.
After the program processes the data, it prepares output. Data output
can be to user’s monitor or to a file. When program has executed,
Operating System removes the program from memory.
Q3. Describe the Basic Steps in the System Development Life Cycle?
or
Explain about SDLC?
The software development life cycle consists of six phases. They are
A. System requirements
B. Analysis
C. Design
D. Code
E. System test
F. Maintenance
A. System requirements :
System analyst defines requirements that specify what the proposed system is
to accomplish. Requirements are usually stated in terms that user understands.
B. Analysis :
The analysis phase looks at different alternatives from a system point of view.
C. Design:
The design phase determines how the system will be built.
The functions of the individual programs that will make up the system are
determined and the design of the files and /or the databases is completed.
D. Code:
We write programs. After the programs have been written and tested
for programmer satisfaction.
E. System test:
We test the entire program together, to make sure the system works as a whole.
F. Maintenance:
Keeps the system working once, it has been put onto production. As each phase
is developed, errors and omissions will often be found in the previous work .When
this happens, it is necessary to go back to the previous work to rework it for
consistency and analyze the impact caused by the changes.
B. System requirement:
We do planning of functional requirements - Software’s Version, Non-
functional requirements - Resources - Internet , table , A/cs , Coffee.
User functional requirements - Problem Oriented and Language used is
in simple i.e. English.
C. Analysis:
User requirements are transformed to technical terms like Blueprint and
also look for different alternatives considering all risks.
D. Design:
In UML software users will develop flowcharts, structure charts, data flow
diagrams
1. Choose the best way to find solution among different alternatives.
2. Choose in analysis , design files , databases and functions.
E. Code:
Unimportant in Software development life cycle
1. Uses software for code generation ( forward energy ).
2. Otherwise go for manual coding.
3. Basic testing is done ( compilation ).
F. System Test :
Test if user requirements are met
Blackbox Testing: Test programs together, make sure system works as a whole.
Whitebox Testing: Release ά-version to customer, according to his/her feed back
we develop β-Version: β - version is released to selected group of people.
G. Maintenance :
Keeps the system working once it has been put in to production ?
Ans: Algorithm:
The same problem can be solved with different methods. So, to solve a problem
different algorithm, may be accomplished. Algorithm may vary in time, space utilized.
User writes algorithm in his / her own language.
So, it can not be executed on computer. Algorithm should be in sufficient detail
that it can be easily translated in to any of the languages.
Or
Write the rules for writing Psuedocode with example.What are the advantages and disadvantages
of Psuedocode? [10+6]
Halt
1. Start
2. [ Obtain input values ]
Read ( A , B )
3. [ Add numbers and store the result ]
CA+B
4. [ Print result ]
Write ( C )
5. Stop
Example2: Find xn
1. Start
2. [ obtain input values ]
Read ( x , n )
3. [ Initialize result so far ]
result → x
4. [ Initialize loop counter ]
i →1
5. [ Print result ]
repeat thru step 7 while i < n
6. [ Recomputed result so far ]
result <-- result * x
7. ( Increment counter )
i <-- i + 1
8. ( Display result )
Write ( x , n , result )
( Finished )
9. Halt.
Guidelines :
Notations used :
Blackbox Testing :
• Testing the program with out knowing what is inside it – with out
knowing how it works.
• Test Plans are developed by looking only at the requirements statement:
We should ask to see this Test Plan before we write our Program.
Whitebox Testing :
Ans: Flowchart :
Purpose of a Flowchart :
• Provides Communication.
• Provides an Overview.
• Shows all elements and their relationships.
• Quick method of showing Program flow.
• Checks Program logic.
• Facilitates Coding.
• Provides Program revision.
• Provides Program documentation.
Advantages of a Flowchart :
• Flowchart is an important aid in the development of an algorithm itself.
• E asier to Understand than a Program itself.
• Independent of any particular programming language.
• Proper documentation.
• Proper debugging.
• Easy and Clear presentation.
Limitations of a Flowchart :
• Complex logic.
• Drawing is time consuming.
• Difficult to draw and remember.
• Technical detail.
Step 1 : Start
Step 2 : Input num1 , num2
Step 3 : temp = num1
Step 4 : num1 = num2
Step 5 : num2 = temp
Step 6 : Output num1 , num2
Step 7 : Stop
Step 1 : Start
Step 2 : Input num1 , num2
Step 3 : calculate num1 = num1 + num2
Step 4 : calculate num2 = num1 – num2
Step 5 : calculate num1 = num1 – num2
Step 6 : Output num1 , num2
Step 7 : Stop
Flowcharts :
Start Start
READ READ
num1,num num1,num
2 2
Q14.Write an algorithm and flowchart to find the largest among two numbers.
Ans:
Algorithm:
Step 1 : Start
Step 2 : Input A , B
Step 3 : if A > B then output A
else output B
Step 4 : Stop
Flowchart :
START
Input A , B
Yes No
Output-A a Output-B
STOP
Q15.Write an algorithm and flowchart to find the largest among three numbers.
Algorithm: (method 1)
Step 1 : Start
Step 2 : Input A, B, C
Step 3 : if A > B go to step 4 , otherwise go to step 5
Step 4 : if A > C go to step 6 , otherwise go to step 8
Step 5 : if B > C go to step 7, otherwise go to step 8
Step 6 : print “ A is largest ” , go to step 9
Step 7 : print “ B is largest ”, go to step 9
Step 8 : print “ C is largest ” , go to step 9
Step 9 : Stop
Flowchart:
START
Input A,B,C
Output B b a a Output A
Yes No Yes Yes
No Output CNo
STOP
Algorithm: b.
Step 1 : Start
Step 2 : Input A, B, C
Step 3 : Let max = A
Step 4 : if B > max then max = B
Step 5 : if C > max then max = C
Step 6 : output max is largest
Step 7 : Stop
Flowchart:
Start
Read A , B ,C
max = A
False
True
T
False
True
Start
READ n
F
Hint: For any given number n, the set of possible factors are 1, 2, 3, … n/2. Divide the
given number by a sequence of numbers 1,2,3,….n/2 and print those numbers for which
the remainder is zero.
Algorithm:
Step 1: Start
Step 2: Input n
Step 3: Initialize counter variable, i , to 1
Step 4: if i > n/2 go to step 7
Step 5: if (n % i == 0) output i
Step 6: increment i and go to step 4
Step 7: stop
Flow chart:
START
READ n
True
F
False
True False
Hint: A number is said to be prime number for which the only factors are 1 and itsel
Algorithm:
Step 1: Start
Step 2: Input n
Step 3: Let i = 1, count=0
Step 4: if i > n/2 go to step 7
Step 5: if (n % i = = 0) count = count + 1
Step 6: increment i and go to step 4
Step 7: if count=2 then print “prime number”
else print “not prime number”
Step 8: Stop
Flow chart:
START
READ n
i = 1
count=0
Yes
No
Yes No
No
Yes
START
READ n
i=1
sum=0
Yes
No
Yes No
No
Yes
Q20.Write an algorithm and flowchart to find the sum of first 20 natural numbers
Hint: Sum = 1+2+3+………+20
Algorithm:
Step 1: Start
Step 2: k = 1, sum = 0
Step 3: if k > 20 then go to step 7
Step 4: sum = sum + k
Step 5: k=k+1
Step 6: go to step3
Step 7: output sum
Step 8: Stop
Flow chart:
Q21.Write an algorithm and flowchart to find sum of digits of a number.
Hint: Ex: 371 = 3 + 7 + 1 = 11
Algorithm:
Step 1: Start
Step 2 : Input n
Step 3 : Let sum=0
Step 4 : if n<0 go to step 8
Step 5 : digit = n % 10
Step 6: sum = sum + digit
Step 7 : n = n / 10, go to step 4
Step 8: output sum
Step 9 : Stop
Flow chart:
Start
Read n
sum = 0
No
n >0
digit=n%10
yes
Flow chart:
START
READ n
sum=0
m=n
n>0
No No
yes
Yes
No
yes
READ n
rev=0
No
n>0
digit = n%10
rev=(rev*10)+digit
yes
Flow chart:
START
READ n
rev=0
m=n
n>0
No
No
Yes
No
Yes
Flowchart :
F
Read n
sum = 0
i++ i=0
i<=n
i<i<=n11
Read a
F
Start
Read n
i++ i=0
i<=n
Ent=0
F T
T
P
A
Write
Q27.Write an algorithm and flowchart to find the Sum of individual digits if a given number
Stop
Algorithm :-
Step 1 : Start
Step 2 : read n
Step 3 : Sum = 0
Step 4 : While n > 0 do
4.1 : r = n % 10
4.2 : Sum = Sum + r
4.3 : n = n/10
Step 5 : End while
Step 6 : Write Sum
Step 7 : Stop
Flowchart :-
Start
Read n
T
Algorithm :
Step 1 : Start
Step 2 : read n
Step 3 : fact = 1
Step 4 : for i=1 to n step by 1
4.1 : fact = fact * i
Step 5 : End for
Step 6 : Write fact
Step 7 : Stop
Flowchart :-
Start
Read n
F
(b) Areas where C language is used and what are the Characteristics of C
language?
1a Ans:
Ken Thompson developed B language then Dennis Ritchie give some advance features,
functionality to B Language for developing C. C language is developed by Dennis Ritchie in
1972. C language depends on ANSI (American National Standard Institute). ANSI is a
standard that is made for every compilers working in same manner. This standard tells what
the language should do and what is happening. Some C programs are not portable such as
if we make it on Microsoft windows then we can’t move it on Apple Macintosh or IBM
operating system.
About C language
1 (b) Ans:
Characteristics of C language :
It is a portable language. Portable means we can run the programs on verity of computers.
C is a structured language.
C is a small size programming language.
C language has pointer implementation.
• C is a building block for many other currently known languages. Take a look at
Python for example a fully Object-Oriented High-Level programming language. It is
written in C (perhaps C++ too). That tells you if you ever want to know what is
going on under the hood in other languages; understanding C and how it works is
essential.
• C is a compiled language versus an interpreted language. Explained simply, this means
that the code is compacted into executable instruction (in the case of windows anyway)
rather than being "translated" on the fly at run time. This feature also lends heavily to the
speed of C programs.
• A lot of libraries are written in C.
• The main advantages of C language is that there is not much vocabulary to learn, and that
the programmer can arrange for the program is very fast. C programming language is
very easier to learn. C programming language is still a practical and compact language. It
comprises a good semantic. Syntax is of C is clear also. C language is very near to
assembly programming i.e. the hard use of pointers for example is a very powerful
mechanism.
• C has features that allow the programmer to organize programs in a clear, easy, logical
way. For example, C allows meaningful names for variables without any loss of
efficiency, yet it gives a complete freedom of programming style, including flexible ways
of making decisions, and a set of flexible commands for performing tasks repetitively
(for, while, do).
• C is a portable language.
Disadvantages Of C Language
• C does not have OOPS feature that's why C++ is developed. If you know any other
modern programming language then you already know its disadvantages.
• There is no runtime checking in C language.
• There is no strict type checking (for ex: we can pass an integer value for the floating data
type).
• C doesn't have the concept of namespace.
• C doesn't have the concept of constructors and destructors.
#include< stdio.h> :
#include :
The ‘#include’ in the first line of the program is called a preprocessor directive. A
preprocessor is a program that processes the C program before the compiler. All the lines in
the C program beginning with a hash (#) sign are processed by the preprocessor.
stdio.h :
stdio.h, stands for "Standard Input/Output Header", ‘stdio.h’ refers to a file supplied
along with the C compiler. It contains ordinary C statements. These statements give
information about many other functions that perform input-output roles.
Library functions are declared in header files.
For example. Stdio.h provide the information to printf() that what should it do.
Global declaration: This section declares some variables that are used in more than one
function. These variables are known as global variables. This section must be declared
outside of all the functions.
main() function :
The next statement is the main() function. As you already know, this is the place where the
execution of the C program begins. Without this function, your C program cannot execute.
Declaration part:The declaration part declares all variables that are used in the executable
part. Initialization of variables is also done in this section. Initialization means providing
initial value to the variables.
Executable part or Functions or Statements parts: This part contains the statements
following the declaration of the variables. This part contains a set of statements or a single
statement. These statements are enclosed between the braces.
User Defined Functions: These functions defined by the user are called user_defined functions.
These functions are generally defined after the main () function. They can also be defined before
the main () function.
Comments: Comments are not necessary in the program. However, to understand the flow of
program, programmer can include comments in the program. Comments are to be inserted by the
programmer. These are useful for documentation.
Thee compiler doesn’t execute comments. Thus we can say that comments are not a part of the
executable programs
The user can frequently use any number of comments that can be placed any where in the
program
Language? Write about space requirements for variables of different data types.
: DATA TYPES
The C language supports a number of data types, all of which are necessary in writing programs.
Because most CPUs generally support these data types directly, it is unnecessary for the
compiler to convert the data types into the types the CPU understands. In addition to the standard
types, new data types are needed, which are often unique to a given application, and C provides
the mechanisms to create and use types of data created by the programmer.
1. Integer Data Type : Integers are whole numbers with a range of values, Generally an
integer occupies 2
bytes memory space and its value range limited to -32768 to +32768. To control the range
of numbers and
storage space, C has three classes of integer storage namely short int, int and long int. All
three data types
have signed and unsigned forms. Integer Data Types are denoted by int.
For Example :
int num1;
short int num2;
long int num3;
2. Floating Point Types : The float data type is used to store fractional numbers (real
numbers).
Floating point numbers are denoted by the keyword float. The double is same as float but
it takes
double space (8 bytes) than float.
For Example :
float num1;
double num2;
long double num3;
• float (4 bytes)
• double (8 bytes)
• long double (10 bytes)
3.Character Types : Character type variable can hold a single character. As there are
singed and
unsigned int (either short or long), in the same way there are signed and unsigned chars;
both occupy
1 byte each, but having different ranges. Unsigned characters have values between 0 and
255, signed
characters have values from –128 to 127. Character is declared by char.
For Example :
char ch='m';
char name='P';
Void Type :
The void type has no values therefore we cannot declare it as variable as we did in case of
integer and
float. Void data type used with function to specify its type. Like in a simple C program we
declared
“main()” as void type because it does not return any value.
DATA
RANGE BYTE FORMAT
TYPES
-128 to + 127
signed char
0 to 255 1 %c
unsigned char
-32768 to +32767 1 %c
short signed
int
0 to 65535 2 %d
short unsigned
int -32768 to +32767 2 %u
0 to 65535 2 %d
signed int
-2147483648 to 2 %u
unsigned int
+2147483647
4 %ld
long signed int
0 to 4294967295
4 %lu
long unsigned
int -3.4e38 to
+3.4e38 4 %f
float
-1.7e308 to 8 %lf
+1.7e308
double
10 %Lf
-1.7e4932 to
long double
+1.7e4932
. Differentiate between the following with example: (5+5+5)
Long Integer
long integer is a data type that can represent a whole number whose range is greater than
or equal to that of a standard integer on the same machine. The range of long integer is -
2147483648 to 2147483647.
Declaration of long int :
Syntax :
long int color;
OR
long color;
Short Integer
The range of short int is -32768 to -32767.'short int' should assign less than or the same
amount of storage as an 'int' and the 'int' should be less or the same bytes than a 'long int'.
short int must be at least 16 bits long.
Declaration of short int :
short int yellow;
Unsigned Integer
unsigned int has a range of 0 - 65535. "int" can be negative, but "unsigned int" cannot
be negative. %u Prints an unsigned integer. The size can range from 2 to 8, or (again)
whatever the implementation provides.
Signed Integer
C allows the character type char to be signed or unsigned, depending on the platform and
compiler. With an unsigned char, the variable c takes the value 255, but with a signed char
it becomes -1. If the signed or unsigned version of char is explicitly required at certain
points in a program, it can be specified using the declarations signed char or unsigned char.
Declaration of signed and unsigned char :
unsigned char grey;
signed char white;
32. (a) Describe the different types of constants in C with example? (8)
(b) What are the rules for creating C constants explain with example? (7)
Constants in C refer to fixed values that donot change during the execution of a program. C
supports several types of constants as:
TYPES OF C CONSTANTS
1. Integer constants
2. Real constants
3. Character constants
4. String constants
1. Integer constants: An integer constant refers to a sequence of digits
3. Character constants: Asingle character constant contains a single character enclosed within a pair of
single quote marks.
Note that the character constant’5’ is not same as the number 5. The last constant is a blank space.
Character constant have integer values known as ASCII values. For example, the statement
Printf(“%d”,a); would print the number 97,the ASCII value of the letter a. Similarly,
String constants: A string constant is a sequence of character enclosed in double quotes. the characters
may be letters, numbers, special characters and balnk space.
Examples are:
“HELLO!”
“1979”
“welcome”
“?.......!”
“5+3”
“X”
5b Ans:
(b) What are the Escape sequences? List with their uses. (5)
6a Ans:
6b Ans:
Escape sequences
Certain ASCII characters are unprintable, which means they are not displayed on the screen or
printer. Those characters perform other functions aside from displaying text. Escape sequences usually
consist of a backslash and a letter or a combination of a digit. An escape sequence is regarded as a single
character and is therefore valid as a character constant. Escape sequences are typically used to specify
actions such as carriage return and tab movements on terminals and printers. The commonly used
escape sequences are listed below.
\a Bell (alert)
\b Backspace
\f Form feed
\n new line
\r Carriage Return
\t Horizontal tab
\v Vertical tab
\\ Backslash
\0 Null
34. (a) Program for converting uppercase character into lowercase letter? (5)
(b) Write a program to demonstrating operator’s precedence in expression in evaluation x=a-b/3+c*2-
1. (5)
#include<stdio.h>
#include<conio.h>
main()
int c;
clrscr();
c=getchar();
printf(“Lowercase=”);
putchar(c+32);
getch();
#include<stdio.h>
#include<conio.h>
void mian()
{ int a=9,b=12,c=3,x;
clrscr();
getch();
}
35. (a) Write a program to demonstrate the use of size of operators (5)
(b)Define an expression? How can you evaluate an expression? (5)
#include<stdio.h>
#include<conio.h>
Void main()
Char a;
Int b;
flaot c;
long d;
clrscr();
// using the size of operators to compute the size of different data types
getch();
8b Ans:
a+b
3.0*x - 9.66553
tan(angle)
• Most expressions have a value based on their contents.
For example:
sum = x + y + z;
printf("Go Buckeyes!");
1)If an expression has parenthesis, sub expression within the parenthesis is evaluated
first and arithmetic expression without parenthesis is evaluated first.
3)the operators at same precedence are evaluated from left to right or right to left depending
on associativity of operators
36. (a) What is a variable? and write the rules for constructing variable?
(b) Differentiate between definition and declaration of variables in ‘C’ with example? (5)
A variable is a data name that may be used to store a data value. Unlike constants that remain
unchanged during the execution of a program, a variable may take different times during execution.
A variable name can be chosen by the programmer in a meaningful way so as to reflect its function or
nature in the program.
Average
Height
Total
Counter_1
Class_strength
9b Ans:
Both objects and functions can be defined and declared. When we declare a variable or
object then its attribute is known to the compiler. When we define a object then the
attribute is known to the compiler and the object is also be created.
Whenever a variable is defined within the function then it has local scope (local scope
means that variable con only access locally). While when a variable is defined outside the
function then it has global scope (global scope means we can access the variable globally or
anywhere).
The declaration of variables must be done before they are used in the program.
Data-type v1,v2,…….,vn;
int count;
double ratio;
Ex:
Main()/*…………….Program Name……………..*/
{
/*……………….Declaration…………………………..*/
Float x,y;
Int code;
Double deviation;
Unsigned n;
Char c;
/*…………………………Computation…………………………*/
…………………
……………………
………………………
}/*…………………………Program ends…………………..*/
(OR)
}
Here we are passing integer type parameter to fun function and we are also declaring n as
integer which is known
by compiler that is called Declaration and are assigning the value num to n is
called definition.
37. (a) Explain the variable initialization and scope and life span of a variable with example? (8)
(b) What is an operator and List different categories of C operators based on their functionality?
Give examples? (7)
Initialization of variable :
Initialize a variable in c to assign it a starting value. Without this we can't get whatever
happened to memory at that moment.
C does not initialize variables automatically. So if you do not initialize them properly, you
can get unexpected results. Fortunately, C makes it easy to initialize variables when you
declare them.
For Example :
int x=45;
The area of the program where that variable is valid, the amount of time that a variable is
retained, as well as where it can be accessed from, depends on its specified location and
type. The life span of that variable, i.e. the length of time that the variable remains in
memory.
10b Ans:
What is an operator:
If we take an expression 9+5=14, here 9 and 5 are operands and + is an operator.
Types of operator :
Arithmetic Operators
Logical Operators
Assignment Operators
Bitwise Operator
Misc Operator(sizeof(), *(Pointer), &(address)
)
Arithmetic Operators:
The arithmetic operators are +, -, *, %, /, ++, --
For ex. If a variable A=10 then A++=11 and A--=9
Bitwise Operators: Bitwise operators works on bits and perform bit by bit operation.
Assume if A = 60; and B = 13; Now in binary format they will be as follows:
A = 0011 1100 and B = 0000 1101
A&B = 0000 1000
Assignment Operators :
=, +=, -=, /=, %= &=, |= etc are the assignment operators.
For Example. C = A + B will assign value of A + B into C and C+= A means C=C+A.
Misc Operators : These are some special kind of operators such as sizeof(), *(Pointer),
&(address).
For Example. sizeof (a) means that If a is integer then it returns value 4.
*a means a will be a pointer to 'a' variable.
38. Explain the hierarchy (priority) and associativity(clubbing)of operators in ‘C’ with
example? (15)
Hierarchy Of Operations In C
There are some operators which are given bellow with their mean. The higher the position
of an operator is, higher is its priority.
Operator Type
! Logical NOT
+- Arithmetic
==!= Relational
|| Logical OR
= Assignment
ASSOCIATIVITY OF OPERATOR
When an expression contains two operators of equal priority the tie between them is settled
using the associatively of the operators.
While executing an arithmetic statement, which has two or more operators, we may have
some problem as to how exactly does it get executed.
1st *, / , % multiplication,
division,
modular
division
addition,
2nd +, -
subtraction
3rd = assignment
For Example :
i= 2*3/4+4/4+8-2+5/8
i=6/4+4+8-2+5/8
i=1+4/4+8-2+5/8
i=1+1+8-2+5/8
i=1+1+8-2+0
i=2+8-2+0
i=10-2+0
i=8+0
i=8