SEBA Board Solution Class 10 Computer Science Chapter 4 Introduction to Loops

SEBA Board Solution Class 10 Computer Science Chapter 4 Introduction to Loops

SEBA Board Solution Class 10 Computer Science Chapter 4 Introduction to Loops full exercise Solution by Computer Sir. Here in this page we have provided SEBA – The Board Of Secondary Education, Assam Class 10 Computer Science Chapter 4 all Question Answer Solution.

 

SEBA Board Solution Class 10 Computer Science Chapter 4: Overview

Board

SEBA / Assam State Board
Class

10

Subject

Computer Science
Chapter Number

4

Chapter Name

Introduction to Loops
Topic

Solution

 

Exercises Question and Answer

(1) Why do use a loop in a C program?

Answer: To repeat the same code for a finite number of times Loop is used.

 

(2) Do we need to use only one type of loop in a C program? Justify answer by writing a C program.

Answer: No. We can’t.

As we know, C program has three different types of loops i.e.

  • For loop
  • .. while loop
  • While loop

A C program can be written in all the three types of loops.

Example:

Printing “Net Explanations” 7 times using  all the three types of loop.

# include<stdio.h>

Int main ()

{

int n = 1, a;

while (n<=7)

{

printf (“Net Explanations\n”)

n++;

}

do

{

printf (“Net Explanations\n”)

n++;

}

do

{

printf (“Net Explanations\n”);

n++;

} while (n<=7);

for (a=1;a<=7;a++)

{

printf (“Net Explanations\n”);

}

return 0;

}

(3) What will happen if we write a while loop with 1 in place of the condition?

Answer: if we write a while loop with 1 in place of condition the loop will be execute forever as the condition is always remain true.

 (4) Name different portions of a for loop. Can we put more than one statement within a portion?

Answer: The three portions of for loop are –

  • Initialization expression
  • Condition / test expression
  • Update expression

Yes we can put.

(5) Answer with True or False.

(a) if the condition of the while loop is false, the control comes to the second statement inside the loop.

Answer: False.

(b) We can use at most three loops in a single C program.

Answer: False.

(c) The statement inside the do-while loop executes at least once even if the condition is false.

Answer: True

(d) Only the first statement inside the do-while loop executes when the condition is false.

Answer: False.

(e) In a do-while loop, the condition is written at the end of the loop.

Answer: True.

 

(6) Programming Exercises.

(A) Write the C program to find the summations of the following series.

(a) 12 + 22 + 32  + …………. + N2

Solution:

#include<stdio.h>

int main()

{

Int i, b, N, sum = 0;

printf(“Enter the value of N:”);

Scanf(“%d”,&N);

For(i=1,i<=N;i++)

{

b=i*i;

sum = sum + b;

}

printf(“\n The summation is %d, sum);

return 0;

}

(b) 13 + 23 + 33 +……………+ N3

Solution:

#include<stdio.h>

int main()

{

Int i, b, N, sum = 0;

Printf(“Enter the value of N:”);

Scanf(“%d”, &N);

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

{

b=i*i*i;

sum = sum + b;

}

printf(“\n The summation is %d”, sum);

Return 0;

}

 

(c) 1*2 + 2*3+3*4+……….+N*(N+1)

Solution:

#include<stdio.h>

int main()

{

Int i, b, n, sum = 0;

printf(“Enter the value of N:”);

scanf(“%d”, &N);

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

{

b=*(i+1);

sum=sum + b;

}

printf(“\n The summation is %d”, sum);

Return 0;

}

 

(B) Write a C program to continuously take a number as input and announce whether the number is odd or even.

Solution:

#include<stdio.h>

int main()

{

Int i, a, N;

printf(“\n Enter the value of N :”);

scanf(‘%d”, &N);

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

{

printf(“\n Enter the value of N :”);

scanf(‘%d”, &a);

If(a%2==0)

printf(“\n The number entered is even”);

else

printf(“\n The number entered is odd”);

}

Return 0;

}

 

(c) Write a C program to display the following pattern.

Solution:

#include<stdio.h>

Int main()

{

int i, a=1;

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

{

Printf(“%d”,a);

}

printf(“\n”);

for(i=1;i<=2;i++)

{

printf(“%d”,a);

}

printf(“\n”);

for(i=1;i<=3;i++)

{

printf(“%d”,a);

}

printf(“\n”);

for(i=1;<=4;i++)

{

printf(“%d”,a);

}

printf9”\n);

For(i=1;i<=5;i++)

{

printf(“%d” , a);

}

Return 0;

}

 

(d) Write a C program to display the following pattern.

Solution:

#include<stdio.h>

int main()

{

int i;

for(i=5;i>5;i–)

{

printf(“%d”, i);

}

printf(“\n”);

for(i=5;i>=4;i–)

{

printf(“%d”, i);

}

printf(“\n”);

for(i=5;i>=3; i–)

{

printf(“%d”,i);

}

for(i=5;i>=2;i–)

{

printf(“%d”,i);

}

printf(“\n”);

for(i=5; i>=1; i–)

{

printf(“%d”,i);

}

return 0;

}

 

(e) Write a C program to display the following pattern.

Solution:

#include<stdio.h>

int main()

{

Int i ;

for(i=5;i>=i–)

{

printf(“%d” , i);

}

printf(“\n”);

for(i=5,i>2; i–)

{

printf(“%d”,i);

}

printf(“\n”);

for(i=5; i>3; i–)

{

printf(“%d”,i);

}

printf(“\n”);

for(i=5; i>=4; i–)

{

Printf(“%d”, i);

}

printf(“\n”);

for(i=5; i>=5; i–)

{

Printf(“%d”, i);

}

printf(“\n”);

for(i=5; i>=5; i–)

{

Printf(“%d”, i);

}

return 0;

}

 

Dear Student, I appreciate your efforts and hard work that you all had put in. Thank you for being concerned with us and I wish you for your continued success. 

Updated: June 7, 2022 — 3:09 pm

4 Comments

Add a Comment
  1. i would be so satisfied if some extra questions are provided to us ..as this time the book is new we don’t have any idea about question paper.. please provide some inside questions nd answers
    thank you

  2. No 2 answer.. It should be do while loop and also in the example given.. The semicolons after the printf statements are missing.
    Kindly fix the errors.

  3. So good to know this it spreads beautifully the computer knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *