Hyperlink 10 Answer Keys
Hyperlink 10 Answer Keys
Hyperlink 10 Answer Keys
Function n
8. A statement causes the computer to carry out some definite action. There are three types of statements in C :
a) Expression statement: It consists of an expression followed by a semicolon. For example, c =a+ b;
b) Control statement: It enables you to execute the particular set of statements depending on a condition and controls
the flow of a program.
c) Compound statement: It consists of several individual statements enclosed within a pair of brackets.
LAB ACTIVITY
1. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Welcome to the world of computers");
getch();
}
2. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Name : Kritika ");
printf("Class : X ");
printf("Roll_No : 4 ");
printf("Age : 15");
getch();
}
3. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
getch();
}
4. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Failures are the Pillars of Success");
getch();
}
CH-4 DATA TYPES AND OPERATORS
A. Fill in the blanks:
1. Expression
2. Variable
3. Postfix Decrement
4. Syntax
5. Two
6. True
7. Ternary Operator
8. Float
9.15
B. State True or False:
1. True
2. False
3. False
4. False
5. True
6. False
7. True
C. Multiple Choice Questions:
1.(c) Operators
2.(a) Data type
3.(a) 2 or 4
4.(b) Assignment
5.(a) Unary
6.(b) Arithmetic
7.(a)%
8.(a) Relational
9.(a) &&
10.(a) String
D. Answer in one word or sentence:
1. 8 bytes
2. 6 decimal places
3. Six operators
4. False
5. 6
6. False
7. 1 byte
E. Answer the following:
1. Data types are defined as the data storage format that a variable can store to perform a specific operation. The size
of a variable and constant are determined by data types. They are classified as
a) Primitive data types b) Derived data types
2. The basic data types available in Care:
a) int: Integer data type is used to store whole numbers. It can store both positive and negative numbers. Its size is 2
or 4 bytes.
b) float: It can hold real numbers, such as 2.321, -9.654, etc. Its storage size is 4 bytes and it has a precision of 6 decimal
places.
c) double: It is similar to float data type. The only difference is that its storage size is 8 bytes and precision up to 15
decimal places.
d) char: This data type can store either a single character or a combination of characters called string. Its storage size
is 1 byte.
3. Variable declaration:
The syntax of declaration of a variable is:
<Data type><variable_name>;
For example, the statement
int age ;
Will declare the variable age with data type int.
Initialization:
Assignment operator(=) is used to initialize a variable. For example, int age = 15;
The above statement declares an integer type of variable age and initializes it with value 15.
4. Float and double data types are used to store decimal values. But they differ from each other in terms of their sizes
and precision values. Float data type has size of 4 bytes and precision up to 6 decimal places, whereas double data type
has size of 8 bytes and precision up to 15 decimal places.
5. Operators are the special symbols that perform specific operations on one, two or more operands, and give mean
ingful result. Cprovides us a large number of operators to perform arithmetic and logical calculations easily.
6. An expression is a valid combination of operators and operands, which returns computed result. Some of the exam
ples of expression are:
a) x = 8 * 4; b) c = a+ b/2; c) w = x + y + z ;
7. Ternary operator works on three operands. It is also known as conditional operator. Its syntax is:
Variable = Expression 1? Expression 2: Expression 3 ;
If Expression 1 is true then the Expression 2 will be evaluated and assigned to the Variable, otherwise, Expression 3 will
be evaluated and assigned to the Variable.
8. If we use ++ as prefix(++var), the value of operand is increased by I and then it is returned. Whereas, if we use ++
operator as postfix(var++), the value of operand is returned first and then it is incremented by 1.
9. Relational operators are used to compare two operands and determine the relation between them. It gives result in
two states either true or false. Cprovides 6 relational operators. These are:
a) Greater than( > ) b) Less than( < ) c) Greater than or equal to( >=)
d) Less than or equal to(<=) e) Equal to(==) f) Not equal to(!= )
10. Logical operators are used for logical operations, which compare the result of relational expressions and give result
in the form of true or false. C provides three logical operators.
a) AND(&&) b) OR (11) c) NOT(!)
LAB ACTIVITY
1. #include<stdio.h>
#include<conio.h>
void main()
{
int p=200000, t=4;
float r=2.5;
float si=p*r*t/100;
clrscr();
printf("Simple interest = %f", si);
getch();
}
2. #include<stdio.h>
#include<conio.h>
void main()
{
int n1=34,n2=12,n3=23;
int sum=0;
float avg=0;
sum =nl+n2+n3;
printf(" Sum of three numbers = %d", sum);
avg = sum/3;
clrscr();
printf("Average of three numbers = %f", avg);
getch();
}
3. #include<stdio.h>
#include<conio.h>
void main()
{
int 1=5,b=7;
int area=l*b;
clrscr();
printf("Area of rectangle is %d",area);
getch();
}
4. #include<stdio.h>
#include<conio.h>
void main()
{
float salary = 30000;
float incre = 0;
float total_salary = 0;
clrscr();
incre= salary*lS/100;
total_salary=salary+incre;
printf("Salary after increment %f",total_salary);
getch();
}
5. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=40,b=5;
int c=a/b;
int d=a%b;
printf("\n Quotient = %d", c);
printf("\n Remainder = %d", d);
getch();
}
6. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=lO, b=12;
int c=a;
a=b;
b=c;
printf("After swapping");
printf("\n a = %d",a);
printf("\n b = %d",b);
getch();
}
2. #include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two numbers \n" );
scanf("%d",&a);
scanf("%d",&b);
clrscr();
printf("First number %d",a);
printf("\n" );
printf("Second number %d",b);
getch();
}
3.
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter a number or a character \n" );
ch=getchar();
printf("Printing value using putchar() \n" );
putchar(ch);
getch();
}
4.
#include<stdio.h>
#include<conio.h>
void main()
{
char a, b;
printf(" Using getch() \n");
printf(" Press any key \n");
clrscr();
a=getch();
printf("Pressed key is not visible \n");
printf(" Using getche() \n");
printf(" Press any key \n");
b=getche();
printf("\n Pressed key is visible \n");
getch();
}
SAMPLE PAPER- I
A. Fill in the blanks:
1. Comment lines
2. Algorithm is a
3.Sequence
4. Token
5. main()
6.Syntax
7. True
8. getch()
9. Passwords, Pin numbers
10. gets( )
B. State True or False:
1. False
2. False
3. True
4. False
5. True
6. True
7. True
8. True
9. True
10. False
C. Multiple Choice Questions:
1. (a) Start/ Stop
2. (a) Dennis Ritchie
3. (a) 2 to 4
4. (a) Conversion specification
5. (c ) Spyware
t
ment. For example:
int a=8, b =7, c =9 ;
( a> b)
•
int d = a + b+ c ;
Printf("%d", d) ;
a++; Compound statement
b--;
}
b) Break statement: This statement is used to bring the control out of the switch expression. It should be written with
every case. If we do not write break statement at the end of each case then all the subsequent cases will get executed.
The following segment explains the use of break statement:
int ch=2;
switch( ch)
{
easel:
printf("\n Color is red" );
break;
case 2:
printf("\n Color is green");
break;
case 3:
printf("\n Color is blue");
break;
}
LAB ACTIVITY
1.
#include<stdio.h>
#include<conio.h>
void main()
{
int a=15,b=90,c=10;
clrscr();
2.
#include <stdio.h>
#include<conio.h>
void main()
{
int n, i, flag=O;
printf("Enter a positive integer: ");
scanf{"%d",&n);
for(i=2;i<=n/2;++i)
{
if{n%i==O)
{
flag=l;
break;
}
if (flag==O)
printf{"%d is a prime number.",n);
else
printf{"%d is not a prime number.",n);
getch();
}
3.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a=1,b=4,c=2,d;
float r1,r2;
d=b*b-4*a*c;
clrscr();
if(d>=O)
{
rl={-b+sqrt(d))/(2*a);
r2={-b-sqrt(d))/(2*a);
printf("\n Rootl = %f",r1);
printf("\n Root2 = %f",r2);
}
else
printf("\n Roots are imaginary");
getch();
}
4.
#include <stdio.h>
#include <conio.h>
void main()
{
char n;
printf("Enter the value");
scanf("%c",&n);
switch(n)
{
case'-':
printf("You entered negative.");
break;
case'O':
printf(" number is zero.");
break;
default:
printf("number is positive ");
break;
}
getch();
5.
#include<conio.h>
#include<stdio.h>
void main()
{
int x,y,z;
printf("\n Enter the sides of a triangle");
scanf("%d %d %d",&x,&y,&z);
if ((x==y) && (y==z))
printf("\n The triangle is equilateral");
else if ((x==z) 11 (y==z) 11 (x==y))
printf("\n The triangle is isoseles");
else
printf("\n The triangle is scalene");
getch();
}
6.
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
printf("Enter character \n");
scanf("%c", &c);
clrscr();
switch(c)
{
case'a':
case'e':
case'i':
case'o':
case'u':
printf("lts a vowel");
break;
default:
printf("lt is not a vowel ");
break;
}
getch();
}
CH- 7 LOOPING CONTROL STRUCTURE
A. Fill in the blanks:
1. Three
2. Initial
3. Statements
4. Label
5. Exit control
6. Jump
7. For
B. State True or False:
1. False
2. False
3. True
4. True
5. False
6. True
7. True
8. False
9. False
10. True
C. Multiple Choice Questions:
1. (b) Looping
2. (c) Nested
3. (c) do while
4. (b) for
5. (a) Step value
6. (b) break
7. (a) Loop
8. (c) Jumping
9. (a) Continue
D. Answer in one word:
1. Double quotes of format specification in printf statement are missing.
2. printf statement is missing.
3. In for statement, semicolon (;) after a<lO is missing. And wrong format specification is given in printf statement.
4. Increment step is missing.
E. Answer the following:
1. Looping control structure has a condition and a block of statements. Till the time the specified condition remains
true the compiler keeps executing the loop i.e., the statements are written in its body.
2. The for loop is used to repeat a particular task finite number of times. It executes a set of statements only after the
condition evaluates to true.
3. The while loop tests the condition before executing the loop body. When the condition becomes false, the control
comes out of the loop. On the other hand, do while loop first executes the block of statements and then checks the
condition. The body of the loop gets executed at least once even if the condition is found false.
4. A loop written inside another loop is called a nested loop. The inner loop gets executed first and then the outer loop
executes. The following example explains the use of nested loop:
(GD Pick program 8 page no. 70)
5. Break statement is used to terminate the execution of the current loop and the control comes out of the loop,
whereas the continue statement skips the next statement and takes the control to the header of the loop.
6. The goto statement is used to change the normal sequence of program execution by transferring the control to some
other part of the program unconditionally.
LAB ACTIVITY
1.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,d,p;
printf("Prime numbers are ");
for(n=2;n<=S0;n++)
{
for(d=2;d<n;d++)
{
if(n%d==0)
{
p=0;
break;
}
p=l;
}
if(p)
printf("\t%d",n);
}
getch();
}
2.
#include <stdio.h>
#include<conio.h>
void main ()
{
float i= 10, s = 0.0;
for (i=l; i<=4; i++)
s = s + 1/i;
printf("Sum is %f", s);
getch();
3.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter the number \n");
scanf("%d",&n);
printf(" Reverse of the number is ");
while(n>0)
{
int m=n%10;
printf("%d",m);
n=n/10;
}
getch();
}
4.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=l; i<=100;i=i+2)
{
printf("\t %d",i);
}
getch();
}
5.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=O;
n=l;
printf("Natural numbers are \n");
•
clrscr();
while(n<=lO)
{
printf("\n %d",n);
sum=sum+n;
n++;
}
printf("\n Sum of 10 natural numbers = %d",sum);
getch();
}
6.
#include <stdio.h>
#include<conio.h>
void main()
{
int i, numl, num2, min, hcf=l;
printf("Enter any two numbers to find HCF: ");
scanf("%d %d", &numl, &num2);
min = (numl<num2) ? numl: num2;
for(i=l; i<=min; i++)
{
if(num1%i==O && num2%i==O)
{
hcf = i;
}
}
printf("HCF of %d and %d = %d\n", numl, num2, hcf);
getch();
}
b) #include<stdio.h>
#include<conio.h>
void main()
{
int a=l, i;
clrscr();
for( i=0;i<=4;i++)
{
if(a==l)
{
printf("\n %d",a);
a=ll;
}
if(a<=14641)
{
printf("\n %d",a);
a=a*ll;
}
}
getch();
}
c) #include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
for(i=l;i<=S;i++)
{
printf("\n");
for(j=l;j<=(2*i-l);j++)
printf("*");
}
getch();
}
CH- 8 FUNCTIONS IN C
A. Fill in the blanks:
1. Function definition
2. Built-in
3. Program control
4. Parameter
5. Call by value
6. Empty
7. Argument
8. Formal parameters, Actual arguments
B. State True or False:
1. False
2. False
3. True
4. True
5. True
6. False
7. False
8. True
C. Multiple Choice Questions:
1. (a) Input
2. (b) Buitl-in
3. (b) User defined
4. (a) Body
5. (a) Recursion
6. (b) Return type
7. (a) Actual parameters
D. Answer in one word or one sentence:
1. Only one return statement gets executed.
2. Formal parameters
3. Call by reference
4. Call by value
5. There are two ways of calling the function.
2.
#include<stdio.h>
#include<conio.h>
void prime(int a);
void main()
{
int n;
clrscr();
printf("\nEnter any number", n);
scanf("%d",&n);
prime(n);
}
void prime(int a)
{
int f= O;
int i ;
for (i = 1; i <= a; i++) {
if (a % i == O)
{
f++;
}
}
if (f == 2)
{
printf("n is a Prime number");
}
else
{
printf("n is not a Prime number");
}
getch();
}
3.
#include<stdio.h>
#include<conio.h>
function1();
function2();
void main()
{
clrscr();
printf("First function \n");
function1();
printf("Second function \n");
function2();
getch();
}
function1()
{
printf("Welcome and good luck for class 10 \n");
}
function2()
{
printf("Perseverance leads to success");
}
4.
#include<stdio.h>
#include<conio.h>
find_cube(int n); //function prototype
void main()
{
clrscr();
int n;
printf("Enter number \n" );
scanf("%d",&n);
find_cube(n); //function calling
getch();
}
find_cube(int n) //function definition
{
int cube=n*n*n;
printf("Cube of the number is= %d \n",cube);
}
5.
#include<stdio.h>
#include<conio.h>
void series( int a);
void main()
{
int n;
printf("\nEnter the value" );
scanf("%d", &n);
series(n);
}
void series( int a)
{
int sum = 0, i;
for(i=l; i<=a; ++i)
sum+=i;
printf("Sum= %d", sum);
getch();
}
6.
#include <stdio.h>
#include<conio.h>
void hcf(int a, int b);
void lcm(int a, int b);
void main()
{
int c, d;
}
printf("The HCF is %d", a);
}
void lcm(int a, int b)
{
int i =1;
for(; a != b; i++)
{
if((a*i)%b == O)
break;
}
printf("\nLCM is %d", a*i);
}
7.
#include<stdio.h>
#include<conio.h>
swap(int x,int y);
void main()
{
int x,y;
printf("Enter first number \n" );
scanf("%d",&x);
printf("Enter second number \n" );
scanf("%d",&y);
swap(x,y);
getch();
}
swap(int x, int y)
{
x=x+y;
y=x-y;
x=x-y;
printf("After swapping : x = %d, y = %d", x, y);
}
3. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout«"Be Good and Do Good"«endl;
cout<<endl;
cout<<"Be Good and Do Good"<<endl;
cout«endl;
cout«"Be Good and Do Good"«endl;
cout<<endl;
cout<<"Be Good and Do Good"<<endl;
cout«endl;
cout<<"Be Good and Do Good"«endl;
cout«endl;
getch();
}
4. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout«"To acquire knowledge, one must study; but to acquire wisdom, one must observe"«endl;
getch();
}
CH-10 PROGRAMMING INC++
A. Fill in the blanks:
1. Single quotes
2. Whole numbers
3. Float
4. Variable
5. int
6. Relational
7. Data type
8. Loops
9. Branching
10. Expression
B. Write True or False:
1. False
2. False
3. True
4. True
5. False
6. True
7. True
8. True
9. False
10. True
2. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int r=3;
float area=3.142*r*r;
cout<<"Area of circle is"<<area;
getch();
}
3. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int p=20000, t=3;
float r=2.5;
float si=p*r*t/100;
cout<<"Simple interest is"<<si;
getch();
}
4. #include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
cout<<"Enter any number"<<endl;
int n;
cin>>n;
float sqroot=sqrt(n);
cout<<" Square root of the entered number is"<<sqroot;
getch();
}
5. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n;
cout<<" Enter any number"<<endl;
cin>>n;
cout<<"Factors are:"<<endl;
for(int i=l; i<=n; ++i)
{
if(n%i==0)
cout<<i<<endl;
}
getch();
}
6.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,x,sum=0;
cout<<"How many numbers?";
cin>>n;
for(i=l;i<=n;++i)
{
cout<<"\nEnter number";
cin>>x;
sum+=x;
}
x=sum/n;
cout<<"Average="<<x;
getch();
}
7. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
for(i=2;i<=100;i=i+2)
cout<<i<<endl;
getch();
}
8.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,sum=0;
cout«" \nEnter the value\n";
cin>>n;
for(i=l;i<=n;++i)
sum+=i;
cout<<"\n Sum="<<sum;
getch();
}
SAMPLE PAPER - II
A. Fill in the blanks:
1. Statements
2. Entry
3. Switch
4. Looping
5. Formal parameters, Actual arguments
6. Empty
7. Encapsulation
8. Attributes, Behaviour
9. Data type
10. Data Abstraction
B. State True or False:
1. False
2. True
3. True
4. False
5. False
6. False
7. True
8. True
9. False
10. True
C. Multiple Choice Questions:
1. (c) do-while
2. (c) is compulsory to be used in a switch statement
3. (b) User defined
4. (c ) Polymorphism
5. (b) Explicit
D. Answer in one word:
1. Compound statements
2. Relational operator
3. Only one of the return statements will get execute.
4. Relational operator
5. <iostream.h>
6. C++ supports 48 keywords
7. Relational operator determines the relation between two operators.
8. Bjarne Stroustrup
9. II
10. Encapsulation