You must sign in Login/Signup

New student? Register here

An important facility for 12th class students preparing for short questions computer science 12th class chapter 11 of BISE. Get hundreds of questions to prepare and get better marks in 12th computer science
Generic placeholder image

0

Our database contains a total of 0 questions for computer science Short Questions. You’ll prepare using this huge databank.

Question: 1
What is control structure?
Answer: 1
1-64
Control Structure: Control Structure: are statement used to control the flow of execution in a program or function.The C control structures enable us to group individual instructions into a single logical unit with one entry point and one exit point .
Kinds: Program instructions can be organized into three kinds of control structures to control execution flow:
  • Sequence
  • Selection
  • Repetition
Question: 2
List types of control structure.
Answer: 2
2-64
Types of Control Structures: There are the following types of control structure:
  • Sequence
  • Selection
  • Repetition.
Question: 3
Describe sequence structure.
Answer: 3
3-64
Sequence Structure: In case of sequence structure , instruction are executed in the same order in which they are specified in the program.
Question: 4
Trace the error in the following code.
Void main (void);
{
Int a , b;
A= -10
B = 40
If (a< 0);
B=SQRT (a);
Printf ("result = %f", b );
Getch( );
}
Answer: 4
4-64
Errors:
  • 1st errors is ; terminator sign has been used with Main starting which is not allowed.
  • 2nd error terminatorsign has been not used in statements where variable are being defined.
  • 3rd eror is terminator sign has been used with If statement which is not allowed .

Question: 5
Find out errors:
#include <stdio>
Void main( )
[
If (50>20) then
Printf ("Islamic Country ");
Getch( )
}
Answer: 5
5-64
Errors:
  • 1st error is wrong library has been used in this program.
  • 2nd error is wrong brackets have been used in Main body.
Question: 6
Find error in the following segment .
Float y 3.14;
If (y == 3)
Printf ("Errors");
Answer: 6
6-64
Errors: is equal sign has not been used in statement where variable y is being declared.
Question: 7
Define Selection Structure.
Answer: 7
7-64
Selection Structure : ASelection Structure chooses which statement or a block of statements is to execute.
Types : In C, there are two basic selection statements:
  • If-else
  • Switch
