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
0
Our database contains a total of 0 questions for computer science Short Questions. You’ll prepare using this huge databank.
Question: 1
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: 1
1-95Output: x = 10
y = 5
z = 15
Question: 2
List some important functions for output.
Answer: 2
2-95Output Function in C-language:
- Putchar()
- Putch()
- Puts()
- printf()
Question: 3
Find the error in the following code.
#include (conio,);
#include (stdio.h);
Void main ()
{
printf("OK");
}
Answer: 3
3-95Errors: Error is brackets do not used in library.
Question: 4
Write the syntax of printf() statement.
Answer: 4
4-95Printf(format string,&var,& var2,& var3,.......);
printf (format string);
Question: 5
Trace the Errors .
Int b =8;
Int c =0
C =number
Print f ("%f",x)
Answer: 5
5-95Errors: Errors is x variable is not present which is written in printf statement
Question: 6
What is the output of the following code?
Answer: 6
6-95Printf ("I\Love\n programming");
Output: I
Love
programming
Question: 7
What is the use of printf() function?
Answer: 7
7-95Use 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: 8
Find the errors from the following code.
#include <stdio.h>
#incluse<conio.h>
{
Void main();
printf (" Assembly Language");
}
Answer: 8
8-95Errors: Errors is bracket is not correctly used in Main body.
Question: 9
Trace the errors in the following code.
#include <std.n>
Void main (void)
{
Printf ('Pakistan");
}
Answer: 9
9-95Errors: Erros is wrong library has been used.
Question: 10
Predict the output of the following code.
{
Printf(."Hello World");
}
Answer: 10
10-95Output: Hello World
Question: 11
Find the error in the following code.
Main();
{
printf(OK)
}
Answer: 11
11-95Errors: Error is " " commas are not present with OK in printf statement .
Question: 12
What is Control String in printf function?
Answer: 12
12-95Control 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: 13
Find the output.
#include <stdio.h>
Void main()
{
Int x, y;
X=10; y=20;
Printf(%d%d,x,y);
}
Answer: 13
13-95Output:
X=10
Y=20
Question: 14
Find Error.
{
Float area ,r;
Printf ("Enter radius");
}
Answer: 14
14-95Errors:
- 1st error is no library has been used in program.
- 2nd error is Mian body is not defined.
Question: 15
Give single print statement to print the following message 'I Love Pakistan".
Answer: 15
15-95Single Print Statement:
printf("I\N Love \n Pakistan");
Question: 16
Trace the errors.
#include<stdio.h>
Void main()
{
printf ("High Level Language")
}
Answer: 16
16-95Errors:
- Errors is terminator sign has not been used in printf statement.
{
printf("555\n");
printf ("55");
}
Question: 17
Find Errors in the following code.
Void main ( )
{
int num =10,
num + =5;
printf("\n %d" ,num);
}
Answer: 17
17-95Errors:
- Errors is ; terminator has not been used in statement where variable num is defined.
Question: 18
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: 18
18-95Output :
Result = 30 50 -20
Question: 19
Show Output.
Inti =515
Printf (" =%5d",i);
Printf (" =%2d",i);
Answer: 19
19-95Output: I =515
I =51
Question: 20
Trace the error.
#include <stdio.h>
Void main (void)
Printf("Hello World");
Answer: 20
20-95Errors: Errors is bracket have not been used in Main body.
Question: 21
Give single print statement to print the following message.
No.of employees
No.of officers
Answer: 21
21-95Single Print Statement:
printf("No.\n of \n employee");
printf(No.\n of \ n officers" );
Question: 22
Find the error in the following code .
Void main ();
{
int num =10;
printf("%d,a);
}
Answer: 22
22-95Errors:
- Errors is Capital A is defined in int A= 10 statement but in printf statement small 'a' has been used
Question: 23
Write the Output of the following code :
Main()
{
printf("444\n");
printf("44");
}
Answer: 23
23-95 444
44
Question: 24
Find Errors.
Main [ ];
(Float n;
Print f ('%dn);
}
Answer: 24
24-95Errors:
- 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: 25
Trace the output.
Float f = 3.14159;
Printf ("f = %4.2f",f);
Answer: 25
25-95Output: f=3.14
Question: 26
Trace Error.
Include<STDIO.H>
VOID Main ();
{
printf ("Pakistan")
}
Answer: 26
26-95Error:
- 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: 27
Find the error in the following code.
Main();
{
printf("Hellow);
}
Answer: 27
27-95Error: Error is both commas is not written in printf statement.
Question: 28
Trace the error in the following C code.
#include <stdio.h>
Void main()
{
prin ("C Language is interesting");
Answer: 28
28-95Error:
- Error is printf statement in not complete.
Question: 29
What is the use of field width specifier?
Answer: 29
29-95Field 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: 30
Trace the output.
Int I = 10
Printf ("%3d",i);
Answer: 30
30-95Output: i=10
Question: 31
Find the error in the following code.
Main();
{
printf("Hellow);
}
Answer: 31
31-95Error: Error is both commas is not written in printf statement.
Question: 32
What is format specifier ?
Answer: 32
32-95Format 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: 33
Trace output :
Int a =512;
Printf ("a+= %5d",a);
Printf ("a =%1d",a);
Answer: 33
33-95Output:
a= 512
a=512
Question: 34
Trace the error in th following code.
#include (std10.h)
Void main (void);
{
x = 5;
y = 6;
z = x+y;
printf ("%d",z);
}
Answer: 34
34-95Errors: Errors is wrong library has been used in program.
Question: 35
Trace the error.
#include <stdio.h>
Main()
{
printf("Hello world")
}
Answer: 35
35-95Errors:
- Errors is ; semicolon is not written in printf statement.
Question: 36
Trace the error in the following code.
#include(stdio.h);
Void main()
{
Printf ("OK");
}
Answer: 36
36-95Errors:
- 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: 37
Trace the error in the following code.
#include <stdio.h>
Void main (void)
{ int x= 4
Y =x+10
printf("%d",x+y);
}
Answer: 37
37-95Errors:
- 1st errors is terminator is not present in two statements.
- 2nd error is variable y is not declared properly.
Question: 38
Write the output in the following code.
Int n =-25.41;
Printf ("%6.2f", n);
Answer: 38
38-95Output: n= - 25.41
Question: 39
Trace the output.
#include <stdio.h>
Void main (void){
Int x = 10;
Print f (" %d",x %2);
Answer: 39
39-95Output:
x = 5
Question: 40
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: 40
40-95Erros: Errors is brackets have not been used with Main which are necessary.
Question: 41
Trace the output .
Int I = 20;
Printf ("%6d",i);
Answer: 41
41-95Output;
i = 20
Question: 42
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: 42
42-95Output:
x = 2
y = 4
Question: 43
Write the output of the following code.
Int x= 9;
X = x%3;
Printf("\n%d is result",x);
Answer: 43
43-95Output: x = 3
Question: 44
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: 44
44-95Output: 5,7,7
Question: 45
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: 45
45-95Output:
6,6,6
Question: 46
What will be the output of the following?
Float t = 3.8961
Printf ("value of t = % 6.2 f" ,t );
Answer: 46
46-95Output:
t= 3.89
Question: 47
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: 47
47-95Output: a = 20
b = 10
Question: 48
Trace the output :
Void main () {
CharW1,W2,W3;
W1 ='A'
W2 ='B'
W3 ='C';
Printf ("%c%cW3",W1,W2,);
Getch();
}
Answer: 48
48-95Output:W3=Cw1 =Aw2 =B
Question: 49
Find the errors in the following piece of code.
#include (stdio.h)
Void Main ()
int a =10;
Printf("%f",a);
Answer: 49
49-95Errors:
- 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: 50
Predict the output of the following code.
Int number =6;
Nymber ++;
Printf("%d\n", number);
Answer: 50
50-95Output:
Number = 7
Question: 51
Trace the error of the given code.
Include<stdio.h>
Main()
{int i = 10;
Printf("%d",i) ;}
Answer: 51
51-95Errors:
- Errors is # sign is not present with include.
Question: 52
Trace the errors from the following piece of code.
Include <stdio.h>
Void main [ ]
{printf ('Pakistan');
}
Answer: 52
52-95Errors:
- 1st error is # sign is not present with include.
- 2nd error is ( ) small brackets must be used with Main body.
Question: 53
Trace out the errors in the following code.
Int a,
Prin ("%d",a);
Answer: 53
53-95Errors:
- 1st error is variable a must be declared with data type char.
- 2nd error is spelling of printf in print statement is wrong.
Question: 54
Trace the errors in the following programs.
Include<stdio.h>
Mian()
{
int a = 10;
printf("%d",a);
}
Answer: 54
54-95Errors:
- 1st errors is # sign is not present with include.
- 2nd error is capital S cannot be used is stdio.h library.
Question: 55
Determine the output of the given segment.
inti=212;
Printf ("i = %5d" ,i);
Printf ("i =%3d" ,i);
Answer: 55
55-95Output:
i 212
i=212
Question: 56
Trace Output:
Void main( )
{
int a, b;
a = 10;
b = 12;
int c= a+b;
printf ("c = %3d",--c);
}
Answer: 56
56-95Output:
c= 2221
Question: 57
Write the output of the following code.
Int x =3;
Printf("%d",x);
Printf("%d",x++);
Printf("%d",++x);
Answer: 57
57-95Output:
x = 3
x = 3
x = 4
Question: 58
Predict the output of the following code.
Int number = 2;
Number ++;
Printf ("%d",number);
Answer: 58
58-95Output:
Number = 3
Question: 59
What will be the output of the following?
Float f = 3.24;
Printf( "value =%f",f);
Answer: 59
59-95Output:
f =3.24
Question: 60
Find the output of the following code.
Int a = 10, b =12;
Int sum =a+b;
Printf("%d",sum);
Answer: 60
60-95Output:
Sum = 22
Question: 61
Trace the output of the following.
X = 5;
Y =x++;
Printf ("d%d",x,y);
Answer: 61
61-95Output:
x = 5
y = 5
Question: 62
Trace the errors from the following.
Void main ( );
{ float I = 15.6;
printf (" %d",i);
}
Answer: 62
62-95Errors:
- Errors is terminator sign has not been used with Main starting.
Question: 63
Find the error:
Void main ( )
{
int a =10;
printf ("%s",b);
}
Answer: 63
63-95Error:
- Error is variable b is not defined which is present in printf statement.
Question: 64
Trace the error.
Int p,q, r;
P = 50000,10
Printf("%d",p);
Answer: 64
64-95Errors:
- 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: 65
Find the output of the following code.
Printf("Book\ t reading\n");
Printf("is a \t very good \n habit");
Answer: 65
65-95Output:
Book reading
is a very good
habit
Question: 66
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: 66
66-95Output: Ch2 = B
Ch1 = A
Ch3 = C
Question: 67
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: 67
67-95Output :
A = 20
B = 10
Question: 68
Write down output of the following piece of code.
Printf( "*\n**\n***);
Answer: 68
68-95Output:
*
**
***
Question: 69
Write down output of the following.
Float f = 3.14159;
Printf ("f %4.f",f);
Answer: 69
69-95Output:
F = 3.14
Question: 70
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: 70
70-95Output:
a = 4
b = 40
n =40
Question: 71
Define Escape sequence.
Answer: 71
71-95Escape 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: 72
Predict the output of the following.
Float f = 3.14159
Print f (" f = %4.2f" , f);
Answer: 72
72-95Output:
f =3.14
Question: 73
Predict the output of the following code.
Printf ("*\n**\n***\n****\n");
Answer: 73
73-95Output:
**
***
****
Question: 74
Trace the output .
Int n =6;
N+ +;
Printf ("%d",n);
Answer: 74
74-95Output :
n = 7
Question: 75
Trace the output of the following code.
Int i = - 786;
Printf( "%6d",i);
Answer: 75
75-95Output:
i = -786
Question: 76
Find the output of the following code.
Printf( "Programming\t is \n very \t interesting");
Answer: 76
76-95Output:
Programming is
very interesting
Question: 77
Why the ampersand (& )used in scanf is function?
Answer: 77
77-95Ampersand (& )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: 78
Trace the error.
Int x = 5;
Int y
Y = x+3
Printf("%d" ,,y );
Answer: 78
78-95Error:
- Error is terminator sign id not present in statements in which variable y is defined and declared.
Question: 79
Trace the output of the following code .
Void main ( )
{
printf ("22\t");
printf ("666");
}
Answer: 79
79-95Output:
22,666
Question: 80
Define Standard input.
Answer: 80
80-95Standard 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: 81
What is the use of "scan f" function?Also write its syntax.
Answer: 81
81-95Scan 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
List some input functions in C-Language.
Answer: 82
82-95Input functions in C-Language:
- Getchar ( )
- Getch ( )
- Gets ( )
- Scanf ( )
Question: 83
Find the output of the following code .
Printf ("Pakistan\n is an \n Islamic \ n country");
Answer: 83
83-95Output:
Pakistan
is
an
Islamic
Country
Question: 84
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: 84
84-95Output
Result = 30, 50 10
Question: 85
Trace the error in the following code.
#include<stdio.h>
Void main( )
{
Inti;
Scanf ("%d",i);
Printf( "%d,i) ;
}
Answer: 85
85-95Errors:
- 1st errors is spelling of word main is incorrect.
- 2nd error is in printf statement closing comma is not present.
Question: 86
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: 86
86-95Output :
Enter three number 235
r = 17
Question: 87
Trace out errors in the following code.
Float r;
Clscr ();
Printf ("enter radius);
Scanf ("%f; r);
Answer: 87
87-95Errors:
- Erros is no main body is present.
Question: 88
Describe getch ( ) function.?
Answer: 88
88-95getch ( ) 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: 89
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: 89
89-95Output: 5,5,6
Question: 90
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: 90
90-95Error:
- Error is the value of variable are is not declared.
Question: 91
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: 91
91-95Output:
Enter three numbers 2 3 5
x = 6
y = 7
z = 5
Question: 92
Compare getch and getche functions
Answer: 92
92-95Getch ( ) function:
- Getch function is very handy is character manipulation.
- It does not eco the character typed.
- It does not accept any arguments.
Question: 93
Find the error in the code .
#include <STDIO>H>
VOID MAIN( ){
Int a;
A = 20
Printf ("%f",a);
Getch( );}
Answer: 93
93-95Error:
- Error is wrong library has been used in this program.
Question: 94
Explain getch ( ) function .
Answer: 94
94-95The 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: 95
Trace the error in the following code.
Float area , r
Printf (" Enter Radius")
scanf(%f"r);
Answer: 95
95-95Errors:
- 1st error no Main body is present
- 2nd error is : terminator sign is not present in statement where variable is defined.