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 10 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 String in printf function?
Answer: 1
1-95
Control String: The format of each expression may be controlled using a control string that precedes the expression and is separated by a colon(:).These control string use the same structured as the control strings in C printf() routines.
Example: The following specifies that each element of the parallel array .A will be printed to 5 decimal places.
Control strings also may be applied to sequential expressions.
The colons have been used strictly to separate control strings from expressions, so each colon must follow a string and precede an expression.
Question: 2
Find the output of the following code segment.
Int x = 10;
Int y = 5;
Int z = x+y;
Printf ("%d %d %d",x, y,z);
Answer: 2
2-95
Output: x = 10
y = 5
z = 15
Question: 3
Find the error in the following code.
#include (conio,);
#include (stdio.h);
Void main ()
{
printf("OK");
}
Answer: 3
3-95
Errors: Error is brackets do not used in library.
Question: 4
Predict the output of the following code.
{
Printf(."Hello World");
}
Answer: 4
4-95
Output: Hello World
Question: 5
Find the error in the following code.
Main();
{
printf(OK)
}
Answer: 5
5-95
Errors: Error is " " commas are not present with OK in printf statement .
Question: 6
List some important functions for output.
Answer: 6
6-95
Output Function in C-language:
  • Putchar()
  • Putch()
  • Puts()
  • printf()
Question: 7
Find the errors from the following code.
#include <stdio.h>
#incluse<conio.h>
{
Void main();
printf (" Assembly Language");
}
Answer: 7
7-95
Errors: Errors is bracket is not correctly used in Main body.
Question: 8
Write the syntax of printf() statement.
Answer: 8
8-95
Printf(format string,&var,& var2,& var3,.......);
printf (format string);
Question: 9
What is the use of printf() function?
Answer: 9
9-95
Use of printf() Function:To see results of program execution, we must have a way to specify what variables values should be displayed . The standard library function printf (pronounced as print -eff) has been used for formatted output . It takes as arguments a format string and an optional list of variable to output.
Question: 10
Trace the errors in the following code.
#include <std.n>
Void main (void)
{
Printf ('Pakistan");
}
Answer: 10
10-95
Errors: Erros is wrong library has been used.
Question: 11
Trace the Errors .
Int b =8;
Int c =0
C =number
Print f ("%f",x)
Answer: 11
11-95
Errors: Errors is x variable is not present which is written in printf statement
Question: 12
What is the output of the following code?
Answer: 12
12-95
Printf ("I\Love\n programming");
Output: I
Love
programming


Question: 13
Find Errors.
Main [ ];
(Float n;
Print f ('%dn);
}
Answer: 13
13-95
Errors:
  • 1st error is wrong brackets have been used with Main word
  • 2nd error is wrong brackets have been used with Main's body
  • 3rd error is variable n is not defines but it has been used in printf statement.
Question: 14
Find the output.
#include <stdio.h>
Void main()
{
Int x, y;
X=10; y=20;
Printf(%d%d,x,y);
}
Answer: 14
14-95
Output:
X=10
Y=20
Question: 15
Give single print statement to print the following message 'I Love Pakistan".
Answer: 15
15-95
Single Print Statement:
printf("I\N Love \n Pakistan");
Question: 16
Find the error in the following code .
Void main ();
{
int num =10;
printf("%d,a);
}
Answer: 16
16-95
Errors:
  • Errors is Capital A is defined in int A= 10 statement but in printf statement small 'a' has been used
Question: 17
Write the Output of the following code :
Main()
{
printf("444\n");
printf("44");
}
Answer: 17
17-95
444
44
Question: 18
Find Error.
{
Float area ,r;
Printf ("Enter radius");
}
Answer: 18
18-95
Errors:
  • 1st error is no library has been used in program.
  • 2nd error is Mian body is not defined.
Question: 19
Trace the error.
#include <stdio.h>
Void main (void)
Printf("Hello World");
Answer: 19
19-95
Errors: Errors is bracket have not been used in Main body.
Question: 20
Trace the errors.
#include<stdio.h>
Void main()
{
printf ("High Level Language")
}


Answer: 20
20-95
Errors:
  • Errors is terminator sign has not been used in printf statement.
Main()
{
printf("555\n");
printf ("55");
}
Question: 21
Show Output.
Inti =515
Printf (" =%5d",i);
Printf (" =%2d",i);
Answer: 21
21-95
Output: I =515
I =51
Question: 22
Give single print statement to print the following message.
No.of employees
No.of officers
Answer: 22
22-95
Single Print Statement:
printf("No.\n of \n employee");
printf(No.\n of \ n officers" );
Question: 23
Find Errors in the following code.
Void main ( )
{
int num =10,
num + =5;
printf("\n %d" ,num);
}
Answer: 23
23-95
Errors:
  • Errors is ; terminator has not been used in statement where variable num is defined.
Question: 24
Find the Output of the following code.
#include <stdio.h>
Void main ()
{
int x =10, y= 20, z = 30;
x= x+y;
y =y+z;
z= x-y;
printf("result =%d%d%d",x,y,z);


Answer: 24
24-95
Output :
Result = 30 50 -20
Question: 25
Trace the error in the following code.
#include(stdio.h);
Void main()
{

Printf ("OK");
}
Answer: 25
25-95
Errors:
  • 1st error is brackets have been used in library which is not allowed.
  • 2nd error is both commas are not written in printf statement.
Question: 26
Trace the output.
Float f = 3.14159;
Printf ("f = %4.2f",f);
Answer: 26
26-95
Output: f=3.14
Question: 27
Trace the error in the following C code.
#include <stdio.h>
Void main()
{
prin ("C Language is interesting");
Answer: 27
27-95
Error:
  • Error is printf statement in not complete.
Question: 28
Trace the error in th following code.
#include (std10.h)
Void main (void);
{
x = 5;
y = 6;
z = x+y;
printf ("%d",z);
}
Answer: 28
28-95
Errors: Errors is wrong library has been used in program.
Question: 29
Trace the error.
#include <stdio.h>
Main()
{
printf("Hello world")
}
Answer: 29
29-95
Errors:
  • Errors is ; semicolon is not written in printf statement.
Question: 30
Trace Error.
Include<STDIO.H>
VOID Main ();
{
printf ("Pakistan")
}
Answer: 30
30-95
Error:
  • 1st error is library is written in capital letter which is not allowed.
  • 2nd error is word void is written in capital letter which is not allowed
Question: 31
What is format specifier ?
Answer: 31
31-95
Format Specifier: Format specifier specify the information in which the value of the variable should be displayed on the screen . Format specifiers are specified in the format string.
Example: The following will show about format specifiers.
#include <stdio.h>
Void main (void)
{
Float var1, var2, res;
Var1 =24.27
var2 =41.50;
res var1 + var2;
Printf ("%f+%f =%f" ,var1, var2, res);
}
Here is the output of the program
24027+41.5 =65.77
Question: 32
Find the error in the following code.
Main();
{
printf("Hellow);
}
Answer: 32
32-95
Error: Error is both commas is not written in printf statement.
Question: 33
Find the error in the following code.
Main();
{
printf("Hellow);
}
Answer: 33
33-95
Error: Error is both commas is not written in printf statement.
Question: 34
Trace output :
Int a =512;
Printf ("a+= %5d",a);
Printf ("a =%1d",a);
Answer: 34
34-95
Output:
a= 512
a=512
Question: 35
What is the use of field width specifier?
Answer: 35
35-95
Field Width Specifier: In a C program, the number of columns used to display a value on the screen is referred to a field width.
Field width: Field-width specifiers describe the number of columns that should be used to print a value.
Question: 36
Trace the output.
Int I = 10
Printf ("%3d",i);
Answer: 36
36-95
Output: i=10
Question: 37
Trace the output :
Void main () {
CharW1,W2,W3;
W1 ='A'
W2 ='B'
W3 ='C';
Printf ("%c%cW3",W1,W2,);
Getch();
}

Answer: 37
37-95
Output:W3=Cw1 =Aw2 =B

Question: 38
Trace the error in the following code.
#include <stdio.h>
Void main (void)
{ int x= 4
Y =x+10
printf("%d",x+y);
}
Answer: 38
38-95
Errors:
  • 1st errors is terminator is not present in two statements.
  • 2nd error is variable y is not declared properly.
Question: 39
Trace the error in the following code.
#include<stdio.h>
#include<conio.h>
Void main <>
{
float area, r = 2.5;
area = 3.14x are * r;
printf ("Area =%f", area);
getch();
}
Answer: 39
39-95
Erros: Errors is brackets have not been used with Main which are necessary.
Question: 40
What will be the output of the following?
Float t = 3.8961
Printf ("value of t = % 6.2 f" ,t );
Answer: 40
40-95
Output:
t= 3.89
Question: 41
Trace the output.
Void main() {
Int a, b, temp;
a =10;
b =10;
temp =b;
b = a
a = temp;
Printf ("%d\n",a);
Printf ("%d\n",b);
Getch ( ) ;}
Answer: 41
41-95
Output: a = 20
b = 10
Question: 42
Write the output in the following code.
Int n =-25.41;
Printf ("%6.2f", n);
Answer: 42
42-95
Output: n= - 25.41
Question: 43
Trace the output of the following code.
{
Int x, y, z;
X = 3;
Y = 2;
z = 4;
Printf(%ds%d%d,x+y, y+5, x+z);
Getche();
}
Answer: 43
43-95
Output: 5,7,7
Question: 44
Trace the output.
#include <stdio.h>
Void main (void){
Int x = 10;
Print f (" %d",x %2);
Answer: 44
44-95
Output:
x = 5
Question: 45
Write the output of the following code.
Int x= 9;
X = x%3;
Printf("\n%d is result",x);
Answer: 45
45-95
Output: x = 3
Question: 46
Find out the output of the following code.
Int a, b, c;
a =b =c = 6;
a= b;
b= a;
C=2;
Printf("%d%d%d",a,b,c);
Answer: 46
46-95
Output:
6,6,6
Question: 47
Trace the output .
Int I = 20;
Printf ("%6d",i);
Answer: 47
47-95
Output;
i = 20
Question: 48
Trace the output.
#include <stdio.h>
Void main (void)
{
int x = 1;
int y = 2;
x =x + 1;
y =y+ x ;
printf( "%d\n %d", x, y);
}
Answer: 48
48-95
Output:
x = 2
y = 4
Question: 49
Find the output of the following code.
Int a = 10, b =12;
Int sum =a+b;
Printf("%d",sum);
Answer: 49
49-95
Output:
Sum = 22
Question: 50
Find the errors in the following piece of code.
#include (stdio.h)
Void Main ()
int a =10;
Printf("%f",a);
Answer: 50
50-95
Errors:
  • 1st errors is Void Main must be written in small letters.
  • 2nd error is in printf statement starting of Printf must be with small letter.
Question: 51
Trace the errors from the following piece of code.
Include <stdio.h>
Void main [ ]
{printf ('Pakistan');
}
Answer: 51
51-95
Errors:
  • 1st error is # sign is not present with include.
  • 2nd error is ( ) small brackets must be used with Main body.
Question: 52
Predict the output of the following code.
Int number = 2;
Number ++;
Printf ("%d",number);
Answer: 52
52-95
Output:
Number = 3
Question: 53
What will be the output of the following?
Float f = 3.24;
Printf( "value =%f",f);
Answer: 53
53-95
Output:
f =3.24
Question: 54
Predict the output of the following code.
Int number =6;
Nymber ++;
Printf("%d\n", number);
Answer: 54
54-95
Output:
Number = 7
Question: 55
Trace Output:
Void main( )
{
int a, b;
a = 10;
b = 12;
int c= a+b;
printf ("c = %3d",--c);
}
Answer: 55
55-95
Output:
c= 2221
Question: 56
Trace the error of the given code.
Include<stdio.h>
Main()
{int i = 10;
Printf("%d",i) ;}
Answer: 56
56-95
Errors:
  • Errors is # sign is not present with include.
Question: 57
Determine the output of the given segment.
inti=212;
Printf ("i = %5d" ,i);
Printf ("i =%3d" ,i);
Answer: 57
57-95
Output:
i 212
i=212
Question: 58
Write the output of the following code.
Int x =3;
Printf("%d",x);
Printf("%d",x++);
Printf("%d",++x);
Answer: 58
58-95
Output:
x = 3
x = 3
x = 4
Question: 59
Trace out the errors in the following code.
Int a,
Prin ("%d",a);
Answer: 59
59-95
Errors:
  • 1st error is variable a must be declared with data type char.
  • 2nd error is spelling of printf in print statement is wrong.
Question: 60
Trace the errors in the following programs.
Include<stdio.h>
Mian()
{
int a = 10;
printf("%d",a);
}
Answer: 60
60-95
Errors:
  • 1st errors is # sign is not present with include.
  • 2nd error is capital S cannot be used is stdio.h library.
Question: 61
Predict the output of the following.
Float f = 3.14159
Print f (" f = %4.2f" , f);
Answer: 61
61-95
Output:
f =3.14
Question: 62
Trace the output of the following.
X = 5;
Y =x++;
Printf ("d%d",x,y);

Answer: 62
62-95
Output:
x = 5
y = 5
Question: 63
Trace the error.
Int p,q, r;
P = 50000,10
Printf("%d",p);
Answer: 63
63-95
Errors:
  • 1st error is we cannot set two values together to a variable.
  • 2nd error is ;terminator sign has not been used in statement where variable P is declared.
Question: 64
Trace the output.
Void main () {
Int a, b, n;
N =400;
A = n % 100;
B = n/ 10;
N = n % 10;
Printf ("%d\n",a);
Printf (%d\n"b);
Printf (%d\n"n);
Getch( );}
Answer: 64
64-95
Output:
a = 4
b = 40
n =40
Question: 65
Define Escape sequence.
Answer: 65
65-95
Escape sequences are characters which are specified in the format string of the printf statement in combination with backslash (\). These cause an escape from the normal interpretation of a string so that the next character is recognized as having special meaning.
Question: 66
Trace the errors from the following.
Void main ( );
{ float I = 15.6;
printf (" %d",i);
}
Answer: 66
66-95
Errors:
  • Errors is terminator sign has not been used with Main starting.
Question: 67
Write down output of the following piece of code.
Printf( "*\n**\n***);
Answer: 67
67-95
Output:
*
**
***
Question: 68
Find the error:
Void main ( )
{
int a =10;
printf ("%s",b);
}
Answer: 68
68-95
Error:
  • Error is variable b is not defined which is present in printf statement.
Question: 69
Write down output of the following.
Float f = 3.14159;
Printf ("f %4.f",f);
Answer: 69
69-95
Output:
F = 3.14
Question: 70
Predict the output of the following code.
Void main ( )
{
Char ch1 = ‘A’, ch2 =’B’, ch3 = ‘C’;

Printf (“ch2 \n %c\n ch1”,ch3);

Getch ( );

}

Answer: 70
70-95
Output: Ch2 = B

Ch1 = A

Ch3 = C

Question: 71
Find the output of the following code.
Printf("Book\ t reading\n");
Printf("is a \t very good \n habit");
Answer: 71
71-95
Output:
Book reading
is a very good
habit
Question: 72
What will be the output from the following code?
Void main ( );
{ int a,b, temp;
a = 10;
b = 20;
temp = a;
a = b;
b = temp;
printf ("a =%d\t b = %d" , a, b);
}
Answer: 72
72-95
Output :
A = 20
B = 10
Question: 73
Trace the output.
Void main ( ){
Int x,y, z;
X = 10;
Y = 20;
Z = 30;
X = x+ y;
Y = y+ z;
Z = x- y;
Printf("result = %d%d%d\n",x,y,z);
getch();}
Answer: 73
73-95
Output
Result = 30, 50 10
Question: 74
Predict the output of the following code.
Printf ("*\n**\n***\n****\n");
Answer: 74
74-95
Output:
**
***
****
Question: 75
Find the output of the following code.
Printf( "Programming\t is \n very \t interesting");
Answer: 75
75-95
Output:
Programming is
very interesting
Question: 76
List some input functions in C-Language.
Answer: 76
76-95
Input functions in C-Language:

  • Getchar ( )
  • Getch ( )
  • Gets ( )
  • Scanf ( )
Question: 77
Find the output of the following code .
Printf ("Pakistan\n is an \n Islamic \ n country");

Answer: 77
77-95
Output:
Pakistan
is
an
Islamic
Country
Question: 78
Trace the output .
Int n =6;
N+ +;
Printf ("%d",n);
Answer: 78
78-95
Output :
n = 7
Question: 79
Define Standard input.
Answer: 79
79-95
Standard Input: Standard input is a steam sata (often text)
Going into a program.The program request data transfers by use of the read operation. Not all programs require stream input.
Example: the dir and Is programs (which displays files names contained in a directory) may take command-line arguments, but perform their operations without stream data input.
Question: 80
Trace the output of the following code.
Int i = - 786;
Printf( "%6d",i);
Answer: 80
80-95
Output:
i = -786
Question: 81
What is the use of "scan f" function?Also write its syntax.
Answer: 81
81-95
Scan f Function: In C, the standard input library provides function to perform input and output operations. This input operations are performed by scanf ( ) function. The scanf (pronounced as scan -eff) function is versatile as it is equally good for numeric as well as string input .
Syntax : Here is the syntax of scanf function.
Scanf(format string, &var1,&var2, &var3,....);
Question: 82
Trace the error.
Int x = 5;
Int y
Y = x+3
Printf("%d" ,,y );
Answer: 82
82-95
Error:
  • Error is terminator sign id not present in statements in which variable y is defined and declared.
Question: 83
Why the ampersand (& )used in scanf is function?

Answer: 83
83-95
Ampersand (& )in scanf function: The ampersand is the address-off operators, In C, if we want to pass parameters by reference the address of (&) operators should be used. The scanf () function reads formatted input and has to put this input into something like a variable .
Question: 84
Trace the output of the following code .
Void main ( )
{
printf ("22\t");
printf ("666");
}
Answer: 84
84-95
Output:
22,666
Question: 85
Trace the error in the following code.
Float area , r
Printf (" Enter Radius")
scanf(%f"r);
Answer: 85
85-95
Errors:
  • 1st error no Main body is present
  • 2nd error is : terminator sign is not present in statement where variable is defined.

Question: 86
Trace the error in the following code.
#include<stdio.h>
Void main( )
{
Inti;
Scanf ("%d",i);
Printf( "%d,i) ;
}
Answer: 86
86-95
Errors:
  • 1st errors is spelling of word main is incorrect.
  • 2nd error is in printf statement closing comma is not present.
Question: 87
Describe getch ( ) function.?
Answer: 87
87-95
getch ( ) function: The getch ( ) function is very handy in character manipulation. The getch ( ) function does not accept echo the character typed. This function does not accept any argument.However it returned the typed character to the calling function.
Question: 88
Find the error in the code .
#include <STDIO>H>
VOID MAIN( ){
Int a;
A = 20
Printf ("%f",a);
Getch( );}
Answer: 88
88-95
Error:
  • Error is wrong library has been used in this program.
Question: 89
Explain getch ( ) function .

Answer: 89
89-95
The getch ( ) function is very handy in character manipulation . This function does not accept any argument ,However it returned the typed character to the calling function.
Question: 90
Write the output of the following code.
Int x, y,z, r;
Printf("Enter three numbers;");
Scanf("%d%d%d", &x,&y, &z);
r =x + y *z ;
Printf( "Enter three numbers :");
Scanf ("%d%d%d", &x,&y,&z);
r = x+y* z;
Printf ("%d",r);

Answer: 90
90-95
Output :
Enter three number 235
r = 17
Question: 91
Compare getch and getche functions
Answer: 91
91-95
Getch ( ) function:

  • Getch function is very handy is character manipulation.
  • It does not eco the character typed.
  • It does not accept any arguments.
Question: 92
Trace out errors in the following code.
Float r;
Clscr ();
Printf ("enter radius);
Scanf ("%f; r);
Answer: 92
92-95
Errors:
  • Erros is no main body is present.
Question: 93
Find the errors in the following code.
#include <stdio.h>
Void main ()
{
Float area ;r ;
Scanf ("%c"&r);
Area = 3.14*r*r;
Printf ("area = %f"area);
}
Answer: 93
93-95
Error:
  • Error is the value of variable are is not declared.
Question: 94
What is the output of the following ?#include <stdio.h>#include <conio.h>Void main ( ){Inti =5;Printf(%d%d%d",i.i++,++i);getch();}
Answer: 94
94-95
Output: 5,5,6
Question: 95
Write the output of the following code.
#include <stdio.h>
#include <conio.h>
Void main ( )
{
int x, y,z,;
Printf ("Enter three numbers;")
Scanf ("%d %d %d" ,&x, &y, &z;
Y = x+z;
X =z+ 1;
Scanf("%d %d %d , x, y, z);
Y =x +z;
X =z +1 ;
Scanf ("%d %d %d",x, y,z);
Getch ( );
}
Answer: 95
95-95
Output:
Enter three numbers 2 3 5
x = 6
y = 7
z = 5