KEMBAR78
Assignment: Computer Science | PDF | Computer Programming | Computing
0% found this document useful (0 votes)
188 views8 pages

Assignment: Computer Science

This document contains an assignment for a computer science C programming class. It includes 10 multiple choice questions and 10 code snippets with errors to find. The questions cover topics like loops, conditional statements, operators, and basic syntax. Students are asked to find the output for the questions and identify any errors in the code snippets. The assignment is due on January 15th, 2022 and is worth a total of 40 marks.

Uploaded by

Hassan Farid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views8 pages

Assignment: Computer Science

This document contains an assignment for a computer science C programming class. It includes 10 multiple choice questions and 10 code snippets with errors to find. The questions cover topics like loops, conditional statements, operators, and basic syntax. Students are asked to find the output for the questions and identify any errors in the code snippets. The assignment is due on January 15th, 2022 and is worth a total of 40 marks.

Uploaded by

Hassan Farid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Assignment

Computer Science

C PROGRAMMING
MISS LARAIB RAZZAQ

COMMUNITY MODEL BOYS COLLEGE


T.M: (2 X20=40) Last Date of Submission: 15-01-2022

Question – 1
Find output.
(a)
int main()
{
int val=1;

do{
val++;
++val;
}while(val++>25);

printf("%d\n",val);

(b)
#include <stdio.h>

int main()
{
int x = 400, y, z;
if (x >= 500)
y = 400;
z = 300;
printf("%d %d\n", y, z);

}
(c)
int main()
{
int p = 800, q, r;

if (p >= 700)
q = 600;

r = 500;

printf("%d %d\n", q, r);

(d)
int main()
{
int e = 4;
float f = 4.0;
if (e == f) {
printf("E and F are equal\n");
}
else {
printf("E and F are not equal");
}
}

(e)
int main()
{
int i = 65;

char j = 'A';

if (i == j) {

printf("This place is beautiful\n");


}

else {
printf("This place is not beautiful\n");
}}

(f)
int main()
{
float p = 13.25, q = 14.5;

if (p = q) {
printf("Hello\n");
}
}

(g)
int main()
{
int i;
for(i=1; i<=10;i++)
printf("i=%d\n",i);

(h)
int main ()

int a, b;

a = b = 4;

b = a++;

printf("%d %d %d %d", a++, --b, ++a, b--);

}
(i)
int main()

int a = 10, b = 25;

a = b++ + a++;

b = ++b + ++a;

printf("%d %d n", a, b);

(j)
int main()
{
int i=2;
while(i<=20)
printf("i=%3d\n",i);
i=i+2;

Question – 2
Find Errors.
(a)
#include<stdio.h>
void main()
{
int x = 10;
int y = 15;

printf("%d", (x, y))


}
(b)
#include<stdio.h>
int main(void)
{
while(.)
{
printf("hello");
}
return 0;
}

(c)
#include<stdio.h>

void Main()
{
int a = 10;
printf("%d", a);
}

(d)
void main()
{
int a, b, c;
a + b = c;
}

(e)
int main ()
{
int m = -10,n =20;

n = ( m < 0) ? 0 : 1;

printf ( " %d %d ", m,n ) ;


}

(f)
char x='Y';
while(x='Y')
{
printf("x is equal to y\n");
}

(g)
int main()
{
int a = 0 while(i < 5);
{
printf("Hello World");
i++;
}
return 0;
}

(h)
#include<stdio.h>

int main()
{
int num1, num2;

printf("\nEnter the first number:\t");


scanf("%d", num1);
return 0;
}

(i)
int main()
{
int a = 0
while(i < 5);
{
printf("Hello World");
i++;
}
return 0;
}

(j)
int main()
{
int num = 10;
printf("Number:\t%f", num)
return 0;
}

***** Good Luck *****

You might also like