Tamim shariar 2nd part(programming book)
-
Upload
ikhtiar-khan-sohan -
Category
Education
-
view
6.616 -
download
2.890
Transcript of Tamim shariar 2nd part(programming book)
-
( - .)
-
:
:
:
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , , , ! , ,
- , , ;
, ! - , ,
, , , ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
()
, , ( )
-
- ? , , '' ,
, , , , , , , , , , , , , , , , , ,
http://cpbook.subeen.com
??http://cpbook.subeen.com
http://cpbook.subeen.com/mailto:[email protected]
-
,
(Loop)
(String)
:
::
-
, ? , , , (0) (1) (user) ,
010,1 , 0, 1 , , ADD(),MUL()0,1, (Fortran),(Basic),(Pascal),(C),,,(C++),(VisualBasic),(Java),(C#),(Perl),(PHP), (Python), (Ruby) , ,
, (logic) ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
,
, , , , (, ) ,
, (),,,,,, ,
,? , gcc Codeblocks(http://www.codeblocks.org/)IDE(IntegratedDevelopmentEnvironment)
-
(:,,) (IDE)
Codeblocks http://www.codeblocks.org DownloadsBinaries (codeblocks13.12mingwsetup.exe) , UbuntuSoftwareCenter(Applications>UbuntuSoftwareCenter)
, , , ,(http://cpbook.subeen.com)
.,
,,
,
??http://cpbook.subeen.com
http://cpbook.subeen.com/http://cpbook.subeen.com/http://www.codeblocks.org/downloads/binaries
-
' ' http://dimikcomputing.com , http://programming-course.appspot.com
http://programming-course.appspot.com/http://dimikcomputing.com/
-
, HelloWorld
Codeblocks ,
.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
.
-
.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
.
-
.No(.)
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
.
Start Programs Codeblocks Applications>Programming
-
.
(.)Showtipsatstartup(tick)FileNewFileEmptyFile(.)
.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
(Save)SaveastypeC/C++files(.)
.
hello.c.c
.
-
#include
intmain(){printf("HelloWorld");
return0;}:.
.
,?,!BuildCompileCurrentFile
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
.
0errors,0warnings,syntax.
.
BuildRun(.) .
-
.
.
, HelloWorldProcessreturned0(0x0)( )executiontime:0.031s0.031,Pressanykeytocontinue. Anykey
HelloWorld
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:#include, :intmain(),() return0; , :
intmain(){return0;}
:printf(HelloWorld); printf() stdio.h(header)(.h)stdio.h,, printf() ,#include,
printf(Hello World);
-
return0; , , (compileerror)
#include,intmain(),{}printfreturn0() (Indentation) , , , (Tab) Codeblocks SettingsEditorTABOptionsTABindentsTABsizeinspaces4(.)
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
.
:Ilovemycountry,Bangladesh
-
,
, ,?! , =
, ,
#include
intmain(){inta;intb;intsum;
a=50;b=60;
sum=a+b;
printf("Sumis%d",sum);
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return0;}:.
, :Sumis110
a,b,sum (variable) a,b,suminta;a (integer) int, , , :inta,b,sum;
:a=50;b=60;a50b60(assign),,a50b60
:sum=a+b;,suma+b,absum(assign)
,printf
printf(Sumis%d,sum);
-
printfSumis%dSumis %d sum %dsum%d, , , ,
:
#include
intmain(){inta,b,sum;
a=50;b=60;
sum=a+b;
printf("Sumis%d",sum);
return0;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
#include
intmain(){inta=50,b=60,sum;
sum=a+b;
printf("Sumis%d",sum);
return0;}:.
?
#include
intmain(){intx,y;
-
x=1;y=x;x=2;
printf("%d",y);
return0;}:.
?12?1,,x1(x=1;)xy(y=x;)y1 x 2 y y=x;'='
:
#include
intmain(){inta=50,b=60,sum;
sum=a+b;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
printf("%d+%d=%d",a,b,sum);
return0;}:.
?printf(%d+%d=%d,a,b,sum);printf(%d+%d=%d,b,a,sum);
,,,, , , ,
,,,int(realnumber),?
#include
intmain(){inta=50.45,b=60,sum;
sum=a+b;
printf("%d+%d=%d",a,b,sum);
-
return0;}:.
a50.45,,mainreturn0;?return0;
:50+60=110
a50,50.45(typecast) doubledouble int, :inta=(int)50.45inta=50.99;a50inta=50.9;a50doubleint
,
#include
intmain(){intn;doublex;
x=10.5;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
n=(int)x;
printf("Valueofnis%d\n",n);printf("Valueofxis%lf\n",x);
return0;}:.
x- - double , %lf (l L) int ?:
#include
intmain(){inta;
a=1000;printf("Valueofais%d",a);
a=21000;printf("Valueofais%d",a);
a=10000000;
-
printf("Valueofais%d",a);
a=10000000;printf("Valueofais%d",a);
a=100020004000503;printf("Valueofais%d",a);
a=4325987632;printf("Valueofais%d",a);
return0;}:.
a? printf printf:printf(Valueofais%d\n,a);printf\n
a , 21474836482147483647 ,intintint(byte)(1byte=8bit),01 (00,01,10,11)32:2324294967296 , 2147483648 1 2147483648021474836472147483648,4294967296 ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
(realnumber) ,,...3,2,1,0,1,2,3...5,3,2.43,0,0.49,2.92( )
#include
intmain(){doublea,b,sum;
a=9.5;b=8.743;
sum=a+b;
printf("Sumis:%lf\n",sum);
printf("Sumis:%0.2lf\n",sum);
return0;}:.:
-
Sumis:18.243000Sumis:18.24
%lf, %0.2lf ( %0.3lf , %0.0lf)double641.7E308(1.7x10308) 1.7E+308 (1.7 x 10308) ,
, , ( ) scanf (- ) :
#include
intmain(){inta,b,sum;
scanf("%d",&a);scanf("%d",&b);
sum=a+b;
printf("Sumis:%d\n",sum);
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return0;}:.
(blank screen) , (space) (enter)
scanf scanf( %d , &a); %d scanf- int ( ) a- (&) , &a a , &a- , a b- scanf :scanf( %d %d , &a, &b); & ? , ,
#include
intmain(){inta,b,sum;
scanf("%d",&a);scanf("%d",b);
sum=a+b;
-
printf("Sumis:%d\n",sum);
return0;}:.
? scanf- %d- %lf
, int double
, , , , ,
, char (character) character , char :#include
intmain()
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
{charch;
printf("Enterthefirstletterofyourname:");scanf("%c",&ch);printf("Thefirstletterofyournameis:%c\n",ch);
return0;}:.
, char printf scanf %c getchar, char :
#include
intmain(){charch;
printf("Enterthefirstletterofyourname:");ch=getchar();printf("Thefirstletterofyournameis:%c\n",ch);
return0;}:.
-
getchar ch char : char c = 'A';
:
#include
intmain(){intnum1,num2;
printf("Pleaseenteranumber:");scanf("%d",&num1);printf("Pleaseenteranothernumber:");scanf("%d",&num2);
printf("%d+%d=%d\n",num1,num2,num1+num2);printf("%d%d=%d\n",num1,num2,num1num2);printf("%d*%d=%d\n",num1,num2,num1*num2);printf("%d/%d=%d\n",num1,num2,num1/num2);
return0;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , num1 num2- , , , printf , num2- 0 printf +, -, *, / char :
#include
intmain(){intnum1,num2,value;charsign;
printf("Pleaseenteranumber:");scanf("%d",&num1);printf("Pleaseenteranothernumber:");scanf("%d",&num2);
value=num1+num2;sign='+';printf("%d%c%d=%d\n",num1,sign,num2,value);
value=num1num2;sign='';printf("%d%c%d=%d\n",num1,sign,num2,value);
-
value=num1*num2;sign='*';printf("%d%c%d=%d\n",num1,sign,num2,value);
value=num1/num2;sign='/';printf("%d%c%d=%d\n",num1,sign,num2,value);
return0;}:.
, ( , - ) , (comment) // /* */
#include
intmain()
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
{//testprogramcomment1printf("Hello");/*WehaveprintedHello,nowweshallprintWorld.Notethatthisisamultilinecomment*/printf("World");//printedworldreturn0;}:.
, ( - ), ? , a z, A Z, 0 9 _( ) () int7d; , sum , y ,
-
,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
' '! -
#include
intmain(){intn;n=10;if(n>=0){printf("Thenumberispositive\n");}else{printf("Thenumberisnegative\n");}return0;}:.
-
? n- (: 0, -10, -2, 5, 988 ) n (positive) (negative) , 'n , n , n ' if else if- () (if- { } ) if- , else- ( ) ,
, ? ' ' >= ' '- - if else- if else , ( ) :
#include
intmain(){intn;n=10;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
- if(n
-
elseif(n>0){printf("Thenumberispositive\n");}elseif(n==0){printf("Thenumberiszero!\n");}return0;}:.
:if(n < 0): n else if(n > 0): , n if(n > 0) else if(n == 0): n > 0 ? n
, , n-
#include
intmain(){
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
intn=10;if(n0){printf("Thenumberispositive\n");}else{printf("Thenumberiszero!\n");}return0;}:.
if else else if , :
#includeintmain(){intnumber=12;if(number>10){printf("Thenumberisgreaterthanten\n");
-
}return0;}:.
?
#include
intmain(){intn=10;
if(n
-
else if else ,
#include
intmain(){intn=10;
if(n
-
number- : number = 5; number 2 : remainder = number % 2; if- remainder- remainder- 0 1 :
#include
intmain(){intnumber,remainder;number=5;remainder=number%2;if(remainder==0){printf("Thenumberiseven\n");}else{printf("Thenumberisodd\n");}return0;}:.
remainder :
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
#include
intmain(){intnumber=9;if(number%2==0){printf("Thenumberiseven\n");}else{printf("Thenumberisodd\n");}return0;}:.
, , ? else
? , (*, /, -)
(small letter lower case letter) (capital letter upper case letter), character 26 lower caseletter 26 upper case letter- , ,
-
charch='p';
if(ch=='a'){printf(%cislowercase\n,ch);}elseif(ch=='A'){printf(%cisuppercase\n,ch);}elseif(ch=='b'){printf(%cislowercase\n,ch);}elseif(ch=='B'){printf(%cisuppercase\n,ch);}elseif(ch=='c'){printf(%cislowercase\n,ch);}elseif(ch=='C'){printf(%cisuppercase\n,ch);}
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
(AND operator) '&&' #include
intmain(){charch='W';
if(ch>='a'&&ch='A'&&ch= 'a' && ch = 'a' ch
-
'z'- A- B- , B- C- 'A' 'Z'- upper case 'A'- 'Z'- if- else if- if-
#include
intmain(){charch='k';
if(ch>='a'&&ch='A'&&ch
-
?
#include
intmain(){intnum=5;
if(num>=1||num= 1) (n
- : ch >= 'a' && ch
-
http://dimikcomputing.com
-
(Loop)
(condition) , 1 10 ( ) , :
#include
intmain(){printf(1\n);printf(2\n);printf(3\n);printf(4\n);printf(5\n);printf(6\n);printf(7\n);printf(8\n);printf(9\n);printf(10\n);
return0;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
1 10 printf() :printf(1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n);
n , 1 n- n- (n = n + 1 , n++ )intn=1;printf(%d\n,n);n=n+1;printf(%d\n,n);n=n+1;printf(%d\n,n);n=n+1;/* */
n 1 printf(%d\n,n);n=n+1; :printf(%d\n,n++);
- , 1 10 1 100, 1000, 10000 ? ,
(loop) ,
-
while for while
#include
intmain(){intn=1;while(n
-
#include
intmain(){intn=1;while(n
-
while(1){...} 1 1 , while(1 == 1){...}
, break
#include
intmain(){intn=1;while(n10){break;}}return0;}:.
? 1 10 while- n 10 , break; , break n- 10 (n++;) n- 11 n > 10 , if
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
break break- , continue; continue continue- :
#include
intmain(){intn=0;
while(n
-
5X1=55X2=105X3=155X4=205X5=255X6=305X7=355X8=405X9=455X10=50
printf :#include
intmain(){intn=5;inti=1;
while(i
-
:
#include
intmain(){intn=5;inti;for(i=1;i
-
for , i-
inti=1;for(;i10){break;}}
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return0;}:.
for 5- (n*i) ? 5 x 3- 5+ 5 + 5 :
#include
intmain(){intm,n=5;inti;
m=0;for(i=1;i
-
, , ,
for 1 20 n- 5 1 20 ( ?) - n- 1 20 n-
#include
intmain(){intn,i;
for(n=1;n
-
for for , (nested loop) , for for while while for while 1,2, 3 (permutation) :
1,2,31,3,22,1,32,3,13,1,23,2,1
, ,
,
#include
intmain(){
- inta,b,c;for(a=1;a
-
2,3,12,3,22,3,33,1,13,1,23,1,33,2,13,2,23,2,33,3,13,3,23,3,3
a- 1 b c- 1 , b c- a, b c b
- for(b=1;b
- b- a- :for (b = 1; b
-
}}}}}
return0;}:.
,
1,2,31,3,22,1,32,3,13,1,23,2,1
, #include
intmain(){inta,b,c;for(a=1;a
- for(c=1;c
-
, , 25 - 01622624182, , , ( ),
01. Go to your bKash Mobile Menu by dialing *247#02. Choose Payment 03. Enter the Merchant bKash Account Number you want to pay to (01622624182)04. Enter the amount you want to pay (25)05. Enter a reference against your payment (cpbook pdf)06. Enter the Counter Number (enter 0)07. Now enter your bKash Mobile Menu PIN to confirm
) *247# ) '' ) 01622624182 ) ( )) cpbook pdf ) ) (PIN)
( )
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, -
) x + y = 15, x y = 5 x y- ?
2x = 20, x = 10 , 2y = 10, y = 5 x + y x y- , x y-
) 4x + 5y = 14, 5x + 6y = 17 x y- ?
:a1x + b1y = c1, a2x + b2y = c2 (substitution) (determinant) ,x = (b2c1 b 1c2) / (a1b2 a 2b1) y = (a1c2 a 2c1) / (a1b2 a 2b1) a1, a2, b1, b2, c1, c2- x y-
, a1, a2, b1, b2, c1, c2 x y-
, :
-
#include
intmain(){doublex,y,x_plus_y,x_minus_y;
printf("Enterthevalueofx+y:");scanf("%lf",&x_plus_y);
printf("Enterthevalueofxy:");scanf("%lf",&x_minus_y);
x=(x_plus_y+x_minus_y)/2;y=(x_plus_yx_minus_y)/2;
printf("x=%0.2lf,y=%0.2lf\n",x,y);
return0;}:.
int double
:
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
#include
intmain(){doublea1,a2,b1,b2,c1,c2,x,y;
printf("a1=");scanf("%lf",&a1);printf("a2=");scanf("%lf",&a2);printf("b1=");scanf("%lf",&b1);printf("b2=");scanf("%lf",&b2);printf("c1=");scanf("%lf",&c1);printf("c2=");scanf("%lf",&c2);
x=(b2*c1b1*c2)/(a1*b2a2*b1);y=(a1*c2a2*c1)/(a1*b2a2*b1);
printf("x=%0.2lf,y=%0.2lf\n",x,y);
return0;}:.
-
! (a1*b2a2*b1) (x- , y- ) , (a1*b2a2*b1)- , ,
#include
intmain(){doublea1,a2,b1,b2,c1,c2,d,x,y;
printf("a1=");scanf("%lf",&a1);printf("a2=");scanf("%lf",&a2);printf("b1=");scanf("%lf",&b1);printf("b2=");scanf("%lf",&b2);printf("c1=");scanf("%lf",&c1);printf("c2=");scanf("%lf",&c2);
d=a1*b2a2*b1;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
if((int)d==0){printf("Valueofxandycannotbedetermined.\n");}else{x=(b2*c1b1*c2)/d;y=(a1*c2a2*c1)/d;
printf("x=%0.2lf,y=%0.2lf\n",x,y);}
return0;}:.
if- (int)d==0 d ( double )- 0- : if (d == 0.0) , - -
? ,
) 35% - , ? , 10000 + 10000 * 35 / 100 -
-
:
#include
intmain(){doubleloan_amount,interest_rate,number_of_years,total_amount,monthly_amount;
printf("Entertheloanamount:");scanf("%lf",&loan_amount);printf("Entertheinterestrate:");scanf("%lf",&interest_rate);printf("Numberofyears:");scanf("%lf",&number_of_years);
total_amount=loan_amount+loan_amount*interest_rate/100.00;monthly_amount=total_amount/(number_of_years*12);
printf("Totalamount:%0.2lf\n",total_amount);printf("Monthlyamount:%0.2lf\n",monthly_amount);
return0;}:.
35%
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
35% 10000 + 10000 * 35 * 5 / 100
-
)
u (initial velocity) a (acceleration) ( a , ) t v 2t ? ( , 10071 )
2t v x 2t
- :v = u + ats = ut + 0.5 at2 ( s t ) 2t u x 2t + 0.5 x a x (2t)2 = u x 2t + 0.5 x a x 4t2 = u x 2t + a x 2t2 = 2t (u + at) = 2tv, , v t- , 2t
) 1 + 2 + 3 + + 998 + 999 + 1000 ?
, , 1000 x 1001 / 2 ,
-
#include
intmain(){intn,sum;
scanf("%d",&n);
sum=(n*(n+1))/2;
printf("Summationis%d\n",sum);
return0;}:.
#include
intmain(){inti,n,sum;
scanf("%d",&n);
for(i=1,sum=0;i
-
}
printf("Summationis%d\n",sum);
return0;}:.
, , ( ) , , n- ( ) n- , , sum ( ) n n- ,
) (Celsius) (Farenheit)
: F = (C 1.8) + 32
#include
intmain(){doublecelsius,farenheit;
-
printf("Enterthetemperatureincelsius:");scanf("%lf",&celsius);
farenheit=1.8*celsius+32;
printf("Temperatureinfarenheitis:%lf\n",farenheit);
return0;}:.
) (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 ? :
#include
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
intmain(){inta,b,x,gcd;
scanf("%d%d",&a,&b);
if(a=1;x){if(a%x==0&&b%x==0){gcd=x;break;}}
printf("GCDis%d\n",gcd);
return0;}:.
gcd ( break ) break
-
(efficient) , (co-prime) 1 , 1
(division algorithm) :a 0- - aa b- = b a % b-
, a- b b- a%b , b- b- a ( a- , b- a- )
#include
intmain(){inta,b,t,x,gcd;
scanf("%d%d",&a,&b);
if(a==0)gcd=a;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
elseif(b==0)gcd=b;else{while(b!=0){t=b;b=a%b;a=t;}gcd=a;}
printf("GCDis%d\n",gcd);
return0;}:.
, ,
x =
,
-
- , , 100 50%, 25% 25% :
#include
intmain(){intft_marks,st_marks,final_marks;doubletotal_marks;ft_marks=80;st_marks=74;final_marks=97;
total_marks=ft_marks/4.0+st_marks/4.0+final_marks/2.0;printf("%0.0lf\n",total_marks);return0;}:.
87 ( total_marks = ft_marks / 4.0 + st_marks / 4.0 + final_marks / 2.0;
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
total_marks = ft_marks / 4 + st_marks / 4 + final_marks / 2; 86 ? ?)
! , :
#include
intmain(){ 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
#include
intmain(){intara[5]={10,20,30,40,50};printf("Firstelement:%d\n",ara[0]);printf("Thirdelement:%d\n",ara[2]);return0;}:.
?
:
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
#include
intmain(){intara[5]={6,7,4,6,9};printf("%d\n",ara[1]);printf("%d\n",ara[5]);printf("%d\n",ara[100]);return0;}:.
? (garbage) -1, 5, 100 5 0 4
, ? (ara[0]), (ara[1]), (ara[2])
#include
intmain(){intara[10]={10,20,30,40,50,60,70,80,90,100};
- inti;for(i=0;i
- for(i=0,j=9;i
-
ara[0] = temp; temp = ara[8];ara[8] = ara[1];ara[1] = temp; :
#include
intmain(){intara[]={10,20,30,40,50,60,70,80,90,100};inti,j,temp;for(i=0,j=9;i
-
? ?
102030405060708090100
! , (bug), , (debug) ( )
, ,
intft_marks[40],st_marks[40],final_marks[40];doubletotal_marks[40]; 1 ( index 0 ) total_marks[34]- ? 35 n total_marks[n-1]
-
:
#include
intmain(){intft_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},final_marks[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};inti;doubletotal_marks[40];for(i=0;i
-
return0;}:.
, ! printf \t , (Tab) ( ) \t ,
50 , 51
, 50- 50 100 total_marks , 50 , 51 100 50 100 total_marks for(marks = 50; marks
-
count++; } } printf("Marks: %d Count: %d\n", marks, count); marks (count) }
:
#include
intmain(){intmarks,i,count;inttotal_marks[]={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};for(marks=50;marks
-
return0;}:.
- if- (total_marks[i] == marks) ? 51 40 51 x 40 = 2040 :
#include
intmain(){inti;inttotal_marks[]={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};intmarks_count[101];for(i=0;i
- for(i=50;i
-
:t_m = total_marks[i];marks_count[t_m]++;
marks_count[total_marks[i]]++; marks_count
#include
intmain(){inti,j;inttotal_marks[]={6,7,4,6,9,7,6,2,4,3,4,1};intmarks_count[11];for(i=0;i
-
return0;}:.
, ?
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , 25 - 01622624182, , , ( ),
01. Go to your bKash Mobile Menu by dialing *247#02. Choose Payment 03. Enter the Merchant bKash Account Number you want to pay to (01622624182)04. Enter the amount you want to pay (25)05. Enter a reference against your payment (cpbook pdf)06. Enter the Counter Number (enter 0)07. Now enter your bKash Mobile Menu PIN to confirm
) *247# ) '' ) 01622624182 ) ( )) cpbook pdf ) ) (PIN)
( )
-
? ? ! ,
printf, scanf , main ,
printf scanf, getchar printf , printf , stdio.h (header) ( printf, scanf ) (#include ) - string.h
, printf , !
, main , ? main , main , :
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return_type function_name (parameters) { function_body
return value}
return_type: , int, double void , ,
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
sin, cos, tan sin 300- 0.5 sin , sine ( sin)-
,
#include
intmain(){doublea,b,c;a=2.5;b=2.5;c=a+b;printf(%lf\nc);
return0;}:.
? 5.000000
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
main
#include
intadd(intnum1,intnum2){doublesum=num1+num2;returnsum;}
intmain(){doublea,b,c;a=b=2.5;c=add(a,b);printf(%lf\n,c);
return0;}:.
? 4.000000! num1 num2 int , double 2.5 2 ( ?) :
intadd(doublenum1,doublenum2){doublesum=num1+num2;
-
returnsum;} ? 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 :#include
doubleadd(doublen1,doublen2){doublesum=n1+n2;returnsum;}intmain(){doublea,b,c;a=2.8;b=2.7;c=add(a,b);printf("%lf\n",c);
return0;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
add main :
#include
intmain(){doublea=2.8,b=2.7,c;
c=add(a,b);printf("%lf\n",c);
return0;}
doubleadd(doublen1,doublen2){
doublesum=n1+n2;returnsum;
}:.
, : error: add was not declared in this scope , add , main add (prototype) :
double add(double n1, double n2);
-
:return_type function_name (parameters) ;
, :
#include
doubleadd(doublex,doubley);
intmain(){doublea=2.8,b=2.7,c;
c=add(a,b);printf("%lf\n",c);
return0;}
doubleadd(doublen1,doublen2){doublesum=n1+n2;returnsum;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
-
#include
inttest_function(intx){inty=x;x=2*y;return(x*y);}
intmain(){intx=10,y=20,z=30;z=test_function(x);printf(%d%d%d\n,x,y,z);
return0;}:.
? , :20 10 200 ( x = 20, y = 10, z = 200)? x, y- test_function- x- 10 , y- y- 10 x- 2 * y 20 x * y ( , 20 * 10 200) z- 200
-
, : 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) :
#include
double pi = 3.14;
void my_fnc() { pi = 3.1416; /* pi- */ return; /* void return; */}
int main() { printf( %lf\n , pi); /* pi- 3.14 */ my_fnc(); printf( %lf\n , pi); /* pi- 3.1416 my_fnc */
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return 0;}
my_fnc pi (double pi;), pi-
, ?int find_max(int ara[], int n) { /* , , , int ara[11] */ int max = ara[0]; /* max max- max- max */
int i;
for(i = 1; i < n; i++) { if (ara[i] > max) { max = ara[i]; /* ara[i] max- max- ara[i]- */ } }
-
return max; /* */}
? , ? :
#include
intfind_max(intara[],intn);
intmain(){intara[]={100,0,53,22,83,23,89,132,201,3,85};intn=11;intmax=find_max(ara,n);printf(%d\n,max);
return0;}
intfind_max(intara[],intn){intmax=ara[0];inti;
for(i=1;imax){max=ara[i];}
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
}
returnmax;}:.
find_min find_sum,find_average
(pass, ) , ( ) :
#include
voidtest_function(intara[]){ara[0]=100;return;}
intmain(){intara[]={1,2,3,4,5};printf(%d\n,ara[0]);test_function(ara);printf(%d\n,ara[0]);
-
return0;}:.
? printf 1 , printf ? test_function- 100 , ara[0]- 100, -, 1
100, ,
?
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
,
-
'?' : N(),?
(1100,101000,1000100000), 1 1000 'N?'(1?2?...999,1000?)
,1100050:)500,?)250,?)125,?)62,?)31,?)46,?)54,?)50,?!
?1100015001250,1125,162,3162,4662,4654
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:(low,high,N):(,(low),(high)(N))1:mid=(low+high)/22:midN53:N,mid,low=mid+1.14:N,mid,high=mid1.15:(mid)
?intara[]={1,4,6,8,9,11,14,15,20,25,3383,87,97,99,100};
lowhigh?low=1high=100? , ara 0 15low_indx=0;high_indx=15;97num=97;
,num ara?
-
,()
while(1){mid_indx=(low_indx+high_indx)/2;
if(num==ara[mid_indx]){/*numara[mid_indx],*/break;
}
if(num
-
lowhigh,,ara[mid_indx]:
#include
intmain(){intara[]={1,4,6,8,9,11,14,15,20,25,3383,87,97,99,100};intlow_indx=0;inthigh_indx=15;intmid_indx;intnum=97;
while(low_indx
-
if(low_indx>high_indx){printf("%disnotinthearray\n",num);}else{printf("%disfoundinthearray.Itisthe%dthelementofthearray.\n",ara[mid_indx],mid_indx);}
return0;}:.
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
(string)
string , , - ,
character string - char
:
charcountry[11]={'B','a','n','g','l','a','d','e','s','h','\0'};
charcountry[]={'B','a','n','g','l','a','d','e','s','h','\0'};
charcountry[]=Bangladesh;
char*country=Bangladesh;
Null character ('\0') , Null character (pointer)
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
#include
intmain(){ charcountry[]={'B','a','n','g','l','a','d','e','s','h','\0'};printf("%s\n",country);return0;}:.
printf- %s '\0'
#include
intmain(){charcountry[]={'B','a','n','g','l','a','d','e','s','h','','i','s','','m','y','','c','o','u','n','t','r','y'};printf("%s\n",country);
-
return0;}:.
? ?
#include
intmain(){ charcountry[]={'B','a','n','g','l','a','d','e','s','h','\0','i','s','','m','y','','c','o','u','n','t','r','y'};printf("%s\n",country);return0;}:.
'\0' ( capital letter uppercase character) , 'A'- 65, 'B'- 66, 'C'- 67... 'Z'- 90 'a' 97, 'b' 98 ... 'z' 122 :
??http://cpbook.subeen.com
http://cpbook.subeen.com/
- if(ch >= 'A' && ch = 65 && ch = 'a' && ch = 97 && ch
- for(i=0;i=97&&country[i]
-
for(i=0;str[i]!='\0';i++){length++;}returnlength;}
intmain(){charcountry[100];
intlength;
while(1==scanf("%s",country)){length=string_length(country);printf("length:%d\n",length);}return0;}:.
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 :
#include
intmain(){charara[100];
while(NULL!=gets(ara)){printf("%s\n",ara);}return0;}:.
ctrl + z ( - ctrl z ) , ctrl + d ctrl +z ctrl + d gets NULL char ara[100];
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
100
string_length :
intstring_length(charstr[]){inti;for(i=0;str[i]!='\0';i++);returni;}
string_length for while concatenate bangla desh bangladesh
: char str1[] = "bangla", str2[] = "desh", str3[12]; str3 bangladesh :str3 = str1 + str2;
''- str1- str3 , str2- str3
#include
-
intmain(){charstr1[]="bangla",str2[]="desh",str3[12];
inti,j,length1=6,length2=4;for(i=0,j=0;i
- for(i=0,j=0;i
-
string_compare() 1 , -1 0
char
intstring_compare(chara[],charb[]){
}
a- b- , a- b- a- b- , a, b- -1 a- b- , 1 a, b- ? 0
intstring_compare(chara[],charb[]){inti,j;for(i=0;a[i]!='\0'&&b[i]!='\0';i++){if(a[i]
-
}if(a[i]>b[i]){return1;}}if(string_length(a)==string_length(b)){return0;}if(string_length(a)string_length(b)){return1;}}
, string.h - (: strcmp, strlen, strcpy) , ,
( ) 1000 (punctuation)
-
, ? , 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' , ,
#include#include
intmain(){chars[1002],word[100];inti,j,length,is_word_started;
gets(s);
length=strlen(s);
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
is_word_started=0;
for(i=0,j=0;i='a'&&s[i]='A'&&s[i]='0'&&s[i]
-
else{if(is_word_started==1){is_word_started=0;word[j]='\0';printf("%s\n",word);j=0;}}}
return0;} :.
? , , gets() (warning) ,
: This is a test. ? :ThisIsA
! test ? test-
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
strlen - string.h include s- word i = 0 length s-
if(s[i]>='a'&&s[i]='A'&&s[i]='0'&&s[i]='A'&&s[i]='0'&&s[i]
-
}
test- ? ( test )
, word !
#include#include
intmain(){chars[1002],ch;inti,length,is_word_started;
gets(s);length=strlen(s);is_word_started=0;
for(i=0;i='a'&&s[i]
- else{printf("%c",s[i]);}} elseif((s[i]>='A'&&s[i]='0'&&s[i]
-
-
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
(Prime Number) , ,
1- 1 -
#include
intis_prime(intn){inti;if(n
-
intmain(){intn;while(1){printf("Pleaseenteranumber(enter0toexit):");scanf("%d",&n);if(n==0){break;}if(1==is_prime(n)){printf("%disaprimenumber.\n",n);}else{printf("%disnotaprimenumber.\n",n);}}return0;}:.
n n 2 n-1 n , 0 n , n
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
1 !
- (efficient) 2147483647 2147483647 2 2147483646 2 n-1 2 n/2
2 , 2 (4, 6, 8, )
:
intis_prime(intn){inti;if(n
- if(n%2==0){return0;}for(i=3;i
-
#include#include
intis_prime(intn){inti,root;if(n==2){return1;}if(n%2==0){return0;}root=sqrt(n);for(i=3;i
-
intn,m;while(1){printf("Pleaseenteranumber(enter0toexit):");scanf("%d",&n);if(n==0){break;}if(1==is_prime(n)){printf("%disaprimenumber.\n",n);}else{printf("%disnotaprimenumber.\n",n);}}return0;}:.
( )
? , (Eratosthenes) - (Sieve of Eratosthenes)
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, 2 40 :2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 , 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,32, 33, 34, 35, 36, 37, 38, 39, 40. , 2 2- (2 , 2- ) :2, 3, 5, 7, 9, 11, 13, 15, 17, 19 , 21, 23, 25, 27, 29, 31, 33, 35, 37, 39. 3- 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37. 5- 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37. 7 37- 7- 7- ? 7- 14, 21, 28, 35 7- 7-
, ara , n- ( ) ara[n] ara[n]- 1 , n ara[n]- 0 n : : , n 1 : 1 1, : 2 m , (0) m- m- n-
-
#include#include
constintsize=40;intara[size];
voidprint_ara(){inti;for(i=2;i
- {inti,j,root;for(i=2;i
-
}intmain(){intn,m;sieve();while(1){printf("Pleaseenteranumber(enter0toexit):");scanf("%d",&n);if(n==0){break;}if(n>=size){printf("Thenumbershouldbelessthan%d\n",size);continue;}if(1==is_prime(n)){printf("%disaprimenumber.\n",n);}else{printf("%disnotaprimenumber.\n",n);}}
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
return0;}:.
, print_ara() sieve() , , n ara[n]- , 1 n , 0 n size- (fast) ? ?, 100 , 100 ' ' n- size- ,n- 100000000 ( ) 10000 sieve ? , ,
, , 0 1 sieve
-
!
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
? -
, , , - - ,
, - :
Roll: 1 Roll: 2 Roll: 3 Roll: 4 Roll: 5 Roll: 6 Roll: 7 Roll: 8 Roll: 9 Roll: 10
First terminal exam 80 70 92 78 58 83 85 66 99 81
Second terminal exam 75 67 55 100 91 84 79 61 90 97
Final exam 98 67 75 89 81 83 80 90 88 77
Total marks
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] - , marks[0][5] - , marks[1][0] - , marks[2][3] - ,
, 10 ? marks[0][0] ?
marks[0][0]- 1- marks[1][9]- 10- :
int 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 )
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
#include
intmain(){intmarks[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}};
intcol;
for(col=0;col
- for(j=0;j
- for(row=0;row
-
{charsaarc[7][100]={"Bangladesh","India","Pakistan","SriLanka","Nepal","Bhutan","Maldives"};
introw;
for(row=0;row
- for(row=0;row
-
printf("(%d,%d)=%c,",row,col,saarc[row][col]);}printf("\n");}
return0;}:.
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 -
:Sumofrow1:34Sumofrow2:29Sumofrow3:27
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
Sumofrow4:22Sumofrow5:21
:Sumofcolumn1:23Sumofcolumn2:22Sumofcolumn3:20Sumofcolumn4:31Sumofcolumn5: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 ?
-
, ,
#include#include
intmain(){intara1[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}};intara2[5][5];
intr,c;
printf("Contentoffirstarray(ara1):\n");
for(r=0;r
-
ara2[c][r]=ara1[r][c];}}
printf("Contentofsecondarray(ara2):\n");
for(r=0;r
-
- (decimal) (binary) 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 09 , 09- 10), 0 9 ( 1 0- 1 ) : 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011... , 0- 1 ( )
, , , , , , ?
10 , 100 , 1000 , (10), (100), (1000), (10000) (100 = 1) , (101 = 10) , (102 = 100) , (20 = 1) , (21 = 2) , (22 = 4) , , , , , ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 10
, 1 + 1 , (10) , ,
101 + 101 = ?
, 1 + 1 = 10 0 1 (carry) , 0+ 0 = 0, 0- 1 1 , 1 + 1 = 10 ( carry ) 0 1 :1010 1011 + 1011 = ? 10110 ,
0 0 = 0,1 0 = 1,1 1 = 0,0 1 = 1 , 23 15 ? 3- 1 ( 1 ), 13 5 = 8 , 1- 0 1 0- , 10 (), ( )
-
110 101 = ?
0 1 1, 1 101- 1 1 = 0, 1 1 = 0 : 001 1 - -
x 10 - , x 2 - : 1903 = 1 x 103 + 9 x 102 + 0 x 101 + 3 x100 : 10110 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 Exponential Expression
, :
10110 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 = 1 x 16 + 0 x 8 + 1 x 4 + 1 x 2 + 0 x 1= 16 + 0 + 4 + 2 + 0 = 22
10110 = 22 , , ?
char binary[] = 10110 ;
int len = 5; // 5int decimal = 0; // , 0
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
2 binary[0] '1' ,- ?- 4 , 0
int position = 4;
int indx;
for(indx = 0; indx < len; indx++) { decimal = decimal + pow(2, position); position--;}
, pow math.h ab- pow(a, b) :
#include#include#include
intmain(){charbinary[65];intlen,decimal,power,i;
-
printf("Enterthebinarynumber:");scanf("%s",binary);
decimal=0;len=strlen(binary);power=len1;
for(i=0;i
-
: ['1', '0', '1', '1', '0'] binary[0]- pow(2, 4), binary[1]- pow(2, 3), , binary[4]- pow(2, 0) 10110- ?
Decimal value is 1510 ? ? ,
decimal += binary[i] * pow(2, power); , binary[i]- '0' '1' ( '0' '1') '0' 48 '1' 49 '0' 0 '1' 1 ?
'0' '0' = 48 48 = 0 '1' '0' = 49 48 = 1
? binary[i] (binary[i] '0') ( )
95 n- , 2n
-
4 = 92 < 95 1 (10111xx) n = 1, 92 + 21 = 92 + 2 = 94 < 95 1(101111x) n = 0, 94 + 20 = 94 + 1 = 95 1 1011111
:
95/ 2 47 1
47/2 23 1
23/2 11 1
11/2 5 1
5/2 2 1
2/2 1 0
1 /2 0 1
: 1011111 0 main
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , 25 - 01622624182, , , ( ),
01. Go to your bKash Mobile Menu by dialing *247#02. Choose Payment 03. Enter the Merchant bKash Account Number you want to pay to (01622624182)04. Enter the amount you want to pay (25)05. Enter a reference against your payment (cpbook pdf)06. Enter the Counter Number (enter 0)07. Now enter your bKash Mobile Menu PIN to confirm
) *247# ) '' ) 01622624182 ) ( )) cpbook pdf ) ) (PIN)
( )
-
??http://cpbook.subeen.com
, , : http://dimikcomputing.com
http://cpbook.subeen.com/
-
,
. .
. . printf , , 'c' ' ' ( )
-
(palindrome) , ? ( ) : madam madam
? , :
#include#include
intmain(){charword[80],reverse_word[80];inti,j,len;
scanf("%s",word);
len=strlen(word);
for(i=0,j=len1;i
-
if(0==strcmp(word,reverse_word)){printf("%sisapalindrome.\n",word);}else{printf("%sisnotapalindrome.\n",word);}
return0;}:.
! , , strcmp , , ,
(factorial) ? n - n! n! = n * (n 1) * (n 2) * * 3 * 2 * 1 4! = 4 * 3 * 2 * 1 = 24 6! = 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 * 5 2 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, 4 1- : 1, 2 3, 5, 4 3 : 1, 2, 3 5, 4 4 3- : 1, 2, 3, 4 , 5 4- 1, 2, 3, 4, 5 (sorting) - ?
: 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
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
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-
,
#include
intmain(){intara1[]={3,1,5,2,4};intara2[5];
inti,minimum,index_2;
for(index_2=0;index_2
- if(ara1[i]
-
minimum , minimum_index :minimum = 10000;for (i = 0; i < 5; i++) { if (ara1[i] < minimum) { minimum = ara1[i]; minimum_index = i; }} minimum- ara1[minimum_index] ara1[minimum_index] = 10000;
:
#include
intmain(){intara1[]={3,1,5,2,4};intara2[5];
inti,minimum,index_2,minimum_index;
for(index_2=0;index_2
- if(ara1[i]
-
(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- :
#include
intmain(){intx,y;charc;
printf("Pleaseentertheinitialposition:");scanf("%d%d",&x,&y);
while(1){scanf("%c",&c);
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
if(c=='S'){break;}elseif(c=='U'){x;}elseif(c=='D'){x++;}elseif(c=='R'){y++;}elseif(c=='L'){y;}}
printf("Finalpositionoftherobotis:%d,%d\n",x,y);
return0;}:.
:Please enter the initial position: 2 2 D R
-
D R S Final 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];
for(i=0;i
- printf(Pleaseenterthenumberofblockedcells:);scanf(%d,&n);printf(Nowenterthecells:);for(i=0;i
-
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , , ! , , ?
, - (skill) , , , ,
- (C++) (Java), (C#), (PHP) (Python)
) ,) IDE ,) ,
-
) ,) (OOP Object Oriented Programming) ,) ,) (Communication Skills),) ,) ,)
, ,
, , 25 - 01622624182, , , ( ),
01. Go to your bKash Mobile Menu by dialing *247#02. Choose Payment 03. Enter the Merchant bKash Account Number you want to pay to (01622624182)04. Enter the amount you want to pay (25)05. Enter a reference against your payment (cpbook pdf)06. Enter the Counter Number (enter 0)07. Now enter your bKash Mobile Menu PIN to confirm
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
) *247# ) '' ) 01622624182 ) ( )) cpbook pdf ) ) (PIN)
( )
-
- , - ,
- (IOI International Olympiad in Informatics) 1989 2009 ( ) IOI
(ACM ICPC ACMInternational Collegiate Programming Contest) , ICPC Regional Contest- ICPC Regional Contest- ICPC Regional Contest- (ICPC World Finals) 1998
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
: 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/) ,
, ,
http://www.codechef.com/http://en.wikipedia.org/wiki/ACM_ICPC_Dhaka_Site
-
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, ,
, , , ,
Telecommuting , , ,
, -- (bid) , ,
-
,
, , , ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, Herbert Schildt- TeachYourself C Brian Kernighan Dennis Ritchie- The C ProgrammingLanguage , Dennis Ritchie, Stephen G. Kochan- Programming in C Schaums Outlines Programming withC
Teach Yourself C++(: Herbert Schildt) Java How to Program (: Paul Deitel and Harvey Deitel)
, , Discrete Mathematics Kenneth H. Rosen- Discrete Mathematics Discrete Mathematics Introduction toAlgorithms (: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein)
: http://projecteuler.net/
, http://www.spoj.pl/
, , , , , ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/http://www.spoj.pl/http://projecteuler.net/
-
http://uva.onlinejudge.org/
http://ace.delos.com/usacogate ,
,
http://www.topcoder.com/tc ( !)
http://codeforces.com/ http://www.codechef.com/
http://ioinformatics.org http://cm.baylor.edu/welcome.icpc
:http://matholympiad.org.bd/forum/
www.google.com , google-
http://www.google.com/http://matholympiad.org.bd/forum/http://cm.baylor.edu/welcome.icpchttp://ioinformatics.org/http://www.codechef.com/http://codeforces.com/http://www.topcoder.com/tchttp://ace.delos.com/usacogatehttp://uva.onlinejudge.org/
-
, , , , , ,
, http://cpbook.subeen.com/p/blog-page_11.html
, - http://cpbook.subeen.com/2012/12/problem-solving-guideline-1.html
- http://dimikcomputing.com https://www.facebook.com/DimikComputing - - - ( ) -
??http://cpbook.subeen.com
http://cpbook.subeen.com/https://www.facebook.com/DimikComputinghttp://dimikcomputing.com/http://cpbook.subeen.com/2012/12/problem-solving-guideline-1.htmlhttp://cpbook.subeen.com/p/blog-page_11.html
-
- - ,
, ,
:
51023829765
:
32
http://cpbook.subeen.com/2012/11/positive-negative.html
http://cpbook.subeen.com/2012/11/positive-negative.html
-
-
, 10000000-
:4121000050207445998876652239876452212
:7133
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- - , ?
, - - ,
:
22223510
:
8150
-
- ASCII ASCII ASCII
,
ASCII
:
2CATdog
:
216314
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- ?
, -
:
2123450105080100
:
511000
-
- ,
0- 10000001-
YES NO
:5410649925
:YESNOYESNOYES
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- -
, -
:2123450105080100
:348
-
- - ,
,
:42508075678438766498819035050100
:65.0066.7190.0066.67
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- 1- 1 -
, -
:471998154329100516522552631671788934775162869251436495677951197794233237845961
:4407
-
-
, 10000001-
:42310074341000
:3141
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- -
L, R L R , 34R92L6 3499226
, 50
:50L74R5L9718R4R034R92L6
:0074555971
-
844003499226
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- --
, (0 2147483647- )
, even odd
:310001111
:evenevenodd
-
- --
,
, even odd
:310001111
:evenevenodd
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- , * , * ,
- N N- (M) 1 100-
M- M X M *
:
-
3
1
3
5
:
*
***
***
***
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
*****
*****
*****
*****
*****
-
-
, N
,
N
:
512253333748690906556
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:23N0956
-
-
() , " ? ? ... ", , ', '
, , , ' ' , 'rice eat you' , !
, -
, order 1/n n
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
2eatyouricenowaynogood
:
1/61/12
-
- ? " " - ( !) ,
, ( )
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
2
alittlepinkcatislookingforamousetoplayanonlinemultiplayergame.pleasefindheramouse.shepromisesnottoeatitorchaseit.sheisagoodpinkcat.thisisatest
:
147001680
-
-
, ' ?'
n , ? ,
, , n n
n- blue red
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:21134344
:bluered
' ' , http://dimikcomputing.com -
-
- - , -
*
***
*****
*******
7 5 , 3 1 , ,
, , 1 100
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
,
:
45142
:
*
***
*****
*******
*********
-
*
*
***
*****
*******
*
***
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , ! ,
, 1 0 , , 10110 ,
1001 ! ? ,
, 1 0 50
-
MAGIC NORMAL
:4
10110
11001001
1001
1
:
NORMAL
MAGIC
MAGIC
NORMAL
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- ! , '' , , , - , , , , ? , ( " : :" ' ' : : ) ( : : ' ' : :) - - ,
'N' (N
- , "hhmm ss", hh (0
-
:
1230
20685
-
-
- , ?
N >= 2 2 N 65536
,
:
100
22
65536
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
65154
11
0
:
100=2^2*5^2
22=2^1*11^1
65536=2^16
65154=2^1*3^1*10859^1
11=11^1
-
- Marks Grade
80100 A+
7579 A
7074 A
6569 B+
6064 B
5559 B
5054 C
4549 D
044 F
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
T (T
-
Case2:F
Case3:B
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
-
T (T
-
-
1 N x
T (T 100). T x N 1 x N 1000000.
1 N x
:
34111350210
:Case1:48Case2:132639Case3:246810
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
-
T (T
-
Case2:333333333333333
??http://cpbook.subeen.com
, : http://dimikcomputing.com
http://cpbook.subeen.com/
-
-
triplet (x, y, z) x A, y B, z C (0 A, B, C 20) x < y < z
T (T 20). T A,B,C
Case X: , X 1 lexicographical
:: Lexicographic (a1, b1, c1) (a2, b2, c2) lexicographic : (i) a1 < a2 (ii) a1 = a2 and b1 < b2 (iii)a1 = a2 and b1 = b2 and c1 < c2)
:
3
-
112
323
444
:
Case1:
012
Case2:
012
013
023
123
Case3:
012
013
014
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
023
024
034
123
124
134
234
-
- ()
T (T 10). T N , (1 N 100000)
,
N
:
361523
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
Case 1: 1 2 3 6
Case 2: 1 3 5 15
Case 3: 1 23
-
- ,
T (T 50).
T B H 1 B, H 1000.
Case X: Y ,
X 1 Y
:
3
612
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
3156
335501
:
Case1:72
Case2:1736
Case3:167835
-
- ?
, , , ,
(Given three numbers, find out if they from arithmetic progression, geometric progression, both, ornone.)
T (T 50) , T n1, n2, n3 0 n1, n2, n3 1000.
, Case X:
X ( )
None , Arithmetic Progression , Geometric Progression , Both ( )
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
4
125
135
248
222
:
Case1:None
Case2:ArithmeticProgression
Case3:GeometricProgression
Case4:Both
-
- , , , , ,
= , = , = , = , =
T (T 50)
T , , S (1 S 10^9)
, , , ,
0 1 ,
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, 0 1 1year , 1 years
10 10 months , 10 month
:
6
1
59
60
395
3840305
31104000
:
-
Case1:1second
Case2:59seconds
Case3:1minute
Case4:6minutes35seconds
Case5:1month14days10hours45minutes5seconds
Case6:1year
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
-
,
T (T 25).
, x1, y1, x2, y2
x3, y3, x4, y4. (x1, y1) (x2, y2)
(x3, y3) (x4, y4)
, x1 < x2, y1 < y2, x3 < x4, y3 < y4
-
X Y 100, -100 x1, y1, x2, y2, x3, y3, x4, y4 100.
Case X: Yes Case X: No ,
X 1
:
3
1155
4477
1155
171012
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
1122
2233
:
Case1:Yes
Case2:No
Case3:No
-
- 1 , 1
: 46709 57618
, 0
,
10000001-
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
:
5
231
117
0
8341
46709
:
320
6
1
9250
57618
-
- ,
, sun rises in the east east the in rises sun
T (T 20).
:
2
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
sunrisesintheeast
helloworld
:
easttheinrisessun
worldhello
-
- N N
, T, T T N (0
-
2
1
3
:
0
1
100
101
110
111
-
-
T (T 10), T N(2 N 1000000000000)
, N , N, is a prime N N, is not a prime
:
32611
:2isaprime6isnotaprime11isaprime
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- - , , banana ana 1 ban 0 anna
, 128
:
4
bananaana
-
bananaban
aquickbrownfoxjumpsoverthelazydogfox
foobarfoobar
:
1
0
11
0
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- -
, , banana ana 1- , 3-
banana
|||||
ana||
|||
ana
, 2 anna 0
-
,
:
5
bananaana
bananaanna
foxaquickbrownfoxjumpsoverthelazydog
dddddddd
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
foobarfoobar
:
2
0
0
3
1
-
??http://cpbook.subeen.com
- , http://dimikcomputing.com,
http://cpbook.subeen.com/http://dimikcomputing.com/
-
- -
, , , , , , , , , 50 (current run rate) (required runrate) , , 6 1 1
, , ,
-
:
4
3002946
200100100
33325040
118100180
:
6.007.00
3.006.06
5.7712.60
5.000.63
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
, , 25 - 01622624182, , , ( ),
01. Go to your bKash Mobile Menu by dialing *247#02. Choose Payment 03. Enter the Merchant bKash Account Number you want to pay to (01622624182)04. Enter the amount you want to pay (25)05. Enter a reference against your payment (cpbook pdf)06. Enter the Counter Number (enter 0)07. Now enter your bKash Mobile Menu PIN to confirm
) *247# ) '' ) 01622624182 ) ( )) cpbook pdf ) ) (PIN)
( )
??http://cpbook.subeen.com
http://cpbook.subeen.com/
-
- (r1, c1) , (r2, c2) , ,
T (T 50), T 4 : r1,c1,r2,c2, , (r1,c1) (r2, c2)
(0 r1, c1, r2, c2 1000).
Case X: Y , X 1 Y (r1, c1) (r2, c2)
-
:
3
1133
1269
42468335501
:
Case1:2
Case2:7
Case3:293
??http://cpbook.subeen.com
http://cpbook.subeen.com/