HSC ICT Chapter 5 Note (Only Important)
HSC ICT Chapter 5 Note (Only Important)
=> !
" #
?
=> $ % & !', ),*+, , - ,-
- . Programing Language #
hZ bZ
R Z _ H Z Y H Z % KR Z Gc Z
= > R Gp # b G HI !W L> Gp #
* K \
< q (Source) t (Object) G ) ,
* K #
‚ * K * ƒ ‚
* K a # <R \
* K
N. > (Compiler)
^. >C (Interpreter)
a. * ` (Assembler) > >C * `
> \
<* K High Level Language - = @) - RGp
- ,- R* K , > #
K * K
N. q t * K N. G G K ! •L ,!
# < #
^. , # ^. ! • ) K ,!
a. K R # < #
P. H a. ‚ ?, L $,- - H
~ # ? #
Q. t q M G P. ! #
#
•. ,-- LG !H
! LG #
>C \
<* K >- q - > - > !
* ƒ * K , >C #
K * K
N. >C * „ (User N. < H >
friendly) # K Q R ^Q ) ! ?#
^. K ,! ^. < < H ,
G # > ! - G
a. >C W M - * K
= % #
P.* @ * ƒ
, I) = #
Q. M ) >C
& #
* ` \
* ` = ! VK * K &
* K * ` #
* ` , > L >C GR
t * ` > >C
N. ,E <* K <* K <* K
* ` ! @) ! - >
L ‰G U , ‰G U , !
* ` # > # ‰G U ,
>C #
^. ‚ ?, L $, Š ? ‹ H ? ‹ Š ? ‹
a. ? W M p M
P. <GŒ M * GI Y
Q. !
•. ! G@ ) V G@ ) V G@ ) V
•. !
Ž. K ! - R - R - >
O. * ` ! M p
‰G U
* ? •% / %.
An algorithm is a step by step procedure < %. f GŒ ! %D
for solving a problem. < - "
<K • • L G< ‘ , •% #
) * ? #
•% & ‹ ) H \
H ’! )
‘ ) ‘ ) H ! -
H & #
> GK / ‘ ) > GK % L - , ‘ )
W GK ! “ “ W GK ! #
ST/ ! ! #
ST / !
- - ” R ,< K’ A f
ŒU ( • )R # f LG •%
K’ ? • #
, <? H & # <= - p
, <? •% - GY – = , <?
*,! *G GY – W• #
GR ! #- *G !
% < G G H R < !
#
,= < ?“ ) * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK A,B,C % )#
G a – A,B,C % <? Sum Input A,B,C
WWWW% =# Sum=A+B+C
GP–“ “ Sum %
Print Sum
WWWW ! #
GQ– ! # End
,= ?p ) * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK A,B,C % )#
G a – A,B,C % <? Sum Input A,B,C
WWWW% =# Sum=A+B+C
GP–“ “ Sum %
X=Sum/3
WWWW ! #
Print X
GQ– ,= ?p ) Sum
WWWW3 _ ? X% =# End
G•– ! #
C ‚ G . “ > G . ‰G U * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK C ‚ G . c-
WWWW )# Input c
G a – f = (9*c/5)+32 f = (9*c/5)+32
GP–“ “ f%
Print f
WWWW ! #
GQ– ! # End
“ > G . C ‚ G . ‰G U * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK “ > G . f-
WWWW )# Input f
G a – c = 5*(f-32)/9 c = 5*(f-32)/9
GP–“ “ c%
Print c
WWWW ! #
GQ– ! # End
,= Y f ,= ) * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK A,B,C % )#
Ga– R ,= _ H L Y H ,= Input A,B,C
aaaaaaaa* GI p? NO YES
A>B
( ) ,
YES NO NO YES
“ “ M G >, R ,= *R q A p B>C A>C
aaaaa- ,• , G < >#
(=) # Print B Print C Print A
GP– _ H ,= Y H ,= * GI
WWWW p?
( ) ,
“ “ M G >, _ H ,= *R q B p End
aaaaa- ,• , G < >#
(=) #
G Q – “ “ M G >, Y H ,= *R q C
WWWW p#
G•– ! #
,= Y f ,= ) * ? L •% \
* ? •%
G N – ST#
G ^ – > GK A,B,C % )#
Ga– R ,= _ H L Y H ,= Start
aaaaaaaa* GI M ?
( ) , Input A,B,C
“ “ M G >, R ,= *R q A M YES NO
A>B
aaaaa- ,• , G < >#
NO YES YES NO
(=) # B>C A>C
GP– _ H ,= Y H ,= * GI
WWWW M ? Print B Print C Print A
( ) ,
“ “ M G >, _ H ,= *R q B M
aaaaa- ,• , G < >#
(=) # End
G Q – “ “ M G >, Y H ,= *R q C
WWWW M #
G•– ! #
1 R n G<U < ?“ ) * ? L •% \
1+2+3…..+n
1+2+3…..+n G<U < ?“ ) * ? L •% \
* ? •%
G N – ST#
G ^ – sum L i % K> <R ‘ 0 Start
aaaaaaaa- , 1 #
G a – > GK n% )# sum=0,i=1
. K I.“ ) * ? L •% \
* ? •%
G N – ST# Start
G ^ – > GK . K @ b- ,
Input b,h
WWWW b h- )#
1
G a – Area=2 *b*h Area - 1
Area=2 *b*h
WWWW ) #
GP–“ “ Area % Print X
WWWW ! #
End
GQ– ! #
K § ,= . . ) * ? L •% \
* ? •%
Start
End
?. . ) * ? L •% \
* ? •%
G N – ST# Start
G ^ – K> ,= l L s > GK
Input l,s (l>s)
WWWW # (l>s)
Ga– M ,= s p ,= l ?
WWWW ?! r ) #
r=l%s
GP– ?! r< 0 , GQ
WWWW- < >, * R K l=s - , s=r YES
r=0?
WWWW GK a , G < >#
NO
G Q – ?. . - ! # Print s
G•– ! # l=s,s=r
End
- * ) * ? L •% \
* ? •%
Start
G N – ST#
G ^ – > GK year )# Input Year
Ga–< (year%400==0) • , YES
WWWW G < ># *
GP–< (year%4==0 && year%100!=0) NO
WWWW • , G < ># * R GQ- YES
**
WWWW< ># NO
G Q – not leap year ! # Print leap year Print not leap year
G • – leap year ! #
GQ– ! #
End
‚ >G & -L ‚ )
Character char char a; char a,b,c;
int number1,
Integer int int number;
number2;
Float float float a; float a,b,c;
Double double double a; double a,b,c;
±! ƒ \
±! ƒ )
\a Audible alert *R q ,
& #
\b Back space *R q - ´
& #
\f Form feed *R q W GK % > !
& #
\n New line *R q W GK K > ST
! & #
\r Carriage return *R q W GK >
µ ST ! & #
\t Horizontal tab *R q W GK ‚ -
G ) @ ! & #
“ · “ \
· “ )
%c Single character > GK /W GK & # scanf(“%c”,&a), printf(“%c”,&a)
*G ) “ “
/ (Division) ? 81/9 9
* (Multiplication) ) 7*6 42
% (Module) ?! ) 20%6 2
+ (Binary plus) <? 8+5+2.75 15.75
- (Binary Minus) ? 9-5 4
*G *R
< Less than ( M )
<= Less than or equal ( M )
> Greater than ( p)
>= Greater than or equal ( M )
== Equal to ( )
!= Not equal to (* )
*G
|| K *G OR *G !
( OR)
&& K *G AND *G !
( AND)
!* K *G NOT *G !
( NOT)
,= < ?“ ) ,\ ,= ?p ) ,\
#include<stdio.h> #include<stdio.h>
int main() { int main() {
int a,b,c,sum; int a,b,c,sum;
printf("Enter three integer numbers:"); float avg;
scanf("%d%d%d",&a,&b,&c); printf("Enter three integer number:");
sum=a+b+c; scanf("%d%d%d",&a,&b,&c);
printf("\n Summation of three number sum=a+b+c;
is=%d",sum); avg=(float)sum/3;
return 0; printf("\n Summation of three number
} is=%d",sum);
printf("\n Average of three number
is=%.2f",avg);
return 0;
}
G> ) ,\ Pow - \
#include<stdio.h> #include <stdio.h>
int main(){ #include <math.h>
int year; int main() {
printf("Enter any year: "); double base, power, result;
scanf("%d",&year); printf("Enter the base number: ");
if(((year%4==0)&&(year%100!=0))||(year%400==0)) scanf("%lf", &base);
printf("%d is a leap year.",year); printf("Enter the power raised: ");
else scanf("%lf",&power);
printf("%d is not a leap year.",year); result = pow(base,power);
return 0; printf("%.1lf^%.1lf = %.2lf", base,
} power, result);
return 0;
}
Yf I.“ \
#include<stdio.h> #include<stdio.h>
float pi=3.14; int main(){
int main(){ float radius,area;
float radius,area; float pi=3.14;
printf("Enter the radius of the circle (in printf("Enter the radius of the circle (in
cm): "); cm): ");
scanf("%f",&radius); scanf("%f",&radius);
area= (pi)*(radius*radius); area= (pi)*(radius*radius);
printf("Area of the circle: %.2f square printf("Area of the circle: %.2f square
cm",area); cm",area);
return 0; return 0;
} }
a ,= Y f ,= ) \
If If..else If….else if
#include<stdio.h> #include<stdio.h> #include<stdio.h>
int main() { int main() { int main() {
int a,b,c,sum; int a,b,c,sum; int a,b,c,sum;
printf("Enter three integer printf("Enter three integer printf("Enter three integer
number:"); number:"); number:");
scanf("%d%d%d",&a,&b,&c); scanf("%d%d%d",&a,&b,&c); scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c)) if((a>b)&&(a>c)) if((a>b)&&(a>c))
printf("%d is the largest printf("%d is the largest printf("%d is the largest
number.",a); number.",a); number.",a);
if((b>a)&&(b>c)) if((b>a)&&(b>c)) else if((b>a)&&(b>c))
printf("%d is the largest printf("%d is the largest printf("%d is the largest
number.",b); number.",b); number.",b);
if((c>a)&&(c>b)) else else
printf("%d is the largest printf("%d is the largest printf("%d is the largest
number.",c); number.",c); number.",c);
return 0; return 0; return 0;
} } }
1+2+3…………n
1+2+3…………n < ?“ \
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> #include <stdio.h>
int main() { int main() { int main() {
int i,n,sum=0; int i=1,n,sum=0; int i=1,n,sum=0;
printf("Enter the last term: printf("Enter the last term: printf("Enter the last term:
"); "); ");
scanf("%d",&n); scanf("%d",&n); scanf("%d",&n);
for(i=1;i<=n;i=i+1) while(i<=n) do
{ { {
sum=sum+i; sum=sum+i; sum=sum+i;
} i=i+1; i=i+1;
printf("%d",sum); } } while(i<=n);
return 0; printf("%d",sum); printf("%d",sum);
} return 0; return 0;
} }
1×2×3…………n
…………n < ?“ \
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> #include <stdio.h>
int main() { int main() { int main() {
int i,n,sum=1; int i=1,n,sum=1; int i=1,n,sum=1;
printf("Enter the last term: printf("Enter the last term: printf("Enter the last term:
"); "); ");
scanf("%d",&n); scanf("%d",&n); scanf("%d",&n);
for(i=1;i<=n;i=i+1) while(i<=n) do
{ { {
sum=sum*i; sum=sum*i; sum=sum*i;
} i=i+1; i=i+1;
printf("%d",sum); } } while(i<=n);
return 0; printf("%d",sum); printf("%d",sum);
} return 0; return 0;
} }
1+3
1+3+5…………n
…………n < ?“ \
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> #include <stdio.h>
int main() { int main() { int main() {
int i,n,sum=0; int i=1,n,sum=0; int i=1,n,sum=0;
printf("Enter the last term: printf("Enter the last term: printf("Enter the last term:
"); "); ");
scanf("%d",&n); scanf("%d",&n); scanf("%d",&n);
for(i=1;i<=n;i=i+2) while(i<=n) do
{ { {
sum=sum+i; sum=sum+i; sum=sum+i;
} i=i+2; i=i+2;
printf("%d",sum); } } while(i<=n);
return 0; printf("%d",sum); printf("%d",sum);
} return 0; return 0;
} }
2+4+6…………n
…………n < ?“ \
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> #include <stdio.h>
int main() { int main() { int main() {
int i,n,sum=0; int i=2,n,sum=0; int i=2,n,sum=0;
printf("Enter the last term: printf("Enter the last term: printf("Enter the last term:
"); "); ");
scanf("%d",&n); scanf("%d",&n); scanf("%d",&n);
for(i=2;i<=n;i=i+2) while(i<=n) do
{ { {
sum=sum+i; sum=sum+i; sum=sum+i;
} i=i+2; i=i+2;
printf("%d",sum); } } while(i<=n);
return 0; printf("%d",sum); printf("%d",sum);
} return 0; return 0;
} }
“ ƒ ) \
(1×2×3…………n < ?“ W -> - > S K sum - ~ fact - , R printf - Enter
the last term - G Enter the integer number & M#)
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> #include <stdio.h>
int main() { int main() { int main() {
int i,n,fact=1; int i=1,n,fact=1; int i=1,n,fact=1;
printf("Enter the integer printf("Enter the integer printf("Enter the integer
number: "); number: "); number: ");
scanf("%d",&n); scanf("%d",&n); scanf("%d",&n);
for(i=1;i<=n;i=i+1) while(i<=n) do
{ { {
fact=fact*i; fact=fact*i; fact = fact*i;
} i=i+1; i=i+1;
printf("%d", fact); } } while(i<=n);
return 0; printf("%d", fact); printf("%d", fact);
} return 0; return 0;
} }
?. . ) \
For While Do…W
o…While
#include <stdio.h> #include <stdio.h> # #include <stdio.h>
int main() { int main() { int main() {
int n1, n2, i, gcd; int n1, n2, i=1, gcd; int n1, n2, i=1, gcd;
printf("Enter two integers: printf("Enter two integers: printf("Enter two integers:
"); "); ");
scanf("%d %d", &n1, &n2); scanf("%d %d", &n1, &n2); scanf("%d %d", &n1, &n2);
for(i=1; i <= n1 && i <= n2; while(i<=n1 && i<=n2) do
++i) { {
{ if(n1%i==0 && n2%i==0) if(n1%i==0 && n2%i==0)
if(n1%i==0 && n2%i==0) gcd = i; gcd = i;
gcd = i; ++i; ++i;
} } } while(i<=n1 && i<=n2);
printf("G.C.D of %d and %d printf("G.C.D of %d and %d printf("G.C.D of %d and %d
is %d", n1, n2, gcd); is %d", n1, n2, gcd); is %d", n1, n2, gcd);
return 0; return 0; return 0;
} } }
. . ) \
#include <stdio.h> printf("The LCD of %d & %d is
int main() { %d",n1,n2,k);
int n1,n2,k; else {
printf("Enter two integer numbers:"); k=k+1;
scanf("%d%d",&n1,&n2); goto Again;
if(n1>n2) }
k=n1; return 0;
else }
k=n2;
Again:
if(k%n1==0 && k%n2==0)