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
Find error from the following .
Int y;z;
If(y = = z)
Printf ("yes)"
Answer: 2
2-64
Error :
  • 1st error is method to declare variable is wrong
  • 2nd error is terminator has not been used in printf statement
Question: 3
Find out errors:
#include <stdio>
Void main( )
[
If (50>20) then
Printf ("Islamic Country ");
Getch( )
}
Answer: 3
3-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: 4
Describe sequence structure.
Answer: 4
4-64
Sequence Structure: In case of sequence structure , instruction are executed in the same order in which they are specified in the program.
Question: 5
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: 5
5-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: 6
Define Selection Structure.
Answer: 6
6-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: 7
Find Errors.
#include (Stdio.n);
#include <conio.c>
Void main ()
{
If (16>10) then printf ("%C","Pakistan");
Getch( );

Answer: 7
7-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: 8
Trace the output.
Void main( )
{int marks;
Printf ("\n enter your marks ");
Scanf ("%d",&marks);
If (marks >= 40)
Printf ("\n congratulation");
}
Answer: 8
8-64
Output :
Enter your marks 50
Congratulation
Question: 9
Find Error.
Int price= 10
If (price! =10)
price=0
Answer: 9
9-64
  • Error is terminator is necessary for terminate the statement but has not been used in this program.
Question: 10
List types of control structure.
Answer: 10
10-64
Types of Control Structures: There are the following types of control structure:
  • Sequence
  • Selection
  • Repetition.
Question: 11
Find error in the following segment .
Float y 3.14;
If (y == 3)
Printf ("Errors");
Answer: 11
11-64
Errors: is equal sign has not been used in statement where variable y is being declared.
Question: 12
Trace the error.
Int a ; b= 5
If (a<b)
Printf ("\nA is less than b");

Answer: 12
12-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: 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 Error :
Void main ( )
{
Int a =2 ;
If (a ==1)
Printf ("ok);
Else
Printf ( "cancel");
Getch( );
Answer: 14
14-64
Error:
  • Error is there must be brackets for If statements body.
Question: 15
What is the error in the following codes?
Int x= 10, y=20;
IF (X >10&Y<30)
PRINTF ("%D",X+Y);

Answer: 15
15-64
ERROR:
  • Error is data type integer must be starting with small i.
Question: 16
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: 16
16-64
Output:
a = 6
Question: 17
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: 17
17-64
Output:
Pass
Question: 18
Find output from the following .
Int pirce = 19;
If (price! =10)
Printf ("price");
Answer: 18
18-64
Output: Price = 19
Question: 19
Write the syntax of "if -else "statement.
Answer: 19
19-64
Syntax :
If (condition)
{ block of if (true case )
}

Else
{ block of else (false true ) }
Question: 20
Find output of the following code .
Int a = 1,b =6;
If (a +b <7);
{
Printf ("%d",a);
}
Else
{
Printf {"%d",b);
}
Answer: 20
20-64
Output;
B= 6
Question: 21
Write the syntax of if-else statement .
Answer: 21
21-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: 22
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: 22
22-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: 23
Trace error from the following code.
If (7! =10
Printf ("hello");
Else-do
Printf ("welcom");
Answer: 23
23-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: 24
Track the errors .
Int p= 20;
If( price == 20 )
Price = 0;
Else
Price =2,
Answer: 24
24-64
Errors:
  • Errors is ; semicolon has not been used after condition of else statement.
Question: 25
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: 25
25-64
Output:
Programming makes the life interesting.
Question: 26
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: 26
26-64
Output: Yes
Question: 27
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: 27
27-64
Output :
C = 0
Question: 28
Trace the erroe in the following code.
Void main ( )
{
Int x = 0
If (x = 1 )
Printf ("hello");
Else
Printf ("bye")
}
Answer: 28
28-64
Error is ;semicolon has not been used after the condition of else statement

Question: 29
Find errors.Void main ( ){Int a =2If (a= 1)Print f ("OK");ElsePrintf ("Cancel");Getch ()}
Answer: 29
29-64
Erros is ; semicolon must be used after defining the variable a.
Question: 30
Trace the error in the following code.#include <stdio.h>Void main( );{If (16<18) thenPrintf ("%c",ok);Getch ( );}
Answer: 30
30-64
Errors is there is if then statement in C language.
Question: 31
Trace the error in the following code.Void main (void){Int x= 10;If (x! =10);X + +;Else (x= =10)X - -;}
Answer: 31
31-64
Errors is ; semicolon must not be used after If condition.
Question: 32
Determine the output of the following code.
Inta a, b;
B= 20; a=10;
If (b< =a)
Printf ("No")
Else
Printf ("yes")
Answer: 32
32-64
Output :
yes

Question: 33
Find output.
Int p= 3, q = 5;
If ((p>q)|| (q! =s))
P = p+1;
Else
P = p*2;
Printf ("p =%d",p);
Answer: 33
33-64
Output:
P =6
Question: 34
Trace the output.
If (1==2)
Printf ("hello");
Elde
Printf( "hello");
Else
Printf ("correct it");
Answer: 34
34-64
Output ; Correct it
Question: 35
What is the output of the following code?Int m, n;M = 0;N= m;If;(m = =n)Printf ("BWP");Elseprintf("LHR");
Answer: 35
35-64
Output: BWP
Question: 36
Show output.Int p =10;If (p! = 10) P =0;ElseP= 5;
Answer: 36
36-64
Output: P =5
Question: 37
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: 37
37-64
Errors:1st error is there must not be ; semicolon after Main starting.2nd error is ;semicolon is missing in different statement.
Question: 38
Trace the error from the following code.Void main ( ){Int a =2;If (a =1);Printf ("ok");ElsePrintf ("No");}
Answer: 38
38-64
Errors is ; semicolon must not be used after If condition.
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
Trace 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 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: 43
What is the output of the following statement , if grade='B'?If (grade = ='A' || grade == 'B' && grade =='C')Printf ("Fail");ElsePrintf ("Pass");
Answer: 43
43-64
Output : Pass
Question: 44
What is the output of the following statement, if grade='B'?If (grade = ='A' || grade = ='B' && grade = ='C')Printf ("Fail");ElsePrintf ("pass");
Answer: 44
44-64
Output: Pass
Question: 45
Find errors;Void main (){Int a ;b;A= 10, b=5If (a= <b)Printf ('A is less than B');Getch ( );}
Answer: 45
45-64
Errors is method for defining the variable is not correct.
Question: 46
Type the error.Void main ( ){Int a, bA = -10B =40If (a <0); b= sqrt (a);Printf ("Result =%f,b);Getch ();}
Answer: 46
46-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: 47
Write output.Int p, q, r;P= 10;Q = 2;If (p% q = =3)R= 0;ElseR =1;Printf ("%d",r)
Answer: 47
47-64
Output: R=1
Question: 48
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: 48
48-64
Output: P =10
Question: 49
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: 49
49-64
Erros is there must not be ; semicolon after If condition .
Question: 50
Trace the error:Int a = 2If (a=1 printf( "OK);ElsePrintf ("Cancel")
Answer: 50
50-64
Errors is ; semicolon is missing after defining variable and after else statement.
Question: 51
Show output :if(1 = =2)Printf ("Programming")Else if (2 = =1)Printf ("Language");ElsePrintf("Correct ir");
Answer: 51
51-64
Output: Correct it
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 use of if,else if statements.
Answer: 53
53-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: 54
Define nested -if statement.
Answer: 54
54-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: 55
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: 55
55-64
Errors:1st error is there must not be ; semicolon after main starting.2nd error is there must be ;semicolon after else statement.
Question: 56
What happens if break is missed in case block?

Answer: 56
56-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: 57
Find output.Int x = 1;Int y = 2;Int z = 3;If((x == y) || (y = =z) || (z == 2)) printf("yes"); else printf ("no");
Answer: 57
57-64
Output : No
Question: 58
Write down output of the following code.Void main ( ){int x= 10;If (x! = 10)Printf ("Hello");ElsePrintf ("World");}
Answer: 58
58-64
Output : World
Question: 59
What is the use of Switch Statement?
Answer: 59
59-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: 60
Why a default level is used in switch statement?
Answer: 60
60-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: 61
Write down the output of following code:
Char ch = 'a':
Switch (ch)
{
Case 'a':
Printf("A");
Case 'b';
printf("B")
Answer: 61
61-64
Output:
A
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 output of the following code.Void main ( ){int x= 10;If (x! = 10)Printf ("Hello");ElsePrintf ("World");}
Answer: 63
63-64
Output : World
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.