Question: 8
Find Errors.
#include (Stdio.n);
#include <conio.c>
Void main ()
{
If (16>10) then printf ("%C","Pakistan");
Getch( );

Answer: 8
8-64
Errors:
  • 1st error is wrong libraries have been used.
  • 2nd error is bracket and terminator has been used with library.
  • 3rd error is word then has been use in If statement.
Question: 9
Trace the output.
Void main( )
{int marks;
Printf ("\n enter your marks ");
Scanf ("%d",&marks);
If (marks >= 40)
Printf ("\n congratulation");
}
Answer: 9
9-64
Output :
Enter your marks 50
Congratulation
Question: 10
Trace the error.
Int a ; b= 5
If (a<b)
Printf ("\nA is less than b");

Answer: 10
10-64
Error:
  • 1st error is wrong method has be used to declare variables.
  • 2nd error is terminator sign has not been use in statement where variables are being defined.
Question: 11
Find error from the following .
Int y;z;
If(y = = z)
Printf ("yes)"
Answer: 11
11-64
Error :
  • 1st error is method to declare variable is wrong
  • 2nd error is terminator has not been used in printf statement
Question: 12
Find Error.
Int price= 10
If (price! =10)
price=0
Answer: 12
12-64
  • Error is terminator is necessary for terminate the statement but has not been used in this program.
Question: 13
What will be output of the following ?
Int x=5, y=10;
If (x>y )
Y =2;
Answer: 13
13-64
Output:
Y = 2
Question: 14
Trace out the errors in the following code.
Void main ( )
{
Int R ;
R= 17;
If (R>0)
{
R= R*3.14*3.14;
};
PRINTF ("THE VALUE OF ARE IS =%F",R);
Getch ( );
}
Answer: 14
14-64
Error:
  • 1st error is variable r has not been defined.
  • 2nd error is : semicolon has been used after closing brackets of If statement which is not allowed.
Question: 15
Trace the output of the following code.
Inta = 4, b=2, c,=5;
If (a>b)
A= 5;
If (c==a)
A= 6;
Printf("%d",a);
Answer: 15
15-64
Output:
a = 6
Question: 16
Find the output of the following code
#include <stdiio.h>
Void main ( )
{
Char grade ='c';
If (grade ='a' || grade= 'b' & &grade ='c'
Printf ("FAIL");
Else
Prints ("pass");
}
Answer: 16
16-64
Output:
Pass
Question: 17
What is the error in the following codes?
Int x= 10, y=20;
IF (X >10&Y<30)
PRINTF ("%D",X+Y);

Answer: 17
17-64
ERROR:
  • Error is data type integer must be starting with small i.
Question: 18
Trace error from the following code.
If (7! =10
Printf ("hello");
Else-do
Printf ("welcom");
Answer: 18
18-64
Errors:
  • 1st errors is if statement has not been written correctly.
  • 2nd error is there is no else-do statement in C language.
Question: 19
Find output from the following .
Int pirce = 19;
If (price! =10)
Printf ("price");
Answer: 19
19-64
Output: Price = 19
Question: 20
Write the syntax of "if -else "statement.
Answer: 20
20-64
Syntax :
If (condition)
{ block of if (true case )
}

Else
{ block of else (false true ) }
Question: 21
Find output of the following code .
Int a = 1,b =6;
If (a +b <7);
{
Printf ("%d",a);
}
Else
{
Printf {"%d",b);
}
Answer: 21
21-64
Output;
B= 6
Question: 22
Predict the output of the following code.
If (4 %2 ==0)
Printf ("programming makes the life interesting \n"); else
Printf ("Programming is difficult to learn");
Answer: 22
22-64
Output:
Programming makes the life interesting.
Question: 23
Trace Error :
Void main ( )
{
Int a =2 ;
If (a ==1)
Printf ("ok);
Else
Printf ( "cancel");
Getch( );
Answer: 23
23-64
Error:
  • Error is there must be brackets for If statements body.
Question: 24
Write the syntax of if-else statement .
Answer: 24
24-64
if-else statement : The keyword else has been used to specify two different choices with if statement
Syntax:
If (condition)
{
block of if (true case)
}
Else
{
block of else (false true)}
Explanation: if the condition is true the block of if statement is executed and if the condition is false, the block of else statement is executed
Question: 25
Track the errors .
Int p= 20;
If( price == 20 )
Price = 0;
Else
Price =2,
Answer: 25
25-64
Errors:
  • Errors is ; semicolon has not been used after condition of else statement.
Question: 26
Trace the output.
If (1==2)
Printf ("hello");
Elde
Printf( "hello");
Else
Printf ("correct it");
Answer: 26
26-64
Output ; Correct it
Question: 27
Trace the erroe in the following code.
Void main ( )
{
Int x = 0
If (x = 1 )
Printf ("hello");
Else
Printf ("bye")
}
Answer: 27
27-64
Error is ;semicolon has not been used after the condition of else statement

Question: 28
Find errors.Void main ( ){Int a =2If (a= 1)Print f ("OK");ElsePrintf ("Cancel");Getch ()}
Answer: 28
28-64
Erros is ; semicolon must be used after defining the variable a.
Question: 29
Predict the output for the following code.
Int a, b,c;
A= 10;
B= 3;
If (a %b == 1)
C= 0;
Else
C=1;
Printf ("%d",c)
Answer: 29
29-64
Output :
C = 0
Question: 30
What is the output of the following code?Int m, n;M = 0;N= m;If;(m = =n)Printf ("BWP");Elseprintf("LHR");
Answer: 30
30-64
Output: BWP
Question: 31
Find output.
Int p= 3, q = 5;
If ((p>q)|| (q! =s))
P = p+1;
Else
P = p*2;
Printf ("p =%d",p);
Answer: 31
31-64
Output:
P =6
Question: 32
Trace the error in the following code.#include <stdio.h>Void main( );{If (16<18) thenPrintf ("%c",ok);Getch ( );}
Answer: 32
32-64
Errors is there is if then statement in C language.
Question: 33
Trace the error in the following code.Void main (void){Int x= 10;If (x! =10);X + +;Else (x= =10)X - -;}
Answer: 33
33-64
Errors is ; semicolon must not be used after If condition.
Question: 34
Trace the error from the following code.Void main ( ){Int a =2;If (a =1);Printf ("ok");ElsePrintf ("No");}
Answer: 34
34-64
Errors is ; semicolon must not be used after If condition.
Question: 35
What is the output of the following code?Int x = 1 ;If( y =z =3;If( (x== y) || (y ==z) || (z==2))Printf ("yes");ElsePrintf ("no")
Answer: 35
35-64
Output: Yes
Question: 36
Determine the output of the following code.
Inta a, b;
B= 20; a=10;
If (b< =a)
Printf ("No")
Else
Printf ("yes")
Answer: 36
36-64
Output :
yes

Question: 37
Show output.Int p =10;If (p! = 10) P =0;ElseP= 5;
Answer: 37
37-64
Output: P =5
Question: 38
Find errors;Void main (){Int a ;b;A= 10, b=5If (a= <b)Printf ('A is less than B');Getch ( );}
Answer: 38
38-64
Errors is method for defining the variable is not correct.
Question: 39
Find output of the following code.Int price = 10;If (price! =10)Price =0ElsePrice= 2;Printf ("%d", price);
Answer: 39
39-64
Output: Price = 2
Question: 40
Trace the output.Int a = 5,b = 10;If a > b; printf ("Low Triangle")Else("Huge Triangle");
Answer: 40
40-64
Output: Huge Triangle
Question: 41
Trace the error in the following code.Void main (void);{Int x, y, zIf (x> y);Printf ("X is largest");ElsePrintf("Y is largest")Getch ( );}
Answer: 41
41-64
Erros:1st errors is there must not be ; semicolon after Mian starting.2nd error is ; semicolon is missing in different statement .
Question: 42
Type the error.Void main ( ){Int a, bA = -10B =40If (a <0); b= sqrt (a);Printf ("Result =%f,b);Getch ();}
Answer: 42
42-64
Errors:1st erro is ;semicolon had not been used after various statement to terminates them.2nd error is we cannot take sqrt of a because it is less than 0.
Question: 43
Trace the output.Void main ( ){Int p, q, r;P =10;Q =3;R= 2;If ((p+q)< 14 &&(r < q-3))Printf ("%d",r);ElsePrintf (%d",p);Getch ( ) ;}
Answer: 43
43-64
Output: P =10
Question: 44
Trace the error.Void main ( ){Int a, bA = -10B = 40If (a<0) ; b= sqrt (a);Printf ("Result = %f",b);Getch( ); }
Answer: 44
44-64
Errors:1st errors is ; semicolon had not been used after various statement to terminates them.2nd error is we cannot take sqrt of a because it is less than 0.
Question: 45
What is the output of the following statement , if grade='B'?If (grade = ='A' || grade == 'B' && grade =='C')Printf ("Fail");ElsePrintf ("Pass");
Answer: 45
45-64
Output : Pass
Question: 46
Trace the errors in the following codes.Void main ( )Int x, y =5;If (x > y);Printf ("x is largest");ElsePrintf ("y is largest");Getch( );
Answer: 46
46-64
Erros is there must not be ; semicolon after If condition .
Question: 47
Trace the error in the following code.Void main (void);{Int x, y,zIf (x> y);Printf ("Xis largest");ElsePrintf("Y is largest")Getch( );}
Answer: 47
47-64
Errors:1st error is there must not be ; semicolon after Main starting.2nd error is ;semicolon is missing in different statement.
Question: 48
What is the output of the following statement, if grade='B'?If (grade = ='A' || grade = ='B' && grade = ='C')Printf ("Fail");ElsePrintf ("pass");
Answer: 48
48-64
Output: Pass
Question: 49
Write output.Int p, q, r;P= 10;Q = 2;If (p% q = =3)R= 0;ElseR =1;Printf ("%d",r)
Answer: 49
49-64
Output: R=1
Question: 50
Find output.Int x = 1;Int y = 2;Int z = 3;If((x == y) || (y = =z) || (z == 2)) printf("yes"); else printf ("no");
Answer: 50
50-64
Output : No
Question: 51
Trace the error:Int a = 2If (a=1 printf( "OK);ElsePrintf ("Cancel")
Answer: 51
51-64
Errors is ; semicolon is missing after defining variable and after else statement.
Question: 52
Why break statement is used in switch statement?

Answer: 52
52-64
Break Statement: The statement following the first label with a matching evaluated value are executed until a break statement is encountered .The
Break causes the rest of the switch to be skipped. If all break statements are omitted from the switch statement, the code from the first true case down to the end of the switch statement will execute sequentially.
Question: 53
Write down output of the following code.Void main ( ){int x= 10;If (x! = 10)Printf ("Hello");ElsePrintf ("World");}
Answer: 53
53-64
Output : World
Question: 54
Why a default level is used in switch statement?
Answer: 54
54-64
Default label in Switch Statement :A default label may be used to provide code to be executed if none of the case label is matched.However the place of default label is not fixed. It may be placed before the first case statement or after the last case
Question: 55
Write down output of the following code.Void main ( ){int x= 10;If (x! = 10)Printf ("Hello");ElsePrintf ("World");}
Answer: 55
55-64
Output : World
Question: 56
Write use of if,else if statements.
Answer: 56
56-64
Nested if statement can become quite complex, if there are more than three alternatives and indentation in not consistent, it may be difficult to determineThe logical structure of the if statement. In such situations,if statements with multiple alternatives (if-else-if) can be a good option.The general of if -else statements is as follows:Syntax The general form of if -else -if statement is as follows:If (condition1,) statement,;Else if (condition2) statement2; " " "Else if (conditionn) statementni) Else statementki
Question: 57
Define nested -if statement.
Answer: 57
57-64
Nested if statement means an if statement inside another if statement. Nesting can be done up to any level.The programmer may use as many if statement inside another if statement as (s) he wants. However , the increase in the level of nesting also increas the commplexity of the 'nested if statement. The general form of nested if statement is as follows:If (condition){ if (condition){ block of inner if}}
Question: 58
What is the use of Switch Statement?
Answer: 58
58-64
Rules of Using Switch Case: There are the following rules of using switch case in C program:
  • Case label must be unique.
  • Case labels must end with Colon .
  • Case labels must have constants/ constant expression.
  • Switch case should have at most one default label.
Question: 59
Show output :if(1 = =2)Printf ("Programming")Else if (2 = =1)Printf ("Language");ElsePrintf("Correct ir");
Answer: 59
59-64
Output: Correct it
Question: 60
Trace the errors from the following code segments.Void main ();{int x= 10;Int y = 15;If (x =y)Printf ("x is equal");ElsePrintf ("x is not equal")}
Answer: 60
60-64
Errors:1st error is there must not be ; semicolon after main starting.2nd error is there must be ;semicolon after else statement.
Question: 61
What happens if break is missed in case block?

Answer: 61
61-64
Reasons: If all break statement are omitted from the switch statement, the code from the first true case down to the end of the switch statement will execute sequentially
Question: 62
Write three advantages of switch statement .
Answer: 62
62-64
Advantages: There are the following advantages of the switch statement :
  • A switch statements works much faster than equivalent if- else ladder.
  • It is more readable and in compare to if-else statements .
  • Its is more manageable for having higher level of identification than
Question: 63
Write down the output of following code:
Char ch = 'a':
Switch (ch)
{
Case 'a':
Printf("A");
Case 'b';
printf("B")
Answer: 63
63-64
Output:
A
Question: 64
What is Conditional operator?Write its syntax.
Answer: 64
64-64
Conditional Operator: Conditional Operator is used as an alternative to the if-else statement. It is a ternary operator
(Requires three operand).
Syntax: Its genera form is:
Conditional expression < true-case statement
: false-case statement;
Explanation: The expression may be a relational or logical expression. If the expression is true then the true-case will be executed otherwise the false-case statement is executed.