Upload
sujonpap
View
307
Download
14
Embed Size (px)
Citation preview
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
1/117
PDF Version
Tj Thouhid
Edited By
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
2/117
Waarning :
PDF , Possible
:-
, Copywrite
Copywrite
,
,
(01191385551),
,
278/3 (),
(),
, ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
3/117
() ,
, (
)
-
? ,
,
''
,
, -(,
, ) -
() ,
: "i just have gone through your book. i have been thinking about
writing a book like this for last five six years- you have done it- i do not need to
do it any more. thank you. i have some comments- it's better to talk. i lost your
cell number send ittome."
(, ) -
-
( , ,
) -
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
4/117
( ) -
:
" ?", " ?", " , " -
( ) -
(, -) -
() -
(, , ) -
(, , ) -
( , , ) -
() -
() -
( ,
) - ,
(, )-
( , ) -
(, , ) -
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
5/117
(, , ) -
(, , ) -
( , ,
) -
, , , ,
,
[] , ? , , ,
(0) (1) (user) -,
0 1 0, 1 ,
0, 1 ,
,
ADD (), MUL () 0, 1-
,
- (Fortran), (Basic), (Pascal),
(C) , , , (C++),
(Visual Basic), (Java), (C#), (Perl), (PHP), (Python),
(Ruby)
, ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
6/117
,
(logic) ,
,
,
,
,
, -
( , )
,
, (),
,
, --, ,
,
,
, ? - ,
gcc
Codeblocks (http://www.codeblocks.org/)
IDE (Integrated Development Environment) (: , , )
(IDE)
Codeblocks http://www.codeblocks.org
Downloads Binaries- : codeblocks-10.05-
setup.exe codeblocks-10.05mingw-setup.exe(74.0 MB)
, Ubuntu Software
Center (Applications > Ubuntu Software Center)
,
-
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
7/117
. ,
-
, ,
,
Chapter 1
[
]
!
, Hello World
Codeblocks ,
--Installing Codeblock
Start Programs- Codeblocks
Applications > Programming-
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
8/117
Show tips at startup (tick)
(Save)
Save as type C/C++ files
hello.c .c
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
9/117
#i ncl ude
i nt mai n ( )
{
pr i nt f ( "Hel l o Wor l d") ;
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
10/117
, ? , !
BuildCompile Current File-
0 errors, 0 warnings, -syntax
Build Run-
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
11/117
, Hello World Process returned 0
(0x0) () execution time : 0.031 s
0.031 , Press any key to continue. -Any
key
Hello World
--Hello World! using Code::Blocks
: #include ,
: int main(),
()
return 0; , ,
:
int main()
{
return 0;
}
: printf("Hello World"); printf()
-
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
12/117
stdio.h (header) (.h
)stdio.h -,
, printf(),
#include ,
printf("Hello World");-
return 0;,
, (compile
error)
#include , int
main(), { } printfreturn 0-
() (Indentation)
,
,
-,
(Tab) Codeblocks-Settings Editor-TAB
Options-TAB indents TAB size in spaces 4
: I love my country, Bangladesh
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
13/117
Chapter 2
[] ,
, ,
? !
, =
, ,
#i ncl ude
i nt mai n( )
{
i nt a;i nt b;
i nt sum;
a = 50;
b = 60;
sum = a + b;
pr i nt f ( "Sum i s %d", sum) ;
r etur n 0;
}
: .
, : Sum is 110
a, b, sum (variable) a, b, sum
int a; a
(integer)-
int , -
,
, : int a, b, sum;
:a = 50;b = 60;a-50 b-60 (assign ), , a-
50 b-60
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
14/117
: sum = a + b;, sum- a + b-, a b-
sum (assign )
, printf
printf("Sum is %d", sum);
printf"Sum is %d" Sum
is %d- sum
%d- sum- %d ,
,
,
,
:
#i ncl ude i nt mai n( )
{
i nt a, b, sum;
a = 50;
b = 60;
sum = a + b;
pr i nt f ( "Sum i s %d", sum) ;
r etur n 0;
}
: . :
#i ncl ude
i nt mai n( )
{
i nt a = 50, b = 60, sum;
sum = a + b;
pr i nt f ( "Sum i s %d", sum) ;
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
15/117
?
#i ncl ude
i nt mai n( )
{
i nt x, y;
x = 1;
y = x;
x = 2;
pr i nt f ( "%d", y) ;
r etur n 0;
}
: .
? 1 2? 1, , x- 1 (x =
1;) x- y- (y = x;) y- 1 x- 2
y-y = x; '='
:
#i ncl ude
i nt mai n( )
{
i nt a = 50, b = 60, sum;
sum = a + b;
pr i nt f ( "%d + %d = %d", a, b, sum) ;
r etur n 0;
}
: .
? printf("%d + %d = %d", a, b, sum);
printf("%d + %d = %d", b, a, sum);
, , ,
,
, ,
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
16/117
-, ,
, int ( real number) , ?
#i ncl ude
i nt mai n( )
{
i nt a = 50. 45, b = 60, sum;
sum = a + b;
pr i nt f ( "%d + %d = %d", a, b, sum) ;
r etur n 0;
}
: .
a-50.45 , , main
return 0; ? return 0;
: 50 + 60 = 110
a- 50 , 50.45 (type cast)
double double int-,
: int a = (int) 50.45
int a = 50.99; a- 50 int a = -50.9; a- -50
double int-
,
#i ncl ude
i nt mai n( )
{
i nt n;
doubl e x;
x = 10. 5;
n = ( i nt ) x;
pr i nt f ( "Val ue of n i s %d\ n", n) ;
pr i nt f ( "Val ue of x i s %l f \ n", x) ;
r etur n 0;
}
: .
x-- double
, %lf (l L)
int ? :
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
17/117
#i ncl ude
i nt mai n( )
{
i nt a;
a = 1000;
pr i nt f ( "Val ue of a i s %d", a) ;
a = - 21000;
pr i nt f ( "Val ue of a i s %d", a) ;
a = 10000000;
pr i nt f ( "Val ue of a i s %d", a) ;
a = - 10000000;
pr i nt f ( "Val ue of a i s %d", a) ;
a = 100020004000503;
pr i nt f ( "Val ue of a i s %d", a) ;
a = - 4325987632;
pr i nt f ( "Val ue of a i s %d", a) ;r etur n 0;
}
: .
a- ?
printf- printf
: printf("Value of a is %d\n", a); printf ""- \n
a- , -2146473648 2147483647
, int int -
int (byte) (1 byte = 8 bit)
, 0 1 (00, 01, 10, 11) 32 :
2^32 4294967296 , -
2146473648 -1 2146473648 0 2146473647
2146473648, 4294967296,
(real number) ,
, ... -3, -2, -1, 0, 1, 2, 3 ... -5, -3, -2.43, 0, 0.49,
2.92 ()
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
18/117
#i ncl ude
i nt mai n( )
{
doubl e a, b, sum;
a = 9. 5;
b = 8. 743;
sum = a + b;
pr i nt f ( "Sum i s: %l f \ n", sum) ;
pr i nt f ( "Sum i s: %0. 2l f \ n", sum) ;
r etur n 0;
}
: .
:
Sum is: 18.243000
Sum is: 18.24
%lf,
%0.2lf ( %0.3lf ,
%0.0lf) double 64 1.7E-308 (1.7 x 10-308)
1.7E+308 (1.7 x 10308)
,
, ,
()
scanf(-):
#i ncl ude
i nt mai n( )
{
i nt a, b, sum;
scanf ( "%d", &a) ;
scanf ( "%d", &b) ;
sum = a + b;
pr i nt f ( "Sum i s: %d\ n", sum) ;
r etur n 0;
}
: .
(blank screen) , (space)
(enter)
scanf scanf("%d", &a); %d
scanf- int ( )
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
19/117
a- (&) , &a a
, &a- ,
a b- scanf : scanf("%d %d",
&a, &b); &? ,
,
#i ncl ude
i nt mai n( )
{
i nt a, b, sum;
scanf ( "%d", &a) ;
scanf ( "%d", b) ;
sum = a + b;
pr i nt f ( "Sum i s: %d\ n", sum) ;
r etur n 0;
}
: .
? scanf- %d-
%lf
, int double
,
, ,
, ,
, char (character) character
, char
:
#i ncl ude
i nt mai n( )
{
char ch;
pr i nt f ( "Ent er t he f i r st l et t er of your name: ") ;
scanf ( "%c", &ch) ;pr i nt f ( "The f i r st l et t er of your name i s: %c\ n", ch) ;
r etur n 0;
}
: .
, char printf scanf%c
getchar, char :
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
20/117
#i ncl ude
i nt mai n( )
{
char ch;
pr i nt f ( "Ent er t he f i r st l et t er of your name: ") ;
ch = get char ( ) ;
pr i nt f ( "The f i r st l et t er of your name i s: %c\ n", ch) ;
r etur n 0;
}
: .
getchar ch
char
: char c = 'A';
:
#i ncl ude i nt mai n( )
{
i nt num1, num2;
pr i nt f ( "Pl ease ent er a number : " ) ;
scanf ( "%d", &num1) ;
pr i nt f ( "Pl ease ent er anot her number : ") ;
scanf ( "%d", &num2) ;
pr i nt f ( "%d + %d = %d\ n" , num1, num2, num1+num2) ;
pr i nt f ( "%d - %d = %d\ n", num1, num2, num1- num2) ;
pr i nt f ( "%d * %d = %d\ n", num1, num2, num1*num2) ;pr i nt f ( "%d / %d = %d\ n", num1, num2, num1/ num2) ;
r etur n 0;
}
: .
,
, num1 num2-, , , printf
, num2- 0 printf
+, -, *, / char
:
#i ncl ude
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
21/117
i nt mai n( )
{
i nt num1, num2, val ue;
char si gn;
pr i nt f ( "Pl ease ent er a number : ") ;
scanf ( "%d", &num1) ;
pr i nt f ( "Pl ease ent er anot her number : ") ;
scanf ( "%d", &num2) ;
val ue = num1 + num2;
si gn = ' +' ;
pr i nt f ( "%d %c %d = %d\ n", num1, si gn, num2, val ue) ;
val ue = num1 - num2;
s i gn = ' - ' ;
pr i nt f ( "%d %c %d = %d\ n", num1, si gn, num2, val ue) ;
val ue = num1 * num2;
si gn = ' *' ;pr i nt f ( "%d %c %d = %d\ n", num1, si gn, num2, val ue) ;
val ue = num1 / num2;
s i gn = ' / ' ;
pr i nt f ( "%d %c %d = %d\ n", num1, si gn, num2, val ue) ;
r etur n 0;
}
: .
, (
, -),
(comment) //
/* */
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
22/117
#i ncl ude
i nt mai n( )
{
/ / t est pr ogr am - comment 1
pr i nt f ( "Hel l o " ) ;
/ * We have pr i nt ed Hel l o,
now we shal l pr i nt Wor l d.
Note t hat t hi s i s a mul t i - l i ne comment */
pr i nt f ( "Worl d") ; / / pr i nt ed worl d
r etur n 0;
}
: .
, ( - ), ?
, a z, A Z, 0 9 _ (
) () int 7d;
, sum ,
y ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
23/117
Chapter 3
[]
''! -
#i ncl ude
i nt mai n( )
{
i nt n;
n = 10;
i f ( n >= 0) {
pr i nt f ( "The number i s posi t i ve\ n") ;
}
el se {
pr i nt f ( "The number i s negat i ve\ n") ;
}
r etur n 0;
}
: .
? n- (: 0, -10, -2, 5, 988 )
n (positive) (negative)
, 'n , n, n ' if else
if- () ( if-
{ } ) if-
, else- ( )
,
, ? '' >=
''- -
if
else-ifelse , ()
:
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
24/117
#i ncl ude
i nt mai n( )
{
i nt n;
n = 10;
i f ( n < 0) {
pr i nt f ( "The number i s negat i ve\ n") ;
}
el se {
pr i nt f ( "The number i s posi t i ve\ n") ;
}
r etur n 0;
}
: .
n , n ; (
n ) n
,
:
#i ncl ude
i nt mai n( )
{
i nt n = 10;
i f ( n < 0) {
pr i nt f ( "The number i s negat i ve\ n") ;
}
el se i f ( n > 0) {
pr i nt f ( "The number i s posi t i ve\ n") ;
}
el se i f ( n == 0) {
pr i nt f ( "The number i s zero!\ n") ;
}
r etur n 0;
}
: .
:if(n < 0): n
else if(n > 0): , n if(n > 0)
else if(n == 0): n > 0 ?
n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
25/117
, ,
n-
#i ncl ude
i nt mai n( )
{
i nt n = 10;
i f ( n < 0) {
pr i nt f ( "The number i s negat i ve\ n") ;
}
el se i f ( n > 0) {
pr i nt f ( "The number i s posi t i ve\ n") ;
}
el se {
pr i nt f ( "The number i s zero!\ n") ;
}
r etur n 0;
}
: .
ifelse else if, :
#i ncl ude
i nt mai n( )
{
i nt number = 12;
i f ( number > 10) {
pr i nt f ( "The number i s gr eat er t han t en\ n") ;
}
r etur n 0;
}
: .
?
#i ncl ude
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
26/117
i nt mai n( )
{
i nt n = 10;
i f ( n < 30) {
pr i nt f ( "n i s l ess than 30. \ n") ;
}
el se i f ( n < 50) {
pr i nt f ( "n i s l ess than 50. \ n") ;
}
r etur n 0;
}
: .
: n is less than 30. else if(n < 50) if (n < 30) ,
else if else ,
#i ncl ude
i nt mai n( )
{
i nt n = 10;
i f ( n < 30) {
pr i nt f ( "n i s l ess than 30. \ n") ;
}
i f ( n < 50) {
pr i nt f ( "n i s l ess than 50. \ n") ;
}
r etur n 0;
}
: .
2 , ;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
27/117
(modulus operator) , '%'
: int number;
number-: number = 5;
number2 : remainder = number % 2;
if- remainder- remainder-
0 1:
#i ncl ude
i nt mai n( )
{
i nt number , r emai nder ;
number = 5;
r emai nder = number % 2;
i f ( r emai nder == 0) {
pr i nt f ( "The number i s even\ n") ;
}
el se {
pr i nt f ( "The number i s odd\ n") ;
}
r etur n 0;
}
: .
remainder :
#i ncl ude
i nt mai n( )
{
i nt number = 9;
i f ( number % 2 == 0) {
pr i nt f ( "The number i s even\ n") ;
}
el se {
pr i nt f ( "The number i s odd\ n") ;
}
r etur n 0;
}
: .
, , ? else
? ,
(*, /, -)
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
28/117
(small letter lower case letter)
(capital letter upper case letter),
character 26 lower case
letter 26upper case letter-, ,
char ch = ' p' ;
i f ( ch == ' a' )
{
pr i nt f ( "%c i s l ower case\ n", ch) ;
}
el se i f ( ch == ' A' )
{
pr i nt f ( "%c i s upper case\ n", ch) ;
}
el se i f ( ch == ' b' )
{
pr i nt f ( "%c i s l ower case\ n", ch) ;
}
el se i f ( ch == ' B' )
{
pr i nt f ( "%c i s upper case\ n", ch) ;
}
el se i f ( ch == ' c' )
{
pr i nt f ( "%c i s l ower case\ n", ch) ;
}
el se i f ( ch == ' C' )
{
pr i nt f ( "%c i s upper case\ n", ch) ;
}
(AND operator) '&&'
#i ncl ude
i nt mai n( )
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
29/117
{
char ch = ' W' ;
i f ( ch >= ' a' && ch = ' A' && ch = 'a' && ch = 'a'
ch = ' a' && ch = ' A' && ch
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
30/117
#i ncl ude
i nt mai n( )
{
i nt num= 5;
i f ( num >= 1 | | num = 1) (n= 'a' && ch
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
31/117
(condition)
,
1 10 ()
, :
#i ncl ude
i nt mai n( )
{
pr i nt f ( "1\ n") ;
pr i nt f ( "2\ n") ;
pr i nt f ( "3\ n") ;
pr i nt f ( "4\ n") ;
pr i nt f ( "5\ n") ;
pr i nt f ( "6\ n") ;
pr i nt f ( "7\ n") ;
pr i nt f ( "8\ n") ;
pr i nt f ( "9\ n") ;
pr i nt f ( "10\ n") ;
r etur n 0;
}
: .
1 10 printf() :
printf("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
n , 1 n-
n-(n = n + 1 , n++ )
int n = 1;printf("%d\n", n);
n = n + 1;printf("%d\n", n);n = n + 1;printf("%d\n", n);
n = n + 1;/* */
n1
printf("%d\n", n);n = n + 1;:
printf("%d\n", n++);
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
32/117
-, 1 10 1 100, 1000, 10000
? ,
(loop) ,
while forwhile
#i ncl ude
i nt mai n( )
{
i nt n = 1;
whi l e( n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
33/117
i nt n = 1;
whi l e( n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
34/117
continue; continue continue-
:
#i ncl ude
i nt mai n( )
{
i nt n = 0;
whi l e (n < 10) {
n = n + 1;
i f ( n % 2 == 0) {
cont i nue;
}
pr i nt f ( "%d\ n", n) ;
}
r etur n 0;
}
: .
1 10- continue
printf("%d\n", n);
5-:
5 X 1 = 55 X 2 = 10
5 X 3 = 15
5 X 4 = 205 X 5 = 255 X 6 = 30
5 X 7 = 355 X 8 = 405 X 9 = 455 X 10 = 50
printf:
#i ncl ude
i nt mai n( )
{
i nt n = 5;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
35/117
i nt i = 1;
whi l e ( i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
36/117
, :
#i ncl ude
i nt mai n( )
{
i nt n = 5;
i nt i = 1;
f o r ( ; ; ) {
pr i nt f ( "%d X %d = %d\ n", n, i , n*i ) ;
i = i + 1;
i f ( i > 10) {
break;
}
}
r etur n 0;
}
: . for 5- (n*i)
? 5 x 3-5 + 5 + 5
:
#i ncl ude
i nt mai n( )
{
i nt m, n = 5;
i nt i ;
m = 0;
f or( i = 1; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
37/117
#i ncl ude
i nt mai n( )
{
i nt n, i ;
f or ( n = 1; n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
38/117
i nt a, b, c;
f or ( a = 1; a
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
39/117
3- c- a- c- b-
:
#i ncl ude
i nt mai n( )
{
i nt a, b, c;
f or ( a = 1; a
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
40/117
f or ( a = 1; a
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
41/117
? ", !"?
,
!
) http://jontrogonok.com/?p=6
) http://jontrogonok.com/?p=9
Chapter 5
[]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
42/117
, -
) x + y = 15, x y = 5 x y-?
2x = 20, x = 10, 2y = 10, y = 5x + y x y-, x y-
) 4x + 5y = 14, 5x + 6y = 17 x y-?
:
a1x + b1y = c1, a2x + b2y = c2
(substitution) (determinant)
,
x = (b2c1 b1c2) / (a1b2 a2b1) y = (a1c2 a2c1) / (a1b2 a2b1)a1, a2, b1, b2, c1, c2-x y-
, a1, a2, b1, b2, c1, c2
x y-
, :#i ncl ude
i nt mai n( )
{
doubl e x, y, x_pl us_y, x_mi nus_y;pr i nt f ( "Ent er t he val ue of x + y: ") ;
scanf ( "%l f ", &x_pl us_y);
pr i nt f ( "Ent er t he val ue of x - y: ") ;
scanf ( "%l f " , &x_mi nus_y) ;
x = ( x_pl us_y + x_mi nus_y) / 2;
y = ( x_pl us_y - x_mi nus_y) / 2;
pr i nt f ( "x = %0. 2l f , y = %0. 2l f \ n", x, y) ;
r etur n 0;
}
: .
int double
:
#i ncl ude
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
43/117
i nt mai n( )
{
doubl e a1, a2, b1, b2, c1, c2, x, y;
pr i nt f ( "a1 = ") ;
scanf ( "%l f ", &a1) ;
pr i nt f ( "a2 = ") ;
scanf ( "%l f ", &a2) ;
pr i nt f ( "b1 = ") ;
scanf ( "%l f ", &b1) ;
pr i nt f ( "b2 = ") ;
scanf ( "%l f ", &b2) ;
pr i nt f ( "c1 = ") ;
scanf ( "%l f ", &c1) ;
pr i nt f ( "c2 = ") ;
scanf ( "%l f ", &c2) ;
x = ( b2 * c1 - b1 * c2) / ( a1 * b2 - a2 * b1) ;y = ( a1 * c2 - a2 * c1) / ( a1 * b2 - a2 * b1) ;
pr i nt f ( "x = %0. 2l f , y = %0. 2l f \ n", x, y) ;
r etur n 0;
}
: .
! (a1 * b2 - a2 * b1)-(x-,
y-),
(a1 * b2 - a2 * b1)-, ,
#i ncl ude
i nt mai n( )
{
doubl e a1, a2, b1, b2, c1, c2, d, x, y;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
44/117
pr i nt f ( "a1 = ") ;
scanf ( "%l f ", &a1) ;
pr i nt f ( "a2 = ") ;
scanf ( "%l f ", &a2) ;
pr i nt f ( "b1 = ") ;
scanf ( "%l f ", &b1) ;
pr i nt f ( "b2 = ") ;
scanf ( "%l f ", &b2) ;
pr i nt f ( "c1 = ") ;
scanf ( "%l f ", &c1) ;
pr i nt f ( "c2 = ") ;
scanf ( "%l f ", &c2) ;
d = a1 * b2 - a2 * b1;
i f ( ( i nt ) d == 0) {
pr i nt f ( "Val ue of x and y can not be det ermi ned. \ n") ;
}el se {
x = ( b2 * c1 - b1 * c2) / d;
y = ( a1 * c2 - a2 * c1) / d;
pr i nt f ( "x = %0. 2l f , y = %0. 2l f \ n", x, y) ;
}
r etur n 0;
}
: .
if-(int) d == 0d (double )-0-: if (d
== 0.0) , --
?
,
) 35% -
, ? ,
10000 + 10000 * 35 / 100 -:
#i ncl ude
i nt mai n( )
{
doubl e l oan_amount , i nt er est _r at e, number_of _years, t ot al _amount ,
mont hl y_amount ;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
45/117
pr i nt f ( "Ent er t he l oan amount : ") ;
scanf ( "%l f " , &l oan_amount ) ;
pr i nt f ( "Ent er t he i nt erest r at e: ") ;
scanf ( "%l f ", &i nt er est _r at e) ;
pr i nt f ( "Number of year s: ") ;
scanf ( "%l f " , &number _of _year s) ;
t otal _amount = l oan_amount + l oan_amount * i nterest _r ate / 100. 00;
mont hl y_amount = t otal _amount / ( number _of _years * 12) ;
pr i nt f ( "Tot al amount : %0. 2l f \ n", t ot al _amount ) ;
pr i nt f ( "Mont hl y amount : %0. 2l f \ n" , mont hl y_amount ) ;
r etur n 0;
}
: .
35% 35%
10000 + 10000 * 35 * 5 / 100
-
)
u (initial velocity) a (acceleration) (a
, ) t v 2t ? (
, 10071 )
2t v x 2t-
:
v = u + at
s = ut + 0.5 at^2 (s t )
2t
u x 2t + 0.5 x a x (2t)^2 = u x 2t + 0.5 x a x 4t^2 = u x 2t + a x 2t^2 = 2t (u+ at) = 2tv
, , v t-, 2t
) 1 + 2 + 3 + + 998 + 999 + 1000 ?
, , 1000 x 1001 / 2
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
46/117
#i ncl ude
i nt mai n( )
{
i nt n, sum;
scanf ( "%d", &n) ;
sum= ( n * ( n + 1) ) / 2;
pr i nt f ( "Summat i on i s %d\ n", sum) ;
r etur n 0;
}
: .
#i ncl ude
i nt mai n( ){
i nt i , n, sum;
scanf ( "%d", &n) ;
f or( i = 1, sum= 0; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
47/117
{
doubl e cel si us, f ar enhei t ;
pr i nt f ( "Ent er t he temper at ur e i n cel si us: ") ;
scanf ( "%l f ", &cel si us) ;
f ar enhei t = 1. 8 * cel si us + 32;
pr i nt f ( "Temper at ur e i n f ar enhei t i s: %l f \ n", f ar enhei t ) ;
r etur n 0;
}
: .
) (GCD Greatest Common Divisor HCF Highest
Common Factor) (LCM Least Common Multiple)
,
,
a b , x x-
(5 10--5-)a b, x (a
% x == 0 b % x == 0) a b
, x-x-
, x-1 , x a b
?
:#i ncl ude
i nt mai n( )
{
i nt a, b, x, gcd;
scanf ( "%d %d", &a, &b) ;
i f ( a < b) {
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
48/117
x = a;
}
el se {
x = b;
}
f or ( ; x >= 1; x- - ) {
i f ( a % x == 0 && b % x == 0) {
gcd = x;
break;
}
}
pr i nt f ( "GCD i s %d\ n" , gcd) ;
r etur n 0;
}
: .
gcd (break ) break
(efficient) ,
(co-prime) 1
, 1
(division algorithm)
:a 0--a
a b- = b a % b-
, a-b b-a%b , b-
b-a (a-, b-
a-)
#i ncl ude i nt mai n( )
{
i nt a, b, t , x, gcd;
scanf ( "%d %d", &a, &b) ;
i f ( a == 0) gcd = a;
el se i f ( b == 0) gcd = b;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
49/117
el se {
whi l e (b ! = 0) {
t = b;
b = a % b;
a = t ;
}
gcd = a;
}
pr i nt f ( "GCD i s %d\ n" , gcd) ;
r etur n 0;
}
: .
, , ,
x =
Chapter 6
[] - ,
, 100
50%, 25% 25%
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
50/117
:
#i ncl ude
i nt mai n( )
{i nt f t _mar ks, st _mar ks, f i nal _mar ks;
doubl e t otal _marks;
f t _mar ks = 80;
st _mar ks = 74;
f i nal _marks = 97;
t otal _mar ks = f t _mar ks / 4. 0 + st _marks / 4. 0 + f i nal _mar ks / 2. 0;
pr i nt f ( "%0. 0l f \ n", t ot al _marks);
r etur n 0;
}
: .
87 (total_marks = ft_marks / 4.0 + st_marks / 4.0 +
final_marks / 2.0; total_marks = ft_marks / 4 + st_marks / 4 +
final_marks / 2; 86? ?)
! ,
:
#include
int main(){int ft_marks_1, st_marks_1, final_marks_1, ft_marks_2, st_marks_2,final_marks_2, ft_marks_3, st_marks_3, final_marks_3,, ? ? 160
!
(Array)
, C
, char char
int ara[10]; , ara,
ara[0] (, ara[1] ), ara[1],
ara[2], ara[9], ara[i] i+1
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
51/117
#i ncl ude i nt mai n( )
{
i nt ar a[ 5] = {10, 20, 30, 40, 50};
pr i nt f ( "Fi r st el ement : %d\ n", ar a[ 0] ) ;
pr i nt f ( "Thi r d el ement : %d\ n", ar a[ 2] ) ;
r etur n 0;
}
: .
?
:
#i ncl ude
i nt mai n( )
{
i nt ar a[ 5] = {6, 7, 4, 6, 9};
pr i nt f ( "%d\ n", ara[- 1] ) ;
pr i nt f ( "%d\ n", ara[5] ) ;
pr i nt f ( "%d\ n", ar a[ 100] ) ;
r etur n 0;
}
: .
?
(garbage) -1, 5, 100 5
0 4
, ? (ara[0]),
(ara[1]), (ara[2])
#i ncl ude
i nt mai n( )
{
i nt ara[10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
52/117
i nt i ;
f or ( i = 0; i < 10; i ++) {
pr i nt f ( "%d t h el ement i s: %d\ n", i +1, ar a[ i ] ) ;
}
r etur n 0;
}
: .
? , index9 0
,
, , , .. ,
#i ncl ude
i nt mai n( )
{
i nt ar a[ ] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
i nt ar a2[ 10] ;
i nt i , j ;
f or ( i = 0, j = 9; i < 10; i ++, j - - ) {
ar a2[ j ] = ar a[ i ] ;
}
f or ( i = 0; i < 10; i ++) {ar a[ i ] = ara2[ i ] ;
}
f or ( i = 0; i < 10; i ++) {
pr i nt f ( "%d\ n", ara[ i ] ) ;
}
r etur n 0;
}
: .
, -araara2
int temp;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
53/117
temp = ara[9];ara[9] = ara[0];ara[0] = temp;
temp = ara[8];
ara[8] = ara[1];ara[1] = temp;:
#i ncl ude
i nt mai n( )
{
i nt ar a[ ] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
i nt i , j , temp;
f or ( i = 0, j = 9; i < 10; i ++, j - - ) {
t emp = ara[ j ] ;
ar a[ j ] = ara[i ] ;
ara[ i ] = t emp;
}
f or ( i = 0; i < 10; i ++) {
pr i nt f ( "%d\ n", ara[ i ] ) ;
}
r etur n 0;
}
: .
? ?
1020304050
60708090
100
! , (bug),
, (debug) (
)
,
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
54/117
int ft_marks[40], st_marks[40], final_marks[40];double total_marks[40];
1 ( index 0 ) total_marks[34]-
? 35n total_marks[n-1]
:
#i ncl ude
i nt mai n( )
{
i nt f t _marks[ 40] = {83, 86, 97, 95, 93, 95, 86, 52, 49, 41, 42, 47, 90,
59, 63, 86, 40, 46, 92, 56, 51, 48, 67, 49, 42, 90, 42, 83, 47, 95, 69, 82,
82, 58, 69, 67, 53, 56, 71, 62},
st _marks[ 40] = {86, 97, 95, 93, 95, 86, 52, 49, 41, 42, 47, 90, 59, 63,
86, 40, 46, 92, 56, 51, 48, 67, 49, 42, 90, 42, 83, 47, 95, 69, 82, 82, 58,
69, 67, 53, 56, 71, 62, 49},
f i nal _mar ks[ 40] = {87, 64, 91, 43, 89, 66, 58, 73, 99, 81, 100, 64, 55,
69, 85, 81, 80, 67, 88, 71, 62, 78, 58, 66, 98, 75, 86, 90, 80, 85, 100, 64,
55, 69, 85, 81, 80, 67, 88, 71};
i nt i ;
doubl e t otal _marks[ 40] ;
f or ( i = 0; i < 40; i ++) {
t ot al _mar ks[i ] = f t _mar ks[i ] / 4. 0 + st _mar ks[i ] / 4. 0 +
f i nal _marks[i ] / 2. 0;}
f or( i = 1; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
55/117
50-50 100
total_marks
, 50 , 51 100 50 100
total_marks
for(marks = 50; marks
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
56/117
count = 0;
f or ( i = 0; i < 40; i ++) {
i f ( t ot al _mar ks[ i ] == mar ks) {
count ++;
}
}
pr i nt f ( "Marks: %d Count : %d\ n" , marks, count ) ;
}
r etur n 0;
}
: .
- if-
(total_marks[i] == marks) ? 51
40 51 x 40 = 2040
:
#i ncl ude
i nt mai n( ){
i nt i ;
i nt t otal _mar ks[ ] = {86, 78, 94, 68, 92, 78, 64, 62, 72, 61, 72, 66, 65,
65, 80, 72, 62, 68, 81, 62, 56, 68, 58, 56, 82, 70, 74, 78, 76, 84, 88, 73,
62, 66, 76, 70, 67, 65, 77, 63};
i nt marks_count [ 101] ;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
57/117
f or( i = 0; i < 101; i ++) {
marks_count[ i ] = 0;
}
f or ( i = 0; i < 40; i ++) {
marks_count [ t otal _mar ks[ i ] ] ++;
}
f or( i = 50; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
58/117
marks_count [ t otal _mar ks[ i ] ] ++;
f or( j = 0; j
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
59/117
printf, scanf, main
,
printf
scanf, getchar printf, printf, stdio.h
(header) ( printf, scanf )
(#include ) - string.h
, printf,
!
, main , ?
main ,
main
, :
return_type function_name(parameters){
function_bodyreturn value
}return_type: , int,
double void
, ,
return ,
function_name:
square_root sqrt beautiful ,
parameters: -
strlen -(?)
, getchar() main()
(,)
function_body: return value: ,
sqrt()
? x , return x;
int root = sqrt(25); sqrt 25- root
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
60/117
sin, cos, tan sin 300-
0.5 sin , sine
(sin)-
,
#i ncl ude
i nt mai n( )
{
doubl e a, b, c;
a = 2. 5;
b = 2. 5;
c = a + b;
pr i nt f ( "%l f \ n" c) ;
r etur n 0;
}
: .
? 5.000000
main
#i ncl ude i nt add( i nt num1, i nt num2)
{
doubl e sum = num1 + num2;
r et urn sum;
}
i nt mai n( )
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
61/117
{
doubl e a, b, c;
a = b = 2. 5;
c = add(a, b) ;
pr i nt f ( "%l f \ n" , c) ;
r etur n 0;
}
: .
? 4.000000! num1 num2 int
, double 2.5 2 (
?):
i nt add( doubl e num1, doubl e num2)
{
doubl e sum = num1 + num2;
r et urn sum;
}
? 5.000000, ! , a, b-
a = 2.8; b = 2.7; ? 5.500000? (2.8 + 2.7 =
5.5) ? 5.000000?
, int, num1 num2
sum-5.5 double
:
#i ncl ude
doubl e add( doubl e n1, doubl e n2){
doubl e sum = n1 + n2;
r et urn sum;
}
i nt mai n( )
{
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
62/117
doubl e a, b, c;
a = 2. 8;
b = 2. 7;
c = add(a, b) ;
pr i nt f ( "%l f \ n" , c) ;
r etur n 0;
}
: .
add main :
#i ncl ude
i nt mai n( )
{
doubl e a = 2. 8, b = 2. 7, c;c = add(a, b) ;
pr i nt f ( "%l f \ n" , c) ;
r etur n 0;
}
doubl e add( doubl e n1, doubl e n2)
{
doubl e sum = n1 + n2;
r et urn sum;
}
: .
, : "error: add was not declared in this
scope", add , main
add (prototype) :
double add(double n1, double n2);
:
return_type function_name (parameters) ;
, :
#i ncl ude
doubl e add( doubl e x, doubl e y) ;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
63/117
i nt mai n( )
{
doubl e a = 2. 8, b = 2. 7, c;
c = add(a, b) ;
pr i nt f ( "%l f \ n" , c) ;
r etur n 0;
}
doubl e add( doubl e n1, doubl e n2)
{
doubl e sum = n1 + n2;
r et urn sum;
}
: .
-
#i ncl ude
i nt t est_f unct i on( i nt x)
{
i nt y = x;
x = 2 * y;
return (x * y);
}
i nt mai n( )
{i nt x = 10, y = 20, z = 30;
z = t est _f unct i on( x) ;
pr i nt f ( "%d %d %d\ n", x, y, z) ;
r etur n 0;
}
: .
? ,
:20 10 200 (x = 20, y = 10, z = 200)? x, y- test_function- x- 10 ,
y- y-10x-2 * y 20
x * y (, 20 * 10 200) z-200
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
64/117
, : 10 20 200 (x = 10, y = 20, z = 200)?
z- , 200 z-, x y-
test_function- x, y- main x, y- -
(local variable) main x, y-
test_function x, y- -
, ,
(global)
:
#i ncl ude
doubl e pi = 3. 14;
voi d my_f nc( ) {
pi = 3. 1416; / * pi - */
ret urn; / * voi d return; */
}
i nt mai n( ) {
pr i nt f ( "%l f \ n" , pi ) ; / * pi - 3. 14 */
my_f nc( ) ;
pr i nt f ( "%l f \ n" , pi ) ; / * pi - 3. 1416 my_f nc
*/
r etur n 0;
}
my_fnc pi (double pi;),
pi-
, ?int find_max(int ara[], int n) { /* ,
,
, int ara[11] */
int max = ara[0]; /*
maxmax-
max- max */
int i;for(i = 1; i < n; i++) { if (ara[i] > max) {
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
65/117
max = ara[i]; /* ara[i] max- max- ara[i]- */
}}return max; /* */}
? ,
? :
#i ncl ude
i nt f i nd_max( i nt ara[] , i nt n) ;
i nt mai n( )
{
i nt ar a[ ] = {- 100, 0, 53, 22, 83, 23, 89, - 132, 201, 3, 85};
i nt n = 11;
i nt max = f i nd_max( ara, n) ;
pr i nt f ( "%d\ n", max) ;
r etur n 0;
}
i nt f i nd_max( i nt ara[] , i nt n)
{
i nt max = ara[0] ;
i nt i ;
f or ( i = 1; i < n; i ++) {
i f ( ar a[ i ] > max) {
max = ara[ i ] ;
}
}
r et urn max;
}
: .
find_min find_sum,
find_average
(pass, ) ,
()
:
#i ncl ude
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
66/117
voi d t est_f uncti on( i nt ara[] )
{
ara[0] = 100;
return;
}
i nt mai n( )
{
i nt ar a [ ] = {1, 2, 3, 4, 5};
pr i nt f ( "%d\ n", ara[0] ) ;
t est _f uncti on( ar a) ;
pr i nt f ( "%d\ n", ara[0] ) ;
r etur n 0;
}
: .
? printf1 , printf? test_function- 100
, ara[0]-100, -, 1
100,
,
?
Chapter 8
[]
'?' - :
N ()-, ?
(1 100, 10 1000, -1000 100000)
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
67/117
, 1 1000- '
N-?' ( 1? 2? ... 999?,
1000?)
, 1 1000-50:) 500-, ?
) 250-, ?
) 125-, ?
) 62-, ?
) 31-, ?
) 46-, ?
) 54-, ?
) 50-, ? !
?
1 1000 1 500 1 250, 1 125, 1 62, 31
62, 46 62, 46 54
: (low, high, N): (, (low), (high)(N))
1: mid = (low + high) / 2
2: mid N-5-
3: N, mid-, low = mid + 1. 1-
4: N, mid-, high = mid - 1. 1-
5: (mid)
?
int ara[] = {1, 4, 6, 8, 9, 11, 14, 15, 20, 25, 33 83, 87, 97, 99, 100};
low high-? low = 1 high = 100 ?
,
ara-0 15
-
low_indx = 0;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
68/117
high_indx = 15;
97
num = 97;
, num ara-?
,
()
whi l e( 1) {
mi d_i ndx = ( l ow_i ndx + hi gh_i ndx) / 2;
i f ( num == ar a[ mi d_i ndx]) {
/ * num ara[ mi d_i ndx] - , */
break;
}i f ( num < ar a[ mi d_i ndx]) {
/ * num ara[ mi d_i ndx] - , l ow_i ndx mi d_i ndx 1
*/
hi gh_i ndx = mi d_i ndx 1;
}
el se {
/ * num ara[ mi d_i ndx] - , mi d_i ndx + 1 hi gh_i ndx
*/
l ow_i ndx = mi d_i ndx + 1;
}
}
- ,
while(1) 1 ara-
, ara- ?
low high- low- high-,
low high , low- high-
low high,
, -ara[mid_indx]
:
#i ncl ude
i nt mai n( )
{
i nt ar a[ ] = {1, 4, 6, 8, 9, 11, 14, 15, 20, 25, 33 83, 87, 97, 99, 100};
i nt l ow_i ndx = 0;
i nt hi gh_i ndx = 15;
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
69/117
i nt mi d_i ndx;
i nt num = 97;
whi l e ( l ow_i ndx hi gh_i ndx) {
pr i nt f ( "%d i s not i n t he ar r ay\ n", num) ;}
el se {
pr i nt f ( "%d i s f ound i n t he ar r ay. I t i s t he %d t h el ement of t he
ar r ay. \ n", ar a[ mi d_i ndx] , mi d_i ndx);
}
r etur n 0;
}
: .
, :
http://video.franklin.edu/Franklin/Math/170/common/mod01/binarySearchAlg.h
tml
Chapter 9
[] (string) string , ,
- ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
70/117
character string
- char
:
char count r y[11] = {' B' , ' a' , ' n' , ' g' , ' l ' , ' a' , ' d' , ' e' , ' s' , ' h' , ' \ 0' };
char count r y[ ] = {' B' , ' a' , ' n' , ' g' , ' l ' , ' a' , ' d' , ' e' , ' s' , ' h' , ' \ 0' };
char countr y[ ] = "Bangl adesh";
char *countr y = "Bangl adesh" ;
Null character ('\0')
,
Null character
(pointer)
#i ncl ude
i nt mai n( )
{
char count r y[ ] = {' B' , ' a' , ' n' , ' g' , ' l ' , ' a' , ' d' , ' e' , ' s' , ' h' ,
' \ 0' };
pr i nt f ( "%s\ n", count r y) ;r etur n 0;
}
: .
printf- %s '\0'
#i ncl ude
i nt mai n( ){
char count r y[ ] = {' B' , ' a' , ' n' , ' g' , ' l ' , ' a' , ' d' , ' e' , ' s' , ' h' , ' ' ,
' i ' , ' s' , ' ' , ' m' , ' y' , ' ' , ' c' , ' o' , ' u' , ' n' , ' t ' , ' r ' , ' y' };
pr i nt f ( "%s\ n", count r y) ;
r etur n 0;
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
71/117
: .
? ?
#i ncl ude i nt mai n( )
{
char count r y[ ] = {' B' , ' a' , ' n' , ' g' , ' l ' , ' a' , ' d' , ' e' , ' s' , ' h' ,
' \ 0' , ' i ' , ' s' , ' ' , ' m' , ' y' , ' ' , ' c' , ' o' , ' u' , ' n' , ' t ' , ' r ' , ' y' };
pr i nt f ( "%s\ n", count r y) ;
r etur n 0;
}
: .
'\0'
( capital letter
uppercase character)
, 'A'- 65, 'B'- 66, 'C'- 67...
'Z'- 90 'a' 97, 'b' 98 ... 'z' 122
: if(ch >= 'A' && ch = 65 && ch
= 'a' && ch = 97 && ch
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
72/117
f or ( i = 0; i < l engt h; i ++) {
i f ( count r y[ i ] >= 97 && count r y[ i ]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
73/117
}
i nt mai n( )
{
char count r y[100] ;
i nt l engt h;
whi l e( 1 == scanf ( "%s" , count r y) ) {
l engt h = st r i ng_l engt h( count r y);
pr i nt f ( "l engt h: %d\ n", l engt h) ;
}
r etur n 0;
}
: .
scanf %s
scanf ,
, scanf: scanf("%d%d", &n1, &n2); : value = scanf("%d %d", &n1,
&n2);value-2 while(1 == scanf("%s", country))
, country- scanf, 1 ,
(1 == 1),
country- &&country
%s (: , ) ,
scanf, this is scanf this
, scanf, is
gets :
#i ncl ude
i nt mai n( )
{
char ara[ 100] ;
whi l e( NULL != get s( ar a) ) {
pr i nt f ( "%s\ n", ara);
}
r etur n 0;
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
74/117
: .
ctrl + z ( - ctrl z ) , ctrl + d
ctrl + z ctrl + d gets NULL char ara[100];
100
string_length
:
i nt st r i ng_l engt h( char st r[ ] )
{
i nt i ;
f or( i = 0; str [ i ] != ' \ 0' ; i ++) ;
return i ;
}
string_length for while
concatenate "bangla"
"desh" "bangladesh"
: char str1[] = "bangla", str2[] = "desh", str3[12];
str3"bangladesh" :
str3 = str1 + str2;
''- str1-str3 ,
str2-str3
#i ncl ude
i nt mai n( )
{
char st r 1[ ] = "bangl a", st r 2[ ] = "desh", st r 3[ 12] ;
i nt i , j , l engt h1 = 6, l engt h2 = 4;
f or ( i = 0, j = 0; i < l engt h1; i ++, j ++) {
str3[ j ] = s t r1[ i ] ;
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
75/117
f or ( i = 0, j = 0; i < l engt h2; i ++, j ++) {
str3[ j ] = s t r2[ i ] ;
}
st r 3[ j ] = ' \ 0' ;
pr i nt f ( "%s\ n", str 3) ;
r etur n 0;
}
: .
? bangladeshdesh
f or ( i = 0, j = 0; i < l engt h1; i ++, j ++) {
str3[ j ] = s t r1[ i ] ;
}
i- 0 i str1- j str3-
j- 0 str1-str3 i j-1
(i++, j++) i j 6
str2 str3- str2- i ,
0 j- 0 j- 0
str2- (0) str3- (0) ,
str2-str3- j-0 :
f or ( i = 0; i < l engt h2; i ++, j ++) {
str3[ j ] = s t r2[ i ] ;
}
str3- '\0' (str3[j] = '\0';)
,
, , >, =,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
76/117
i nt st r i ng_compar e( char a[ ] , char b[ ] )
{
}
a- b-, a- b-
a-b-, a, b-
-1 a- b-
, 1 a, b-?
0
i nt st r i ng_compar e( char a[ ] , char b[ ] )
{
i nt i , j ;
f or( i = 0; a[ i ] ! = ' \ 0' && b[ i ] ! = ' \ 0' ; i ++) {
i f ( a[ i ] < b[ i ] ) {
r et ur n - 1;
}
i f ( a[ i ] > b[ i ] ) {
r et ur n 1;
}
}
i f ( st r i ng_l engt h( a) == st r i ng_l engt h( b) ) {
r etur n 0;
}
i f ( str i ng_l engt h( a) < str i ng_l engt h( b) ) {
r et ur n - 1;
}
i f ( str i ng_l engt h( a) > str i ng_l engt h( b) ) {
r etur n 1;
}
}
, string.h
- (: strcmp, strlen, strcpy )
,
,
( )
1000
(punctuation)
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
77/117
, ? , scanf("%s")
gets() ? , 'a' 'z', 'A' 'Z' '0' '9'
, ?-
is_word_started 0 ,
1 0 (is_word_started- 1)
'a' 'z' 'A' 'Z', '0' '9' ,
,
#i ncl ude
#i ncl ude
i nt mai n( )
{
char s[ 1002] , word[ 100] ;
i nt i , j , l engt h, i s_word_st art ed;
gets(s);
l engt h = st r l en( s) ;
i s_word_st art ed = 0;
f or ( i = 0, j = 0; i < l engt h; i ++) {
i f ( s[ i ] >= ' a' && s[i ] = ' A' && s[ i ]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
78/117
j ++;
}
el se i f ( s[ i ] >= ' 0' && s[ i ] = 'a' && s[i]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
79/117
is_word_started- 1 word[j] s[i]- j-
else if (s[i] >= 'A' && s[i] = '0' && s[i] = 'A' && s[i] = '0' && s[i] = ' a' && s[i ]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
80/117
i f ( i s_wor d_st ar t ed == 0) {
i s_word_st art ed = 1;
ch = ' A' + s[i ] - ' a' ;
pr i nt f ( "%c", ch) ;
}
el se {
pr i nt f ( "%c", s [ i ] ) ;
}
}
el se i f ( ( s[ i ] >= ' A' && s[ i ] = ' 0' && s[ i ]
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
81/117
1 -
#i ncl ude
i nt i s_pr i me( i nt n)
{
i nt i ;
i f ( n < 2) {
r etur n 0;
}
f or ( i = 2; i < n; i ++) {
i f ( n % i == 0) {
r et ur n 0;
}
}
r etur n 1;
}
i nt mai n( )
{
i nt n;
whi l e( 1) {
pr i nt f ( "Pl ease ent er a number ( ent er 0 t o exi t ) : ") ;
scanf ( "%d" , &n) ;
i f ( n == 0) {
break;
}
i f ( 1 == i s_pri me( n) ) {
pr i nt f ( "%d i s a pr i me number . \ n", n) ;
}
el se {
pr i nt f ( "%d i s not a pr i me number . \ n" , n) ;
}
}
r etur n 0;
}
: .
nn2 n-
1 n ,
0
n, n
1 ! -
(efficient)
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
82/117
2147483647 21474836472
2147483646
2 n-1 2
n/2
2 , 2(4, 6, 8, )
:
i nt i s_pr i me( i nt n)
{
i nt i ;
i f ( n < 2) {
r etur n 0;
}
i f ( n == 2) {
r etur n 1;}
i f ( n % 2 == 0) {
r etur n 0;
}
f or ( i = 3; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
83/117
}
i f ( n % 2 == 0) {
r etur n 0;
}
r oot = sqr t ( n) ;
f or ( i = 3; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
84/117
2-(2 , 2- ) : 2, 3, 5, 7, 9, 11,
13, 15, 17, 19 , 21, 23, 25, 27, 29, 31, 33, 35, 37, 39. 3-
(3- ) 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37.
5-(5 ) 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37.
7 37- 7-
7- ? 7-14, 21, 28, 35 7- 7-
( 2 120
):
, ara
, n- ( ) ara[n]
ara[n]- 1 , n ara[n]- 0 n
:
: , n1
: 1 1,
: 2 m , (0)
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
85/117
m-m-n-
#i ncl ude
#i ncl ude
const i nt si ze = 40;
i nt ara[ s i ze] ;
voi d pr i nt _ar a( )
{
i nt i ;
f or ( i = 2; i < si ze; i ++) {
pr i nt f ( "%4d", ara[i ] ) ;
}
pr i nt f ( " \ n" ) ;f or ( i = 2; i < si ze; i ++) {
pr i nt f ( " - - - - " ) ;
}
pr i nt f ( " \ n" ) ;
f or ( i = 2; i < si ze; i ++) {
pr i nt f ( "%4d", i ) ;
}
pr i nt f ( " \ n\ n\ n") ;
}
voi d si eve( )
{
i nt i , j , r oot ;
f or ( i = 2; i < si ze; i ++) {
ar a[ i ] = 1;
}
r oot = sqr t ( si ze) ;
pr i nt _ara( ) ;
f or ( i = 2; i
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
86/117
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
87/117
10000 sieve
? , ,
,
,
0 1 sieve
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
88/117
Chapter 11
[] ? -
, ,
, -
- ,
, -:
R o l l 1: R o l l 2: R o l l 3: R o l l 4: R o l l 5: R o l l 6: R o l l 7: R o l l 8: R o l l 9: R o l l :
F i r s t
t e r m i n a l e x a m 8 0 7 0 9 2 7 8 5 8 8 3 8 5 6 6 9 9 8 1
S e c o n d
t e r m i n a l e x a m 7 5 6 7 5 5 1 0 0 9 1 8 4 7 9 6 1 9 0 9 7
F i n a l e x a m 9 8 6 7 7 5 8 9 8 1 8 3 8 0 9 0 8 8 7 7
T o t a l m a r k s
Total Marks , 25%,
25% 50% ,
4 (row) 10 , -, -
, - - 2-D
()
2-D : data_type array_name [number of rows][number of
columns];marks 2-D , : int marks[4][10];
, marks[0], marks[1], marks[2]
marks[3] marks[0][0] -, marks[0][1] - ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
89/117
marks[0][5] -, marks[1][0] -, marks[2][3]
-,
, 10 ? marks[0][0]
?
marks [0][0]- 1- marks[1][9]- 10-
:
i nt marks[ 4] [ 10] = {{80, 70, 92, 78, 58, 83, 85, 66, 99, 81}, {75, 67, 55,
100, 91, 84, 79, 61, 90, 97}, {98, 67, 75, 89, 81, 83, 80, 90, 88, 77}, {0,
0, 0, 0, 0, 0, 0, 0, 0, 0}};
marks[0]
, marks[1]- , marks[2]- marks[3](, 0 )
#i ncl ude
i nt mai n( )
{
i nt marks[ 4] [ 10] = {{80, 70, 92, 78, 58, 83, 85, 66, 99, 81}, {75, 67,
55, 100, 91, 84, 79, 61, 90, 97}, {98, 67, 75, 89, 81, 83, 80, 90, 88, 77},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
i nt col ;
f or( col = 0; col < 10; col ++) {
mar ks[3] [ col ] = mar ks[0] [ col ] / 4. 0 + mar ks[1] [ col ] / 4. 0 +
mar ks[ 2] [ col ] / 2. 0;
pr i nt f ( "Rol l NO: %d Tot al Mar ks: %d\ n" , col + 1, mar ks[3] [ col ] ) ;
}
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
90/117
?
i nt mar ks[4] [ 10] ;
i nt i , j ;f or ( i = 0; i < 4; i ++) {
f or ( j = 0; j < 10; j ++) {
scanf ( "%d", &ara[i ] [ j ] ) ;
}
}
-
i = 0, - j = 0 9 , i = 1 ()-
j = 0 9 ()
1 10 2-D
-, - -?
, ,
#i ncl ude
i nt mai n( )
{
i nt namt a[10] [ 10] ;i nt row, col ;
f or ( r ow = 0; r ow < 10; r ow++) {
f or( col = 0; col < 10; col ++) {
namt a[r ow] [ col ] = ( r ow + 1) * ( col + 1) ;
}
}
f or ( r ow = 0; r ow < 10; r ow++) {
f or( col = 0; col < 10; col ++) {
pr i nt f ( "%d x %d = %d\ n" , ( r ow + 1) , ( col + 1) , namt a[r ow] [ col ] ) ;
}pr i nt f ( " \ n" ) ;
}
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
91/117
-,
namta
, ,
,
, , , ? char type
: char country[] = "Bangladesh";2-
D ? ?
, 100 ,
100,
#i ncl ude
i nt mai n( ){
char saar c[ 7] [ 100] = {"Bangl adesh", "I ndi a", "Paki st an" , "Sr i Lanka",
"Nepal ", "Bhut an" , "Mal di ves"};
i nt r ow;
f or ( r ow = 0; r ow < 7; r ow++) {
pr i nt f ( "%s\ n", saar c[r ow] ) ;
}
r etur n 0;
}
: .
, saarc[3][3], saarc[0][5] saarc[5][0]
? ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
92/117
, :
#i ncl ude
#i ncl ude
i nt mai n( ){
char saar c[ 7] [ 100] = {"Bangl adesh", "I ndi a", "Paki st an" , "Sr i Lanka",
"Nepal ", "Bhut an" , "Mal di ves"};
i nt r ow, col , name_l engt h;
f or ( r ow = 0; r ow < 7; r ow++) {
name_l engt h = st r l en( saar c[ r ow] ) ;
f or( col = 0; col < name_l engt h; col ++) {
pri nt f ( "%c ", saar c[r ow] [ col ] ) ;
}
pr i nt f ( " \ n" ) ;}
r etur n 0;
}
: .
,
#i ncl ude
#i ncl ude i nt mai n( )
{
char saar c[ 7] [ 100] = {"Bangl adesh", "I ndi a", "Paki st an" , "Sr i Lanka",
"Nepal ", "Bhut an" , "Mal di ves"};
i nt r ow, col , name_l engt h;
f or ( r ow = 0; r ow < 7; r ow++) {
name_l engt h = st r l en( saar c[ r ow] ) ;
f or( col = 0; col < name_l engt h; col ++) {
pr i nt f ( "( %d, %d) = %c, ", r ow, col , saar c[ r ow] [ col ] ) ;
}pr i nt f ( " \ n" ) ;
}
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
93/117
6 4 7 8 9
3 7 1 9 9
8 6 4 2 7
2 4 2 5 9
4 1 6 7 3
2-D -
:
Sum of row 1: 34
Sum of row 2: 29Sum of row 3: 27Sum of row 4: 22Sum of row 5: 21:
Sum of column 1: 23
Sum of column 2: 22Sum of column 3: 20Sum of column 4: 31Sum of column 5: 37
,
- !
6 3 8 2 4
4 7 6 4 1
7 1 4 2 6
8 9 2 5 7
9 9 7 9 3
, -: 6,
4, 7, 8, 9: 6, 4, 7, 8, 9
, 5 x 5 (5 5 ), 5 x 5
,
: 1, 2, 3, 4, 5
1, 2, 3, 4, 5 ? ,
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
94/117
#i ncl ude
#i ncl ude
i nt mai n( )
{i nt ar a1[ 5] [ 5] = {{1, 2, 3, 4, 5}, {10, 20, 30, 40, 50}, {100, 200, 300,
400, 500}, {1000, 2000, 3000, 4000, 5000}, {10000, 20000, 30000, 40000,
50000}};
i nt ara2[ 5] [ 5] ;
i nt r , c;
pr i nt f ( "Cont ent of f i rst arr ay ( ara1) : \ n") ;
f or ( r = 0; r < 5; r ++) {
f or ( c = 0; c < 5; c++) {
pri nt f ( "%d ", ara1[ r] [ c]) ;
}pr i nt f ( " \ n" ) ;
}
pr i nt f ( " \ n" ) ;
/ / now st ar t copy
f or ( r = 0; r < 5; r ++) {
f or ( c = 0; c < 5; c++) {
ar a2[ c][ r ] = ar a1[ r ] [ c];
}
}
pr i nt f ( "Cont ent of second ar r ay ( ar a2) : \ n") ;f or ( r = 0; r < 5; r ++) {
f or ( c = 0; c < 5; c++) {
pri nt f ( "%d ", ara2[ r] [ c]) ;
}
pr i nt f ( " \ n" ) ;
}
r etur n 0;
}
: .
2-D ,
() 2-D 3-D, 4-D
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
95/117
Chapter 12
[]
- d e c i ma l( )
b i n a r y( ) 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,
8 ,9 ,0 1
: 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 19, 20, 21, , 98, 99, 100, 101 ... , ( )
, ( 1 0 - 1
,9 0 9 ,0 9 - 1 0 ), 0 9
( 1 0 - 1 )
:0 ,1 ,1 0 ,1 1 ,1 0 0 ,1 0 1 ,1 1 0 ,1 1 1 ,1 0 0 0 ,1 0 0 1 ,
1 0 1 0 ,1 0 1 1 ... , 0 - 1 ( )
, , , , , ,
?
1 0 ,1 0 0 ,1 0 0 0 , (1 0 ),
(1 0 0 ), (1 0 0 0 ), (1 0 0 0 0 )
(1 0 0 =1 ) , (1 0 1 =1 0 ) , (1 0 2 =1 0 0 )
, (2 0 =1 ) , (2 1 =2 ) ,(2 2 =4 )
,
,,, , ,
:0 +0 =0 ,0 +1 =1 ,1 +0 =1 ,
1 +1 =1 0
,1 +1 , (1 0 ) , , 1 0 1 +1 0 1 =?
,1 +1 =1 0 0 1 c a r r y( )
,0 +0 =0 , 0 - 1 1
,1 +1 =1 0 (c a r r y ) 0 1
:1 0 1 0 1 0 1 1 +1 0 1 1 =? 1 0 1 1 0 ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
96/117
0 0 =0 ,1 0 =1 ,1 1 =0 ,
0 1 =1
,2 3 1 5 ?3 - 1 (1
),1 3 5 =8 , 1 - 0
1 0 - , 1 0 (),
( )
1 1 0 1 0 1 =?
0 1 1 ,1 1 0 1 -
1 1 =0 , 1 1 =0 :0 0 1 1 - -
x 1 0 - , x
2 - 1 9 0 3 1 x 1 0: = 3 9 x 1 0+ 2 0 x 1 0+ 1 3 x+
1 0 0
1 0 1 1 0 1 x 2: = 4 0 x 2+ 3 1 x 2+ 2 1 x 2+ 1 0 x 2+ 0
E x p o n e n t i a l E x p r e s s i o n
, :
1 0 1 1 0 1 x 2=
4
0 x 2+
3
1 x 2+
2
1 x 2+
1
0 x 2+
0
1 x 1 6 0 x 8 1 x= + +4 1 x 2 0 x 1+ +=1 6 +0 +4 +2 +0 =2 2
1 0 1 1 0 =2 2 ,
, ?
c h a r b i n a r y 1 0 1 1 0[] = " ";
i n t l e n 5= ; // 5
i n t d e c i ma l 0= ; // , 0
2
b i n a r y 0[ ] '1 ',- ?- 4
, 0
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
97/117
i nt posi t i on = 4;
i nt i ndx;
f or( i ndx = 0; i ndx < l en; i ndx++) {
deci mal = deci mal + pow( 2, posi t i on) ;
posi t i on- - ;
}
,p o w
ma t h h. a b - p o w a b( , ) :
#i ncl ude
#i ncl ude
#i ncl ude
i nt mai n( )
{
char bi nar y[65] ;i nt l en, deci mal , power , i ;
pr i nt f ( "Ent er t he bi nar y number : ") ;
scanf ( "%s", bi nar y) ;
deci mal = 0;
l en = st r l en( bi nar y) ;
power = l en - 1;
f or ( i = 0; i < l en; i ++) {
deci mal += pow( 2, power ) ;
power - - ;
}pr i nt f ( "Deci mal val ue i s %d\ n" , deci mal ) ;
r etur n 0;
}
: .
1 0 1 1 0 , ? 3 1
2 2
p o w 2 p o s i t i o n( , ) p o s i t i o n -
, :
d e c i ma l b i n a r y i p o w 2 p o w e r+= [ ] * ( , );
?1 0 1 1 0 - ,
:['1 ','0 ','1 ','1 ','0 '] b i n a r y 0[ ]- p o w 2( ,
4 b i n a r y 1), [ ]- pow(2, 3), ,b i n a r y 4[ ]- p o w 2 0( , )
1 0 1 1 0 - ?
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
98/117
D e c i ma l v a l u e i s 1 5 1 0 ?
? ,
d e c i ma l b i n a r y i p o w 2 p o w e r+= [ ] * ( , );
b i n a r y i, [ ]- '0 ''1 '( '0 ' '1 ')
'0 ' 4 8 '1 ' 4 9
'0 '0 '1 '1 ?
'0 ' '0 '=4 8 4 8 =0
'1 ' '0 '=4 9 4 8 =1
?b i n a r y i[ ] b i n a r y i( [ ] '0 ')
( )
9 5
n - ,2 n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
99/117
:
9 5 /2 4 7 1
4 7 /2 2 3 1
2 3 /2 1 1 1
1 1 /2 5 1
5 /2 2 1
2 /2 1 0
1 /2 0 1
:1 0 1 1 1 1 1 0 ma i n
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
100/117
Chapter 13
[]
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
101/117
printf,
, 'c' ' ' ()
(palindrome) , ? ( )
: madam madam
:
--Palindromes
--The Palindrome Day Song! (01/11/10)
?
, :
#i ncl ude
#i ncl ude
i nt mai n( )
{
char word[ 80] , r everse_word[ 80] ;
i nt i , j , l en;
scanf ( "%s" , wor d) ;l en = st r l en( wor d) ;
f or( i = 0, j = l en - 1; i < l en; i ++, j - - ) {
r ever se_wor d[ i ] = wor d[ j ] ;
}
r ever se_wor d[ i ] = ' \ 0' ;
pr i nt f ( "%s\ n", r ever se_wor d) ;
i f ( 0 == st r cmp( word, r everse_word) ) {
pr i nt f ( "%s i s a pal i ndr ome. \ n", wor d) ;
}
el se {pr i nt f ( "%s i s not a pal i ndr ome. \ n", wor d) ;
}
r etur n 0;
}
: .
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
102/117
! ,
, strcmp
, , ,
(factorial) ?
n -n! n! = n * (n 1) * (n
2) * * 3 * 2 * 14! = 4 * 3 * 2 * 1 = 246! = 6 * 5 * 4 * 3 * 2 * 1
= 720 1! = 1 0! = 1 (0- , 0- 1
) ,
int
12- (
)12-
n ( 1 < n < 100, n- 2
99 )-
, , 5! = 120 = 2 * 2 * 2 * 3 * 52 3 , 3 1 5 1
5 : 5! = (2, 3), (3, 1), (5, 1)n-
? n-99
12- n!-
- 2 99
- ,
,
: int ara[] = {3, 1, 5, 2, 4}, ,
ara[] = {1, 2, 3, 4, 5}
, : 3, 1, 5, 2, 4
? : 1
: 3, 5, 2, 41-: 1, 23, 5, 4
3: 1, 2, 3 5, 443-
: 1, 2, 3, 4, 54-1, 2, 3, 4, 5
(sorting) -
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
103/117
,
, -
?: int ara1[] = {3, 1, 5, 2, 4};
: int ara2[5];0 int index_2 = 0;
ara2
for(index_2 = 0; index_2 < 5; index_2++) // 0 4
ara1-
minimum = 100000; // ara1-
for (i = 0; i < 5; i++){
if (ara1[i] < minimum)
{
minimum = ara1[i];}}ara1-minimum
ara2 : ara2[index_2] = minimum
ara2-
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
104/117
#i ncl ude
i nt mai n( )
{
i nt ar a1[ ] = {3, 1, 5, 2, 4};
i nt ar a2[ 5] ;
i nt i , mi ni mum, i ndex_2;
f or ( i ndex_2 = 0; i ndex_2 < 5; i ndex_2++) {
mi ni mum = 10000;
f or ( i = 0; i < 5; i ++) {
i f ( ar a1[ i ] < mi ni mum) {
mi ni mum = ara1[ i ] ;
}
}
ar a2[ i ndex_2] = mi ni mum;
}
f or ( i = 0; i < 5; i ++) {pr i nt f ( "%d\ n", ara2[ i ] ) ;
}
r etur n 0;
}
: .
! ? , 1
1
11
11
( ) minimum- 1 ,
1 1 minimum
,
minimum_index:
mi ni mum = 10000;f or ( i = 0; i < 5; i ++) {
i f ( ar a1[ i ] < mi ni mum) {
mi ni mum= ara1[ i ] ;
mi ni mum_i ndex = i ;
}
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
105/117
minimum-ara1[minimum_index]
ara1[minimum_index] = 10000;
:
#i ncl ude
i nt mai n( )
{
i nt ar a1[ ] = {3, 1, 5, 2, 4};
i nt ar a2[ 5] ;
i nt i , mi ni mum, i ndex_2, mi ni mum_i ndex;
f or ( i ndex_2 = 0; i ndex_2 < 5; i ndex_2++) {
mi ni mum = 10000;
f or ( i = 0; i < 5; i ++) {i f ( ar a1[ i ] < mi ni mum) {
mi ni mum = ara1[ i ] ;
mi ni mum_i ndex = i ;
}
}
ar a1[mi ni mum_i ndex] = 10000;
ar a2[ i ndex_2] = mi ni mum;
}
f or ( i = 0; i < 5; i ++) {
pr i nt f ( "%d\ n", ara2[ i ] ) ;}
r etur n 0;
}
: .
, ?
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
106/117
N x N
, , ,
(0 ,0 ) (0 ,1 ) (0 ,2 ) (0 ,3 ) (0 ,4 ) (0 ,5 ) (0 ,6 ) (0 ,7 ) (0 ,8 )
(1 ,0 ) (1 ,2 )(2 ,0 ) (2 ,1 ) R (2 ,2 ) (2 ,3 )
(3 ,0 ) (3 ,2 )
(4 ,0 )
(5 ,0 )
(6 ,0 )
(7 ,0 )
(8 ,0 ) (8 ,8 )
(0, 0)(0, 8)
(8, 0)(8, 8), (2, 2)
(1, 2) (3, 2) (2, 3) (2, 1)
U (up), D (down), L (left), R (right), S (stop)
, (stop )
?
2-D
- , (x, y) U , x- , y- D , x-, y-
R y-, x- L y-, x-
:
#i ncl ude
i nt mai n( )
{
i nt x, y;
char c;pr i nt f ( "Pl ease ent er t he i ni t i al posi t i on: ") ;
scanf ( "%d %d", &x, &y) ;
whi l e ( 1) {
scanf ( "%c", &c) ;
i f ( c == ' S' ) {
break;
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
107/117
el se i f ( c == ' U' ) {
x - - ;
}
el se i f ( c == ' D' ) {
x++;
}
el se i f ( c == ' R' ) {
y++;
}
el se i f ( c == ' L' ) {
y - - ;
}
}
pr i nt f ( "Fi nal posi t i on of t he r obot i s: %d, %d\ n", x, y) ;
r etur n 0;
}: .
:
Please enter the initial position: 2 2DR
DRSFinal position of the robot is: 4, 4
(), ? , (0, 4)
(blocked) (0, 3) 'R' ,
((0, 4) )
, 2-D
? 1
0
10 x 10 2-D :
int grid[10][10];
f or ( i = 0; i < 10; i ++) {
f or ( j = 0; j < 10; j ++) {
gr i d[ i ] [ j ] = 1;
}
}
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
108/117
:
pr i nt f ( "Pl ease ent er t he number of bl ocked cel l s: ") ;
scanf ( "%d", &n) ;pr i nt f ( "Now ent er t he cel l s: ") ;
f or ( i = 0; i < n; i ++) {
scanf ( "%d %d", &x, &y) ;
gr i d[ x][ y] = 0;
}
,
if (grid[x][y] == 1)
{, (x, y)
}
.. : http://jontrogonok.com/?p=12
Bonus Collection From Tj : (
, ) Published by in on -,
-
, , ,
,
, ; ,
,
, ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
109/117
, ?
-
, ,
, , ,
?
, ,
, , , , , , , ,
,, , (, , , , , ) , ,
( ) , , [] (, , , , ), , [, ]
(, , , ), [, , ] (, , ), [, , , ] (, ), [, , , , ] , ( , !!)
, [, , , , , ] ,
( ) -
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
110/117
, ? ,
x
, x
? ,
,
? ? ,
?
,
, ,
, ,
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
111/117
(, , , , , ) , (, , , , , ) (, ) , (, ) (, ,
, , , ) (, ) (, ) (, , ,, , )
, ,
(, , , , , ) -> (, , , , , ) ( )(, , , , , ) -> (, , , , , ) ()(, , , , , ) -> (, , , , , ) ( )(, , , , , ) -> (, , , , , ) () , ,
(, , , , , ) -> ( , , , , , ) ()(, , , , , ) -> (, , , , , ) ( )(, , , , , ) -> (, , , , , ) () , , (, ,
, , , )
( )
,
,
, , , (,
, , , , ) (, , )(,
, )
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
112/117
, ,
(, , ) ? , , ,
(, )() , (, ) , (, ) ()
? , , ,
,
, (, , )
, , (, , )
, (, , ), (, , )
(, , ), (, , ), [ ] -> (, , ), (, ), [] ( )(, , ), (, ), [] -> (, ), (, ), [, ] ( )(, ), (, ), [, ]->(, ), (), [, , ](, ), (), [, , ] -> (), (), [, , ,](), (), [, , ,]-> ( ), (), [, , , , ]( ), (), [, , ,]-> ( ), ( ), [, , , , , ], , , ,
x log(),
( ),
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
113/117
- , ,
Chapter 14
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
114/117
[ ] ,
, , !
, , ?
, -
(skill)
,
, , , -
(C++) (Java), (C#), (PHP)
(Python)
) ,
) IDE ,
) ,
) ,
) (OOP Object Oriented Programming) ,
) ,
) (Communication Skills),
) ,
) ,)
, ,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
115/117
Bonus 1
[]
-
, -,
- (IOI International Olympiad in
Informatics) 1989
2009
() IOI (ACM ICPC ACM
International Collegiate Programming Contest)
,
ICPC Regional Contest-
ICPC Regional Contest-
ICPC Regional Contest-
(ICPC World Finals) 1998
: http://en.wikipedia.org/wiki/ACM_ICPC_Dhaka_Site
-- ,
Google Code Jam
(http://code.google.com/codejam), Topcoder (http://www.topcoder.com/tc)
Codechef (http://www.codechef.com/),
,
,
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
116/117
Bonus 2
[] , ,
, , ,
,
Telecommuting
,
,
,
,
--(bid)
,
,
,
,
, ,
,
Bonus 3
[
]
, Herbert Schildt- Teach
Yourself C Brian Kernighan Dennis Ritchie- The C
Programming Language , Dennis Ritchie,
Stephen G. Kochan-
Programming in C Schaums
Outlines Programming with C
7/28/2019 Tamim Shariar Subeen-(Esho Programming Shikhi)
117/117
Teach Yourself C++
(: Herbert Schildt) Java How to Program (: Paul Deitel and
Harvey Deitel)
, , Discrete Mathematics Kenneth H. Rosen- Discrete Mathematics
Discrete Mathematics
Introduction to
Algorithms (: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and
Clifford Stein)
:
http://projecteuler.net/
, http://www.spoj.pl/
, , , , , ,
http://uva.onlinejudge.org/
http://ace.delos.com/usacogate,
,
http://www.topcoder.com/tc
(!)
http://codeforces.comhttp://www.codechef.com
http://ioinformatics.org
http://cm baylor edu/welcome icpc