Exercises
C is a high-level Structured Programming Language.
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.
Exercises
1. Answer the following questions.
a) What is structured programming? Give any four examples of structured
programming language.
b) Write the advantages of structured programming.
c) Write the features of C language.
d) List the data types supported by ‘C’ language.
e) Explain the structure of C program.
f) Differentiate between int and float data type in C.
g) Explain the different looping statements used in C.
2. Fill in the blanks.
a) Structured Programming is also known as ……………. .
b) Single-Entry, Single-Exit concept can be achieved from the …………….
fundamental Control Structure.
c) To run any program, we need memory location to store data which is called
244 Computer Science : Grade 10
……….....
d) ……………. is the name given to any variable, function etc.
e) A group of valid characters and symbols supported by C language is called
……………. .
f) The printf() function is defined in ……………. header file.
g) There are basically …………… types of arithmetic operations.
h) C language has …………… keywords.
3. State whether the following statements are 'True' or 'False'.
a) Top-Down Design is the process of breaking down the complex problem
into simpler ones.
b) Format specifier tells the type of data stored in a variable during input and
output operations.
c) C is not a case-sensitive language.
d) C Language has all the features of Object Oriented Programming Language
such as Classes, Objects, Inheritance etc.
e) C language is far closer to the hardware than most other languages.
f) We use printf() function to ask data from keyboard.
g) C is a Structured Programming Language.
4. Re-Write the below programs after correcting the bugs.
a) // Calculate sum of any three numbers
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c,s;
printf ("Type any three numbers ");
Computer Science : Grade 10 245
scanf ("%f%f%f%f",a,b,c);
s=a+b+c
printf("\nSum=",&s);
getch();
}
b) //Series 100 95 90 85 ..... 5
#include <stdio.h>
#include <conio.h>
int main()
{
cls;
int n=100;
do
{
scanf("%d ",n);
n=n-5;
}while(n>=5)
getch();
}
c) //Reverse of an integer
246 #include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int n,r,d;
printf("Type an integer ");
Computer Science : Grade 10
scanf("%d",&n);
while(n<>0)
{
d=n mod 10;
r=r*10+d;
n=n/10;
}
printf("\nReversed integer = %d ",d);
}
Lab Activities
1. Write the below program in C Language.
a) Write a program that asks any two numbers and find their sum.
b) Write a program that asks Principal Amount, Rate and Time and calculates
Simple Interest.
c) Write a program that asks length & breadth of a room and calculates its
area and perimeter.
d) Write a program that asks any two numbers and displays the smaller one.
e) Write a program to check whether the supplied number is divisible by 7 or
not.
f) Write a program that asks your marks in Computer Science and checks
whether you are pass or fail if the pass mark is 40.
g) Write down C program to generate the below 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
Computer Science : Grade 10 247
vi) 1
22
333
4444
55555
h) Write a program that asks any one integer and calculates the sum of its
individual digits.
i) Write a program that asks any one integer and displays its reverse.
j) Write a program that asks any one integer and checks whether it is an
Armstrong number or not.
k) Write a program that asks any one integer and calculates its factorial.
l) Write a program that asks any one integer and displays its factors.
m) Write a program to check whether the supplied number is prime or
composite.
Technical Terms
Structured Programming : A programming approach to breakdown main program
into smaller logical modules
Top-Down Design : Process of breaking down the complex problem into
simpler ones
Variable : A memory location used to hold data during run-time
Format Specifier : Tells the type of data stored in a variable during input and
output operations
Identifier : The name given to any variable, function etc.
C Character Set : A group of valid characters and symbols supported by C
language
Logical Calculation : A type of calculation which is performed based on one
or more conditions
248 Computer Science : Grade 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 to do different file handling tasks.
Sample Menu:
1. Display the records
2. Insert new records
3. Edit a record
Enter Your Choice (1/2/3):
4. Delete records
5. Exit
Choose [1-5]:
Project 2:
Develop a simple "Contact Management System" in QBASIC with the following
features:
Computer Science : Grade 10 249
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.
250 Computer Science : Grade 10