Computer Worksheet
Computer Worksheet
dse
Ik-8-20;
30/7*3-6
-33-6
3. Write a program that reads a number and prints its square if it is greater than 10. (3)
ch= 'c:
switch(ch M
case 'a':
case'b':
printf(" hello");
9eodbye
printf(" h"):
case 'c:
case 'd':
case 'e':
printf(" good bye");
WORKSHEEI
Computer Science SSC-II
Date:.
Class/Sec:IOB_
Student Name: Arfa Sodaat
Statements
SLOS: Use of Conditional Control
(3)
after correction(s):
1. Rewrite the following program
#nclucke <teioh
#include<stdio.h>
("Enter a number:
");
printf
scanf("%8",
num);
if (num %2=0)
number");
if(um2-).
númte )
print("Even printf ('ven
else
number"); Printf("odd
numbe";
printf("Odd
return; } LretunO
(1
above program into Ternarý operators,
2. Convert the nunmbe
nube)iprint("bdd
(num 20) ?printf("Even
3. Write a program that
inclode <stdioh
int main
Lint a)
)
Printf ("Enler
readss
a number");
a number and prints its
|f(a>10)
square
PrintfC"saquove
/", a*a):
if it
te number
is greaterthan 10.
of numberis
is
(2)
lestho lo};
Scanf ("td"la);
Celsiusand prints a message as given
4. Write a program that reads temperature
(t) i
below:
(3)
Temperature Message to print
t>35 It is hot!
printf(" I+ is hoH)
lelse iflE>-2022t+3s)
rornntCNice Deuyl
is cold),
printf
else
nfvakd input);
reurnO)
WORKSHEET
Computer Science SSC-|
Include <stdio.h>
Date:
Name: Axfa Sadagat Class/Sec:lOB
Student
of Repetition
Structure(Loops)
SLOS: Use
(2)
after correction(s):
1. Rewrite the following program
#include<stdio.h>
#incude (stdio-h
intmain() int main()
{int n, sum =0;, |lintn,i,sum-0;
i,
printf("Enter a number: "); pnntf(" Ernter anumber:");
scanf("%d", &n); scanfCd' &n);
for (i=1;i<-n;i+ +) 4
for(i = 1; i<= n; it+)
sum =+ i; }
printf("Sum =%d", sum); sug:dsu);
printf"
return O;
returnO; )
2. What will be the output: (1)
int n; 30 25 20 IS VO S
for(n=30; n>=5; n=n-5)
printf("%d ",n );