Vedanta Let’s Log in Computer Science | Book 10
The output of the above program:
Note:
Each C statement must be closed by a semicolon(;).
Input Function in C
Input function is used to ask data for processing. In C language, scanf() is one of
the input function defined in <stdio.h> header file.
scanf() function
scanf() is one of the most important functions of C program. This function is also
defined in the header file <stdio.h> and used to ask value from keyboard.
Syntax:
scanf(“format string”, argument list);
format string is the combination of format identifier, escape sequence or string
constant.
For example,
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
printf ("Type an integer ");
scanf ("%d",&a);
printf ("\n The value of a is %d.",a);
getch();
}
251 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
In the above program,
scanf (“%d”,&a);
%d o Format Identifier of int data type
&a o & – address operator, a – variable
This function in the above program asks for an integer form keyboard and stores
in the variable ‘a’.
The output of the above program:
getch() function
getch() function is another input function of C language. This function is defined
in the header file <conio.h>. This function is used to ask any one character from
keyboard.
For example,
#include <conio.h>
#include <stdio.h>
void main()
{
char ch;
clrscr();
ch=getch();
printf("The typed character is %c.",ch);
getch();
}
NOTE:
You can see the use of getch() function in every example of C program in this book. The
purpose of using this function in the sample program is to let the user to read output on the
screen. If such type of function is not used, the output screen is closed immediately after
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 252
Vedanta Let’s Log in Computer Science | Book 10
showing the output and returns to the coding window. In the above program, after showing
the output by printf() function, getch() asks for a character and get chance to see the output
until the character is not typed.
Arithmetic Calculations in C Program
There are basically four types of arithmetic operations:
i) Addition ii) Subtraction
iii) Multiply iv) Division
To perform the above arithmetic operations, C language supports the following
arithmetic operators:
List of Arithmetic Operators in C
If A=10 and B=20,
Operator Description Example Result
+ (Plus) A+B 30
- (Minus) Add two operands A-B -10
* (Asterisk) A*B 200
/ (Slash) Subtract second operand from first B/A 2
operand
% (Percentage Symbol) B%A 0
++ (Plus Plus) Multiply two operands
-- (Minus Minus) A++ 11
Divides first operand by second B-- 19
operand
Provides remainder when first operand
is divided by second operand
Increase the value of operand by 1
Decrease the value of operand by 1
C Expression
An expression consists of at least one operand with one or more operators. It is a
legal combination of symbols that represents a value.
For example,
C=A+B
253 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Example of Arithmetic Calculation #1 // Calculate perimeter of a
room
// Calculate perimeter of a room
#include <stdio.h> // is used to write comment
#include <conio.h> as we used REM statement
void main() in QBASIC
{ // is used to write comment
in a single line
int l,b,p;
clrscr(); Output
printf("Type length of a room ");
scanf("%d",&l);
printf("Type breadth of a room ");
scanf("%d",&b);
p=2*(l+b);
printf("Permeter is %d ",p);
getch();
}
Example of Arithmetic Calculation #2 /* Calculate simple Interest
providing Principal, Time &
/* Calculate simple
Interest providing Principal, Time & Rate */ Rate */
#include <stdio.h>
#include <conio.h> /* … */ is also used to write
void main() comment in C Language. It is
{ used to write comments in one
or more lines.
float p,t,r,i;
clrscr(); Output
printf("Type principal, time and rate");
scanf("%f%f%f",&p,&t,&r);
i=(p*t*r)/100;
printf("Simple Interest is %f",i);
getch();
}
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 254
Vedanta Let’s Log in Computer Science | Book 10
Logical Calculation in C
The calculation that is done based on one or more conditions is called logical
calculations. Several relational or comparison operators are used to check the
condition which gives True or False as a calculated result.
Relational Operators in C
Relational Operator checks the relationship between two operands and returns
either 1 (True) or 0 (False). In C programming, relational operators can be used to
take decisions and provide condition in looping statements.
List of Relational Operators in C
If A=5 and B=10,
Operator Description Example Result
== Equal to A==B 0
> A>B 0
< Greater than A<B 1
!= Less than A!=B 1
>= A>=B 0
<= Not equal to A<=B 1
Greater than or equal to
Less than or equal to
if statement
if statement is used to test one or more conditions and execute statement(s) if the
given condition is True.
Syntax:
if (condition)
{
statements
…………………
}
If the condition mentioned in the syntax is True, then the statements written inside
the parenthesis { } is executed.
255 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Example: Output
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
printf ("Type your marks ");
scanf ("%d",&a);
if(a>=40)
{
printf ("You are Pass");
printf ("\nCongratulations!!!");
}
getch();
}
if … else statement
The previous if statement executes the statement only if the given condition is True.
This statement is used to check one or more condition. It executes the condition
either as True or False.
Syntax :
if (condition)
{
statements
…………..
}
else
{
statements
…………..
}
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 256
Vedanta Let’s Log in Computer Science | Book 10
Example: Output
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
printf ("Type your marks ");
scanf ("%d",&a);
if(a>=40)
{
printf ("You are Pass");
}
else
{
printf ("You are Fail");
}
getch();
}
In the above program, if the value of a is greater than or equal to 40, the message
“You have passed” is printed; otherwise, the program shows “You have failed”.
Example of Logical Calculation #1 Output
//Check ODD or EVEN
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n;
printf("Type any number ");
scanf("%d",&n);
if (n%2==0)
{
printf ("\nIt is even.");
}else{
printf ("\nIt is odd.");
}
getch();
}
257 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Example of Logical Calculation #2 Output
/* Find the GREATER number among 2*/
#include <stdio.h>
#include <conio.h>
int main()
{
clrscr();
int a,b;
printf("Type first number ");
scanf("%d",&a);
printf("Type second number ");
scanf("%d",&b);
if(a>b)
{
printf("Greater number is %d ",a);
}else{
printf("Greater number is %d ",b);
}
getch();
return 0;
}
Logical Operators in C
These operators are used to perform logical operations on the given expressions.
There are 3 logical operators in C language. They are: logical AND (&&), logical,
OR (||) and logical NOT (!).
Operators Example/Description
&& (logical AND)
(x>5)&&(y<5)
|| (logical OR) It returns true when both conditions are true
! (logical NOT) (x>=10)||(y>=10)
It returns true when at-least one of the condition is true
!((x>5)&&(y<5))
It reverses the state of the operand “((x>5) && (y<5))”
If “((x>5) && (y<5))” is true, logical NOT operator makes it false
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 258
Vedanta Let’s Log in Computer Science | Book 10
if … else if statement
else-if is used when multipath decisions are required. The general syntax of how
else-if ladders are constructed in 'C' programming is as follows:
if (test - expression 1) {
Statement1;
} else if (test - expression 2) {
Statement2;
} else if (test - expression 3) {
Statement3;
} else if (test - expression n) {
Statement n;
} else {
default;
}
Statement x;
The test-expressions are evaluated from top to bottom. Whenever a true test-
expression if found, statement associated with it is executed. When all the n test-
expressions becomes false, the default else statement is executed.
Let us see the actual working with the help of a program.
Example of Logical Calculation #3 Output
//Find the greatest among 3 integers
#include <stdio.h>
#include <conio.h>
void main()
{ int a,b,c;
printf("Type any 3 integers ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c) {
printf ("Greatest integers = %d",a);
} else if (b>a && b>c) {
printf ("Greatest integers = %d",b);
} else {
printf ("Greatest integers = %d",c);
}
getch();
}
259 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
QBASIC C
ELSEIF else if
AND
&&
OR ||
Looping in C
The looping statement allows a set of instructions to be performed repeatedly until
a certain condition is fulfilled. The looping statements are also called iteration
statements.
Looping statements in C
C provides three kinds of loops:
i) while loop
ii) do loop
iii) for loop
i) while loop
The while loop continues executing a block of code till the given condition is
true. The loop will be terminated when the condition becomes false.
Syntax:
initial variable declaration
while (condition)
{
statements
………………
// increment of counter
}
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 260
Vedanta Let’s Log in Computer Science | Book 10
Example:
//To display first 50 natural numbers
#include <stdio.h>
#include <conio.h>
void main()
{
int c=1;
clrscr();
while (c<=50)
{
printf("%d ",c);
c++;
}
getch();
}
Output
In the above program, the value of variable (counter) c is initialized as 1. The loop
continues till the values of c is less than or equal to 50. In each iteration (loop), the
current value of c is printed and the value of c is increased by 1. When the value of c
becomes 51, the condition becomes false and the loop is terminated.
ii) do loop
The do loop also executes a block of code as long as a condition is satisfied.
The difference between a “do” loop and a “while” loop is that the while loop tests its
condition at the top of its loop; the “do” loop tests its condition at the bottom of its
loop.
261 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Syntax:
initial value declaration
do
{
statement
………………
// increment of counter
} while (condition);
Example:
//To display first 50 natural numbers
#include <stdio.h>
#include <conio.h>
void main()
{
int c=1;
clrscr();
do
{
printf ("%d ",c);
c++;
} while (c<=50);
getch();
}
Output
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 262
Vedanta Let’s Log in Computer Science | Book 10
Difference between while / do loop do loop
while loop Code is executed at first then the
condition is checked.
Test expression (condition) is checked at
first. It is also called exit-controlled loop elgG5 .
It is also called entry-controlled loop elgG5 . n=1
do
n=1 {
while (n>10)
{ printf (“%d”,n);
n++;
printf (“%d”,n); } while (n>10);
n++; Output: 1
}
Output: Nothing
iii) for loop
The for loop can execute a block of code for a fixed number of repetitions. It is
easy to use and defined in a single statement.
Syntax:
for (intial variable, condition, increment )
{
statement
……………….
}
Example:
#include <stdio.h> Output
#include <conio.h>
void main()
{
clrscr();
int c;
for (c=1;c<=10;c++)
{
printf ("%d ",c);
}
getch();
}
263 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Use of Loop – Example #1 Output
//Fibonocci series 1 2 3 5 8 13 ...
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a=1,b=2,c,n=1;
do
{
printf ("%d ",a);
c=a+b;
a=b;
b=c;
n++;
}while (n<=10);
getch();
}
Use of Loop – Example #2 Output
//Series 1 2 4 8 ... upto 10th terms
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n=1,c;
for (c=1;c<=10;c++)
{
printf ("%d ",n);
n=n*2;
}
getch();
}
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 264
Vedanta Let’s Log in Computer Science | Book 10
Use of Loop – Example #3 Output
//Check PRIME or COMPOSITE
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n,i,c=0;
printf ("Type any number ");
scanf ("%d",&n);
for (i=2;i<=n-1;i++)
{
if(n%i==0) c++;
}
if (c==0)
printf("The number is prime. ");
else
printf("The number is composite. ");
getch();
}
Use of Loop – Example #4 Output
//Sum of individual digits
#include <stdio.h>
#include <conio.h>
void main()
{
int n,r,s=0;
clrscr();
printf("Type any one integer ");
scanf("%d",&n);
while (n!=0)
{
r=n%10;
s=s+r;
n=n/10;
}
printf("Sum of individual digits = %d",s);
getch();
}
265 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
POINTS TO REMEMBER
C is a high-level Structured Programming Language.
C language was developed by Dennis Ritchie for the Unix operating system.
C has only 32 keywords.
C is a case-sensitive programming language.
C language is used to develop Operating System, Language Compilers/Interface,
Text Editors, Network Devices, Modern Programs, DBMS, Utilities, etc.
C supports two data types: Basic and Derived.
Basic data type includes int, char, float, etc.
Like QBASIC, C program is also written using different control statements such as if
statement, looping statement.
C provides three looping statements: do, while and for.
C tokens are of six types. They are Keywords, Identifiers, Constants, Strings, Special
symbols, and Operators.
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 266
Vedanta Let’s Log in Computer Science | Book 10
xercise
1. Answer the following questions.
a) Define structured programming.
b) Write the advantages of structured programming.
c) Give any four examples of structured programming language.
d) Why is C called a structured programming language?
e) Write the features of C language.
f) Mention the limitations of C Language.
g) What types of software are developed using C language?
h) Explain the four steps of writing program in C.
i) List the data types supported by ‘C’ language.
j) What are C tokens? Explain its types.
k) Explain the structure of C program.
l) Explain the different looping statements supported by C.
2. Fill in the blanks.
a) C language has …………… keywords.
b) C program was developed for …………… operating system.
c) C supports two types of data: …………… and …………… .
d) C supports …………… types of tokens.
e) To run any program, we need memory location to store data which is called ………. .
f) The printf() function is defined in ……………. header file.
g) There are basically …………… types of arithmetic operations.
3. State whether the following statements are True or False:
a) C does not support object-oriented programming.
b) C is also an Extendable Programming Language.
c) C is not a case-sensitive language
267 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
d) Arrays is a basic data type of C language.
e) Format specifier tells the type of data stored in a variable during input and output
operations.
f) We use printf() function to ask data from keyboard.
4. Match the following: Group B
Group A Identifiers
Void
a) Special word defined for some tasks Keyword
b) C token Pointers
c) Derived data type
d) Basic data type
5. Rewrite the following programs after correcting the bugs.
a) #include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n=5,a=2,c=5;
while (n>1)
{
printf("%d ",a);
a=a+c;
c++;
n--;
}
getch();
}
b) #include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n=5,a=2,c=5;
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 268
Vedanta Let’s Log in Computer Science | Book 10
while (n>1)
{
printf("%d ",a);
a=a+c;
c++;
n--;
}
getch();
}
Lab Activities
1. Write the following program in C Language.
a) Write a program to print your name, date of birth. and mobile number.
Expected output:
Name : Ramita Nepali
DOB : July 14, 2005
Mobile : 98510XXXXX
b) Write a C program to print a block F using hash (#), where the F has a height of six
characters and width of five and four characters. And also make a program to print a
big 'C'.
Expected output: ######
###### ## ##
# #
# #
##### #
# #
# #
# ## ##
######
269 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
c) Write a program that asks for any two integers and find their difference.
d) Write a program that accepts two item’s weight (floating points' values) and calculate
the average weight of the items.
e) Write a program that asks for length, breadth and height of a room, and calculates its
area and volume.
f) Write a C program to calculate a bike’s average consumption from the given total
distance (integer value) traveled (in km) and spent fuel (in liters, floating points’ values)
Test Data :
Input total distance in km: 300
Input total fuel spent in liters: 6
Expected Output:
Average consumption (km/lt) 75.000
g) Write a program that asks for any two numbers and displays the smaller one.
h) Write a C program to read an amount (integer value) and break the amount into smallest
possible number of bank notes.
Test Data :
Input the amount: 975
Expected Output:
There are:
0 Note(s) of 1000
1 Note(s) of 500
4 Note(s) of 100
1 Note(s) of 50
1 Note(s) of 20
0 Note(s) of 10
1 Note(s) of 5
0 Note(s) of 2
0 Note(s) of 1
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 270
Vedanta Let’s Log in Computer Science | Book 10
i) Write a C program to convert a given integer (in seconds) to hours, minutes and
seconds.
Test Data :
Input seconds: 25365
Expected Output:
There are:
H:M:S - 7:2:45
j) Write a program to check whether the supplied number is divisible by 5.
k) Write a program that asks for your marks in Computer Science and checks whether you
are pass or fail if the pass mark is 40.
l) Write a C program that reads an integer between 1 and 12 and print the month of the
year in English.
Test Data :
Input a number between 1 to 12 to get the month name: 6
Expected Output:
June
m) Write a C program that prints all even numbers between 1 and 50 (inclusive).
n) Write down C program to generate the following series:
i) 5, 10, 15, ….. 50
ii) 5, 10, 15, ….. up to 50th terms
iii) 1,2,4,8,16, …. up to 10th terms
iv) 999, 728, 511, …. up to 10th terms
v) 1,2,3,5,8,13,21, …. up to 10th terms
vi) 1
22
333
4444
55555
271 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
o) Write a program that asks for the value of ‘n’ and prints the square of each one of the
values from 1 to n.
Test Data :
Enter the value of n - 4
Expected Output:
1^1 = 1
2^2 = 4
3^3 = 9
4^2 = 16
p) Write a program that asks for any one integer and calculates the sum of its individual
digits.
q) Write a program that asks for any one integer and displays its reverse.
r) Write a program that asks for any one integer and displays its factors.
s) Write a program to check whether the supplied number is prime or composite.
t) Write a program that asks for any one integer and calculates its factorial.
u) Write a program that asks for any one integer and checks whether it is an Armstrong
number or not.
Technical Terms
a) Structured Programming : A programming approach to breakdown main
program into smaller logical modules
b) Top-Down Design :
Process of breaking down the complex problem into
c) Variable : simpler ones
d) Format Specifier :
A memory location used to hold data during run-time
e) Identifier :
f) C Character Set : Tells the type of data stored in a variable during input
and output operations
g) Logical Calculation :
The name given to any variable, function, etc.
h) Token :
A group of valid characters and symbols supported
by C language
A type of calculation which is performed based on
one or more conditions
Basic buildings blocks in C language
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 272
Vedanta Let’s Log in Computer Science | Book 10
Project Work
Accomplish the following tasks and prepare a project report as per the guideline below:
The report should include the following parts:
a) Title page
b) Acknowledgement
c) Table of content
d) Problem statement
e) Problem analysis
f) Flowcharts
g) Program Code
h) Output (Screenshots)
i) Limitation of the program
j) Conclusion
Project 1:
Develop a menu-based application in QBASIC and perform the following file based operations:
Sample Menu:
Main Menu
1. Add Records
2. Display Records
3. Search Records
4. Delete Record
5. Edit Record
6. Exit
Enter Your Choice: 1/2/3/4/5/6/… ?
273 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
Project 2:
Develop a simple “Contact Management System” in QBASIC with the following features:
Able to add, view, edit, search and delete contacts.
The contact details should include name, phone no., address and email.
Project 3:
Develop a simple “Quiz Game” in QBASIC with the following features:
User will choose a random number between 1 and 10.
A question will be asked with 4 options.
Check the answer and award the marks.
Project 4:
Develop a program “Class Routine” either in QBASIC or C Language. The program should ask
or search for teacher’s name and display his or her weekly routine.
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 274
Vedanta Let’s Log in Computer Science | Book 10
Abbreviation
i) bps : bits per second
ii) Kbps : Kilobits per second
iii) Modem : Modulator / demodulator
iv) ADSL : Asymmetric Digital Subscriber Line
v) LAN : Local Area Network
vi) WAN : Wide Area Network
vii) ISP : Internet Service Provider
viii) CAN : Campus Area Network
ix) NetBIOS : Network Basic Input / Output System
x) IPX/SPX : Inter network Packet Exchange / Sequenced Packet Exchange
xi) TCP/IP : Transmission Control Protocol / Internet Protocol
xii) HTTP : Hyper Text Transfer Protocol
xiii) FTP : File Transfer Protocol
xiv) SMTP : Simple Mail Transfer Protocol
xv) POP : Post Office Protocol
xvi) OSI : Open Systems Interconnection
xvii) UTP : Unshielded Twisted Pair
xviii) STP : Shielded Twisted Pair
xix) EMI : Electromagnetic Interference
xx) MC : Media Converter
xxi) UHF : Ultra-High Frequency
xxii) VHF : Very-High Frequency
xxiii) GPS : Global Positioning System
xxiv) GPRS : General Packet Radio Service
xxv) NOS : Network Operating System
xxvi) NIC : Network Interface Card
xxvii) MAC : Media Access Control
xxviii) NAT : Network Address Translation
275 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
xxix) VSAT Vedanta Let’s Log in Computer Science | Book 10
xxx) DARPA
xxxi) ARPA : Very Small Aperture Terminal
xxxii) ISDN : Defense Advanced Research Projects Agency
xxxiii) DSL : Advanced Research Projects Agency
xxxiv) FAQ : Integrated Services Digital Network
xxxv) FTP : Digital Subscriber Line
xxxvi) SMTP : Frequently Asked Question
xxxvii) BBS : File Transfer Protocol
xxxviii) E-mail : Simple Mail Transfer Protocol
xxxix) POP : Bulletin Board System
xl) E-fax : Electronic Mail
xli) IP : Post Office Protocol
xlii) DVD : Electronic Fax
xliii) DVD-RW : Internet Protocol
xliv) CD : Digital Video Disc/Digital Versatile Disc
xlv) CDROM : Digital Video Disc-Rewritable
xlvi) CD-RW : Compact Disc
xlvii) CAD : Compact Disc - Read Only Memory
xlviii) BMP : Compact Disc-Rewritable
xlix) TIFF : Computer Aided Design
l) JPEG : BitMap
li) GIF : Tagged Image File Format
lii) BCD : Joint Photographic Experts Group
liii) ASCII : Graphic Interchange Format
liv) EBCDIC : Binary Coded Decimal
lv) MSB : American Standard Code for Information Interchange
lvi) LSB : Extended Binary Coded Decimal Interchange Code
lvii) MSD : Most Significant Bit
lviii) LSD : Least Significant Bit
: Most Significant Digit
: Least Significant Digit
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 276
Vedanta Let’s Log in Computer Science | Book 10
lix) ICT : Information Communication Technology
lx) IT : Information Technology
lxi) G2G : Government-to-Government
lxii) ETA : Electronic Transactions Act
lxiii) URL : Uniform Resource Locator
lxiv) PHP : Hypertext Preprocessor
lxv) PIN : Personal Identification Number
lxvi) HTTP : Hypertext Transfer Protocol
lxvii) FTP : File Transfer Protocol
lxviii) PC : Personal Computer
lxix) SQL : Structured Query Language
lxx) B2C : Business-to-Consumer
lxxi) B2B : Business-to-Business
lxxii) C2C : Consumer-to-Consumer
lxxiii) EFT : Electronic Fund Transfer
lxxiv) IoT : Internet of Things
lxxv) IaaS : Infrastructure as a Service
lxxvi) SaaS : Software as a Service
lxxvii) CRM : Customer Relationship Management Software
lxxviii) PaaS : Platform as a Service
lxxix) AI : Artificial Intelligence
lxxx) VR : Virtual Reality
lxxxi) Wi-Fi : Wireless Fidelity
lxxxii) QoS : Quality of Service
lxxxiii) GPS : Global Positioning System
277 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
SEE Full Marks: 50
(Model Question)
COMPUTER SCIENCE
lbOPsf lgb{]zgsf cfwf/df cfkm\ g} zn} Ldf l;h{gfTds pQ/ lbg'xf];\ .
Time: 1 hour. 30 minute
(Group 'A' Very Short Questions - 10 Marks )
1. Answer the following questions in one sentence: 6x1=6
a) List any two search engine.
b) Which software is used to remove virus form computer system?
c) Name any one mobile device to use online transaction.
d) What is the extension of MS-Access 2016 database file?
e) What is Modular Programming?
f) Write any two features of C language.
2. Write appropriate technical term for the following: 2x1=2
a) Law that governs the legal issues of cyberspace.
b) The smallest unit to represent information on quantum computer
3. Write the full form of the following: 2x1=2
i) FTP ii) B2C
(Group 'B' Short Questions – 24 Marks)
4. Answer the following questions. 9x2=18
a) Draw a net diagram of any one network topology and enlist any two advantages of it.
b) Define computer ethics. Write any two of them.
c) Describe software security. Write any two measures of software security.
d) Write any two opportunities and threats in social media.
e) What is IoT? Write any two importance of it.
f) Describe database management system with two examples.
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 278
Vedanta Let’s Log in Computer Science | Book 10 2
2
g) Define primary key with two advantages.
h) Give the importance of data sorting.
i) List any two differences between forms and reports.
5. Write down the output of the given program. Show with dry run in table.
DECLARE SUB SER (N)
CLS
FOR K=1 TO 4
READ N
CALL SER (N)
NEXT K
DATA 16, 25, 9, 4
END
SUB CUB (N)
PRINT N ^ 0.5+1
END SUB
6. Rewrite the given program after correcting the bugs:
REM TO CHECK EVEN ODD NUMBER
DECLARE FUNCTION CHK$ (K)
CLS
INPUT” Enter any numbers”; K
PRINT “NUMBER IS”; CHK$
END
FUNCTION CHK$(K)
S=K/2
IF S=0 THEN
A$="ODD"
ELSE
A$="EVEN"
ENDIF
A$=CHK$
END FUNCTION
279 Approved by Curriculum Development Centre, Sanothimi, Bhaktapur
Vedanta Let’s Log in Computer Science | Book 10
7. Study the following program and answer the given questions: 2x1=2
OPEN "Detail.dat" FOR INPUT AS #1
OPEN "Temp.dat" FOR OUTPUT AS #2
INPUT "Enter name of the students "; Sn$
FOR I = 1 TO 10
INPUT #1, Nm$, Cl, A
IF Sn$ < > Nm$ THEN
WRITE #2, Nm$, Cl, A
END IF
NEXT I
CLOSE #1, #2
KILL "Detail.dat"
NAME "Temp.dat" AS "Detail.dat"
END
i. What is the main objective of the program given above?
ii. Do you get any problem in the above program if “Kill” statement is removed? Give
reason.
(Group 'C' Long Questions – 16 Marks)
8. (Convert / Calculate as per the instruction): 4x1=4
i) (1010101) = (?) ii) (93) = (?)
2 16 10 2
iii) (1110) x (101) – (1010) = (?) iv) (10101) ÷ (110)
22 22 22
9. a. Write a program in QBASIC that asks for length, breadth and height of room, and
calculates its area and volume. Create a user-defined function to calculate area
and sub-program to calculate volume. Hint: [A = LxB], [V = LxBxH] 4
b. A sequential data file called "Result.dat" has stored data under the field heading
Roll No., Name, Gender, English, Nepali, Maths, and Computer. Write a program
to display all the information of those students whose gender is ‘F’ and obtained
marks in computer is above 80. 4
10. Write a program in C language that asks for a number and checks whether it is odd or
even. 4
Or
Write a program in ‘C’ language to display the series with their sum. 2,4,6,8,… up to 10th
term.
Approved by Curriculum Development Centre, Sanothimi, Bhaktapur 280