Punjab College Gujrat - Girls Campus: Predict The Output of The Following Code. 2x4 8 Question #1 Question #2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Computer Science

I.C.S

Punjab College Gujrat Girls Campus


Time Allowed: 40mins

Student Name:
Section:

_____________
_____________

Date:
Marks:

_____________

Predict the output of the following code. 2x4=8


Question #1
void main()
{
int age;
age=10;
printf(" Welcome!\n");
printf(" You are able to test your
skill of writing C code here.\n");
getch();
}

Question #3
{
intnum=15;
num+=5
num*=2;
printf(value of num is
%d,num);
}

Trace the errors in the program.2x4=8

Question #2
void main()
{
int x=10;
int y=15;
float z=12.6;
printf("x= %d \t",x);
printf("y=%d \t",y);
printf("z=%3.1f",z);
printf("\n");
getch();
}

Question#4
#include<stdio.h>
void main()
{
int x;
x= -2 + 11 - 7 * 9 % 6 / 12;
printf("%d",x);
getch() ;
}

Computer Science
I.C.S

Question#1

Correction:

void main()
{
int = 10 ;
char = d
k=d+d;
printf(%d,k);
}

Question#2

Correction:

void main()
{
intx= 10 ;
x+5=y
Printf(%d,y);
}

Question#3

Correction:

void main();
{
int n ;
scanf(%f.k);
float sum=n+k;
printf(%d,sum);
}

i.

$cash

ii.

Total Marks

iii.
iv.
v.

Room#
_num
1.var

Identify the valid and invalid identifier from the above.


Briefly answer the following questions. 2x5
i.
What is difference between implicit and explicit type casting?
ii.
Rewrite expression in c language a=6b4?
ii.
Define variable declaration and initialization.
iii.
What is compound assignment statement.
iv. Describe coments in C.
What are operators? Explain logical operators.
(08)

Computer Science
I.C.S

You might also like