Posts

Showing posts with the label Conditional Control structure
Chapter # 4 (Conditional Control structure) LAB ACTIVITIES                                         1)      Write a program that reads a number and prints its square if it is greater than 10. Ans: Program: #include<stdio.h> #include<conio.h> int main(int) {             int n;             printf(“\nEnter a number:”);             scanf(“%d”, &n);             if(n>10)             printf(“\nThe square of %d is %d”, n, n*n); getch(); } Output: Enter a number:12 The square of 12 is 144. 2)      Write a progr...

Conditional Control structure. Chapter 4, Lab Activities, Long questions.

Image
  Chapter # 4 Conditional Control structure LAB ACTIVITIES                                LONG QUESTIONS               Question 1. Write a program that reads a number and prints its square if it is greater than 10. Ans: Program: #include<stdio.h> #include<conio.h> int main(int) {             int n;             printf(“\nEnter a number:”);             scanf(“%d”, &n);             if(n>10)             printf(“\nThe square of %d is %d”, n, n*n); getch(); } Output: Enter a number:12 The square of 12 is 144. Question 2. Write a program that reads t...

Conditional Control structure ,Short Questions, Computer Science

Chapter # 4 Conditional Control structure SHORT QUESTIONS Question 1. What is control statement? Ans: A control statement is an instruction which determine the sequence of execution of other statements. In other words, it controls the flow of execution of program of program statements.   Question 1. What is conditional statement? Ans : A conditional statement is an instruction in a programming language that contains a condition.   When a conditional statement is executed, first the condition is evaluated then based on the result (True or False) a particular statement or a set of statements is executed. Conditional statements of c language are : if, if-else, else-if and switch statements.   Question 3. Explain the syntax and purpose of if statement with the help of a computer program? Ans : The if statement has the following general form. if(condition) { Block of statements } When this statement is executed the condition is evaluated. If the co...