Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

218
1 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

Transcript of Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

1 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
2 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

& &

[email protected]
3 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
++c,c) (



1 •
++c ,c)( ) vb.net2008( •
http://www.4shared.com/account/dir/z01ovuue/_online .html?rnd=80#dir=83250388
4 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

(
( 1
..(
( ) (

1 1




(
( .

.) c=a+b( . ) a,b( .) a,b,c( .
(
%100 (
#include<iostream.h>
3.c=a+b; 4.cout<<c;}
5 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: 1
if ,Switch)( :
)For , While , Do—While( :
Array)( :
)Function( :
)pointer( :



!
:!



!
!
H:!
:
7 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: ) ++c , c(

: •
K
<stdio.h> C )scanf ,printf(
.<iostream.h> ) cout , cin(
:)main( •
1 : 6 •
. ( •
++C
include<iostream.h> # Main()
{
}
Main()
{
}
8 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
. ( ( 1
)if,for,while (
) time( K
. ( ( (
. ) ( xK
main() )integer (
) x(
x


Int var; integer K )int x=5(
Float var; K )Float var=5.4;( Char var; K )Char var="a";(
Double var; Double Void var; Void (
++c c

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

.
)(
) (
first =51; second= first ;
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

) x,y,z(


symbol ( )a. (
K

first second
((
X=5
symbol
9 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb









symbol ='a'
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb


)y( ) x+3(
K 1 1
) x+3(
1.int y, x=5;

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

1
1
) (
) (
K 1 1
) (
) (
(
=
+
+
10 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
1 •

K 1 1 •
:



Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) const(
K . (
)pi(

()main
)(
const float pi=3.14;
{
}
Main()
9.
10
11.
}
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
(
( (
1 ( ) 3.14

. (
( (

//or #include <stdio.h> for user of C language
) (

(
Main 7
11 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
. ) pi=3.14(
)const ( )3.14

language

7


12 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
float integer :
:
1 .
Main .
integer fixOnly .
. float float fixAndPint .
float float fixAndPint integer fixOnly . float fixAndPint integer fixOnly
float
fixOnly .
).( ) ( fixOnly K )(
) cout,printf(K .( L
integer ( "d%" C .
++c c #include<stdio.h> main()
{
#include<iostream.h>
cout<<fixOnly; }
float integer
integer

13 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:L .
++C
cout>>var;
printf("%symbleToVar",var);
1 (K • .
• )var( • )symbleToVar( +
)( ) C ( printf ("%d",&var); var printf ("%f",&var); var printf ("%c",&var); var printf ("%s",&var); var
. ) ctrl+f9(
integer data3)( :
integer ( ) C( ) "d% "(
:
) hi hussien ahammed taleb( :
++c cout<< data3;
++c c #include<stdio.h> main()
{ printf(" hi hussien ahammed taleb"); }
#include<iostream.h> main()
{ cout<<" hi hussien ahammed taleb"; }
14 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) run( )ctrl+f9(+
. E :E "n\" •

+
) "n\"( E

) E ( E
\v \h \n \t
t\"" " n\"
++c c #include<stdio.h> main()
{ Printf(" hi\nhussien\nahammed\ntaleb"); }
#include<iostream.h> main()
{ cout<<" hi\nhussien\nahammed\ntaleb"; }
++c c Printf(" hi\t hussien\t ahammed\t taleb"); cout<<" hi\t hussien\t ahammed\t taleb";

15 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. :
+ ) C( "f%"+ ) float( .
+) 3.5( .

)fixAndPint ( ) =Number_is( ++C ) $(
)"symbleToVar%"( ) C(
)) C( (. ) symbleToVar(
++c c #include<stdio.h>
Main()
++C
#include<iostream.h>

16 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: L
. K
++C
Cin>>var;
C
scanf("%symbleToVar",&var);
• )var( . • )symbleToVar( + .
)( )C ( scanf("%d",&var); var scanf("%f",&var); var scanf("%c",&var); var scanf("%s",&var); var

++C
scanf("%symbleToVar %symbleToVar ",&var1,&var2);
) symbleToVar%( 1 •
) float( ) x( :
++C
cin>> x;
++C
scanf("%f",& x);
)float( ( ) C( ) "f% "(

17 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
a : )a(
:
) ( .
. ) ( . character )C( ) "%C"
)( ) ( .

: ( (
)b( ) a( :
++c c #include<stdio.h>
main()
// ;c( c=a( a
,a a=b; //a=30 b ,b b=c; // b=12 a

18 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:)6(
-:
6 --++
- % / * - + =
– ++
-:Bowties 6
<< >> )and( &
^ )or( |
) ( 6
6 !
)and( && )or( ||
. )False( ) True( 1
B
)Bowties( 1
1 1 1 K )( ) ( 1
19 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
(
)c( ) a,b(
;C=a+b C=a+b (+)
;C=a-b C=a-b )-( ;C=a/b )/(
;C=a*b C=a*b (*) ;C=a mod b C=a%b (%)
( .
K )(integer :
.
:
()main ) ( . ) ( .
. 1 . ) ( .
++c c 1.#include<stdio.h>
2.main()
4.scanf("%d", &first);
5. prinC("+\n");
4.cin>> first;
9. }
20 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
K ) ( . 1 ) ( . ) ( . .
(Sum) ) seconds( first )( )( .
(integer) Sum) ( )(
Sum (integer) (integer) (integer) )float( B
K ) ( .
.
) (
) (
) (
) (
) (
) (
) (
( )sum( )div(


7.sum= first/ seconds;
( ( (
21 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
) .( % (
) (
K ( : B
)False( ) True(
K (a>b) <
(a>=b) K =<
(a<b) K > (a<=b) K => (a==b) K == (a!=b) K ( =!

3%2=1
6%2=0
9%3=0
10%8=2
B B 6 7
9%12=9
7%8=7

22 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: 6
1 ) ( 1 (
) 6 . ) ( . 1 1 (
).a-b/d( 6

Reslt=a – c / d
1. Reslt=5 – 10 / 2
7 )5=10/2(
2. Reslt=5 – 5
6
) Reslt=0(
7 .7 7 7
7 : B
7

23 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

Reslt=a * c +d
) a( 7 ) c,d( ) a,c( 6
7 ...........! ) d(

Reslt=a * c + d
1. Reslt=5 * 10 +5
7 )5*10=50(
2. Reslt=50 + 5
) 55( 6
) Reslt=55(
7 ) 67 (

Reslt=a *( c +d)

24 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
Reslt=a *( c +d);
77
Reslt=a * ( c + d)
1. Reslt=5 * (10 + 5)
6 6 6 )12=2*10( 7
2. Reslt=5 * 15
) 75( 6
Reslt=75 ........ 7 B
6 6 6 :B
7
Reslt=a * ( c + d/f)
)d/f( . )c( . )a( . reslt .
25 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

=

) d( 7 ) A,5( ) D/5( 6
..!......... ) A( )Y= 5+A /D - B/C ( 7
y=5+A/d-b/c
6
) c=2,A=4,b=4,d=4(
1. y=5 + 4 / 4 – 4 / 2
7 )4/4=1(
2. y=5 + 1 – 4 / 2
7 )6=1+5(7
3. y=6 – 4 / 2
)2=4/2(7 6
26 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
4. y=6 – 2
) 4( 6
y=4
7
) D( C B

7
y=(5+A)/d-b/c
6
) c=2,A=4,b=4,d=4(
1. y=(5 + 4) / 4 – 4 / 2
7 6 6 6 )9=4+5( 7
27 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
.. 6 7
. ( . . 1 ( 1 ( 1 .
)( 1 1
2. y=9/4 – 4 / 2
)2.25=9/4( 7
3. y=2.25 – 4 / 2
)2=4/2(7 6
4. y=2.25 – 2
y= 25
28 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
6 Bowties S 6: B
7
1 1
)AND,OR,NOT(
NOT )A( OR AND A | B
True False False False False True True False True False False True False False True False True True True True


True && False || True
1.
)True And False=False(7 or and
False || True

29 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

(3+2) && (4*2) || (4%2)
1.
6 7 ) 2*4( 7

2.
) 2%4( 6
(3+2) && 8 || 0
5 && 8 || 0
4.
or 7 and ) or( ) and( T
(5 && 8)
5.
) or( (1||0)=1

30 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
| || & && ) &&( : & &&
) False True( ).&&( ) False True( . False True ) || &&( B:
Int a=5;
Int b=7;
True)True( && )True(
) A>0( . 7 B True ) and( ) True( ) b>0( )True(
) True( ) 1= 1 && 1( )a && b( *
B ) &(
. Bowties -:
Int a=5;
Int b=7;
A & b)( and Binary ) (
0111 7
5 0101
0101 5
) False True( ) 5( B )| ||(
1 :
1 /* * / ) C(
// ) ++C(
++C
C
#include<stdio.h> /* declaration of Lab we will use it*/
31 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
| || & &&
(3|2) && (4&2) || (4<2) ..............................
(3|2) && (4&2) || (4<2)
1.
6 7 )and( ) 2&4( ) &(
(0100)&(0010)=(0000)
2.
False 7 6
(3|2) && 0 || 0
3.
or or B (0011)|(0010)=(0011)
B
3 && 0 || 0
4.
or 7 and ) or( ) and( T
(1 && 0)
5.
) or( (0||0)=0

32 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
.. :

a =a+1;
B ) ( ( ) a( )
---------------------------------- ------------------------------------- Int a=0
a=0
a =a+1;
a=1 a =a+1;
a=2
a=a+5;
--------------------------------------------------------------------------------
7 a 7
);a=a+1( a++ 7
a+=1 a ++
. a
);a=a+5( a+=5 7
---------------------- ------------------------- Int a=0
a=0
a ++;
a=2
--------------------------------------------------------------------------------
33 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ..a++ ,++a(
)a(++7B (
. )( ( ) ( ) (
( )++a( K
() (
( ) a++(
. 1
. :
....
) (a .
item
;a=2.1 ;++a.2 B
.3 B
;a=2.1 ;++a.2 B
++c c
10.}

34 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) a( ) ( .
7 ( ) a( .
) +( )
1 ) ( ) a=3(

) ( ) a( ) +( item
)a=3( K K
item .
a .
a (
K

Item=6

{
2.int b=0; 3.int item=0;
)a=2,b=0,item=0( 4. item=1+a++;
a 7 )a=3,b=0,item=3( // ) ( ) (
5.++a;
7 7 )a=4,b=0,item=3( // ) 7 ( a ) (
6.Item=item + ++b
b 7 )a=4,b=1,item=4( // b item
7.a++;
7 7 )a=5,b=1,item=4( // 7 ( a ) (
) 8.++b;
7 7 )a=5,b=2,item=4( // )(
) 7 (2 b 9.item=item + a++ - b++;
) a,b( )a=6,b=3,item=7( // b a item 7
10.item=item + a++ - ++b;
b )a=7,b=4,item=9( // b a item 7 a
11.item=++b;
b a )a=7,b=5,item=5( // b item
12.item+=5;
item )a=7,b=5,item=10( //
13.b=b+5; b )a=7,b=10,item=10( //

}
36 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:

a =a-1;
) ( ( )a( B (
---------------------------------- ------------------------------------- Int a=2
a=0
a =a-1;
a=1 a =a-1;
a=0
a=a-5;
--------------------------------------------------------------------------------
7 a 7 .
);a=a-1( a-- 7 a - =1
--a . a

);a=a-5( a-=5 7
---------------------- ------------------------- Int a=2
a=0
a --;
a=2
--------------------------------------------------------------------------------
37 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ..a-- ,--a(
( )a--( (K
) (
1 ( ) a--( .
.. :
....
) (a .
item
;a=2.1 ;--a.2
.3
;a=2.1 ;++a.2
++c c 1.#include<stdio.h> 2.main()
3.{
8.item=3+ a;
8.item=3+ a;
9.cout<<"\nSecondTry="<< item ;
10.}
38 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) a( ) ( .
7 ) a( .
) +( ) (
1 ) ( ) a=1(

) ( ) a(
) +( item
)a=1( K K
item .
a .
a ( (4)


Item=4
FirstTry=5
SecondTry=4

39 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
<stdio.h> ) C( L L
getchar).1 ( . . ) enter(
.2)putchar ( ) .(
<conio.h> L
getch).1 (7 ) . ) enter( 7 ). 1
) 1 conio (
.enter)( ) w((

C
5. symbol=getchar;
Putchar( symbol); 6. }
#include<conio.h>
}
}
40 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
getche).2 (7. . ) enter(

enter)( ) w((
<math.h>

.1)sin ( )rad ( )deg (
pi/180
#include<conio.h> main(){ char symbol;
symbol=getche();
#include<iostream.h>
symbol=getche(); cout<<"\nThe symbol your enter is=" << symbol; }
) (
Float sin x;
X=sin(90*(3.14/180) );
41 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
2.)cos ( )rad ( )deg ( pi/180
. .
K
3).pow( ) K ) .9=2^3
X=pow(number,hispower);
1 hispower number K 1 )9^3( :
4).abs(
5).sqrt(
) (
Float x;

X=sqrt(25); // x=5
42 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
!......... (size of).1 . .
(int).2 integer . )ASCii( . B 6 7 6 :7 6 ). ( ) A( )( ) a(
)-----c=99,d=100,e=101( ) ( ) b(
(char).3 1 .
.. ( :
) d%( ) ( ) c( : .
) A( ) ( ) a( ) ( )(

) integer (
Int x;
Int x;
char x;
#include<conio.h> main(){ 1.char symbol;
2.symbol=getche();
2.symbol=getche();
char x='a'; x=char(int('a')-32) // x=A
43 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
(K ) ++C( ) C(
( ) ++C( ) C(
K )++C( ) C( 7B
<include<stdio.h> #include<iostream.h# scanf cin L
printf Cout L
( 1 (K K
44 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
Control Structures)(

!
:!


!
%100
H:!
H :
45 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:7 )if( .
() statement ( ( ) True ( ) (condition if
.
) (if . 1
) False( ) (condition • ) 1 (( ) (if
) True ( ) (condition •
( ) (if
(

if
If ( condition )
include<iostream.h> # ) (
Main()
1.int a;
2.cin>>a;
} a=a+2; 4.

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
a(
True)( (K
) ( ) (
1 2 3 4 5

K
) (
) ( ) 1 2 4 5
C
main()
1.int a;
}
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
integer ) a( )(
a( )
)(
(True ) (condition

) (if

() (if (
K) )(False ) (condition 2
( ) (if (
( ) (


"is greter than 5");
46 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: .
) ( .
.


) (
(




47 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) if( )condition( B if
a if ) a,b( if(a>b) 1K <
b
b a if if(a<b) 1K > b a if if(a>=b) K =< b a if if(a<=b) K => b a if if(a==b) K == b ( a if if(a!=b) ( K =!
b a if and If((a>b)&&(a>c)) && C a
b a if OR If((a>b)||(a>c) || a C
K ) =!,==,=>,=<,>,<( )if(

) OR And ( K ) ||,&&(

(3>2) True (5!=7)True
(23>=120) False
(21 <11) False
( 4==2)False
(43<=76) True
((3+2)>4) (5>4)True
7 6 . B 6 6 6
If(a==0)
If(a/2==0)
48 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:)if( 6
) a , b ( :
. )b 7 a ,, b a ,, b a ,, b a ,, b b a a(
:
: a,b)( ) ( ( . )( .
( 1 ) 3,4,8( ( )a=3,b=2(
6 a b K a ) ( .
( b=2 (a>b)(3>2)True
++c c
include<stdio.h> # main()
if ( a>b )
if ( a>=b )
if ( a<b )
if ( a<=b )
if ( a==b )
if ( a!=b )
include<iostream.h> # main()
if ( a>=b )
if ( a<b )
if ( a<=b )
If ( a==b )
if ( a!=b )
8.cout<<"\na is not equal than b"; }
49 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
a b K a )( .
)( b=2 ) =<(*
(a>=b)(3>2)True a b K ( a )( .
)( ( b=2
1 ***
) .( b a ( 1 b 1a
(a<b)(3<2)False
( ( ) false( 1 ) 5,6,8( ( )a=3,b=6(
6 b a .
K a b=6 )(
(a<b)(3<6)True a b K a 6 .
6 b=6 ) =>(*
(a<=b)(3<=6)True a b K ( a .
( b=6 (a!=b)(3!=6)True
1 *** ) 4,6,7( ( )a=3,b=3(
6 a . a b K
b=3 (a>=b)(3>=3)True




50 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
a b K a 6 . 6 b=3
) =>(* (a<=b)(3<=3)True
a b K a .
b=3 (a==b)(3==3)True
1 ***
)—( :
. (
:
. )a(
1 ) —( .



If ( a < 100 )
( if` (
(


51 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) and( )( .
7 7
K OR 1 ) and( *
. ( ( and if OR
:
integer ) ( .
) ( .
) ( .
) (

++c c include<stdio.h> #
main()
include<iostream.h> #
1.{int a; 2.cin>>a;
}
( a>5 )&&(a<100)
) a=50( ( 50>5 )&&(50<100)
7 6
)( 1.
1 &&(50<100)
6
2.
1 && 1=1 ) True( and

52 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) (
K ) (c : .
) ( 1( . ) (
OR 1 and ) (
1 1 ( * (
OR ) ( AND AND ) ( OR
a=50
( a>5 )&&(a<100)
) a=150( ( 150>5 )&&(150<100)
7 6
)( 1.
1 &&(150<100)
6 B
2.
1 && 0=0 7 ) False( and

If ( ( ( c%3==0 )&&(c%6==0) ) || (c% 9==0) )
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
OR




If ( ( c%3==0 )||(c%6==0
If ( ( ( c%3==0 )||(c%6==0
int a=6;
if ( a>5>3)
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
( OR AND
1
7 OR and
and (
)( ) (a
True=1,False=0( ) ( ) True(
) False=3<1(
a) ( ) ) ( )
) False True(

(c%6==0 ) && (c% 9==0) )
(c%6==0 ) ) && (c% 9==0) )
53 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb






) (
(a





54 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)a ( and ). ( ) (


a> 5 > 3
) a=6( 6> 5 > 3
6 ) True(
1.
1 >3
) false( B B 2. 1>3=0


( a>5) && (a>3)
) a=6( ( 6>5) && (6>3)
6 6 7
) True(
1.
1 && (6>3)
B B ) True(
2. 1 && 1=1
)True( ) and(
55 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. ) a ,b( :
:
) a=5( ) ( .
)a=5( ) a( ) b=7( ) ( .
b ) ( .
) ( )( K ) (
)(
(b%2==1)(7%2==1) (1==1)True
)b=7( ) b( ) (a=5+6=11 ) a( ) ( •
)a=11( ) a( ) (b=7+4=11 ) b( ) ( •
)b=11( ) b( ) (a=11+3=14 ) a( ) ( .
)a=14( ) a( ) (b=11+2=13 ) b( ) ( .
++c c include<stdio.h> #
main()
include<iostream.h> #

a=14 b=13
56 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) b=4( ) ( ) ( ) b ( :
) a=5( ) ( .
) a( ) b=4( ) ( .
)a=5( ) ( .
b () ( ) ( ) ( ) (
(b%2==1)(4%2==1) (0==1)False
)b=4( ) b( ) (a=5+3=8 ) a( ) ( . )a=8( ) a( ) (b=4+2=6 ) b( ) ( .
) ++C(

++c c include<stdio.h> #
main()
include<iostream.h> #

If ( True>3)
{int x=5;}
// ;x=3 ) x(

a=8 b=6


57 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )if--else( .
)condition( (
)else( )if(
Statement1 ) condition(
Statement2
)else( 1 ) If( 1

) ( )input_Numner( )If ( input_Numner%2==0 )( Statement1
( ) ( )input_Numner( B Statement2
)Statement1 Statement2(
if --else
}
58 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. )if—else( ) (
-:
integer ) a( ) ( .
) a( ) ( .
(.
) ( ) if(
is greater than 1 is posi7ve
) ( ) ( ) 1) ((
1 2 3 5 6
) else( ) if( (
) (
is less than 1 is nega7ve
) ( ) (
1 2 4 5 6
++c c include<stdio.h> #
main()
else
a=a+6; 5.
else
a=a+6; 5.
is less than 1 is nega7ve
is greater than 1 is posi7ve
59 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
-: . )( if )(if –else

)( if )(if –else ) ( ( (( . ( )( if
7 7 ( ( ) (if –else
if (input_Try > 0) )input_Try (
) (if –elseK
) ( ) (
)( ) (if –else K (
if (input_Try > 0) ) (if –else (
(
)( if –else ) else ( ) if( • .. 1) if(
. ) if( ) else(

else
}
3.


60 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: . K ( B
( K ( 1 1 ( 1 1 .
(
6 )else( )else( )if( )if( )if( )else( )if( )if(
. )else( 6 )if( 6 )else(
++c ++c include<iostream.h> #
main()
else
}
}
cout<<"the number is donot aceept mod to 9";
If (( Number % 3==0)&&( Number % 9 ==0))
cout<<" the number is aceept mod to 9";
}
c c include<stdio.h> #
main()
else
}
}
printf("the number is donot aceept mod to 9");
If (( Number % 3==0)&&( Number % 9 ==0))
printf(" the number is aceept mod to 9");
}

61 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
input_Try=4 input_Try=7 ,( :
input_Try= -3( 1 1
:
input_Try ) ( .
) ( . input_Try= -3
) 3-( input_Try if (input_Try>0)
) ( ) else(
++C
include<iostream.h> # Main() {
1.int input_Try; 2.cin>> input_Try;
if (input_Try > 0) f )if( f) else ( E if (input_Try %2==0)
3.cout<<"the number is positive even"; else 4.cout<<" the number is positive Odd"; else 5.cout<<"the number is less than zero"; }
C
1.int input_Try; 2.scanf("%d", input_Try);
if (input_Try>0) f )if( f) else ( E if (input_Try %2==0) 3.printf(" the number is positive even "); else 4. printf(" the number is positive Odd "); else 5. printf("the number is less than zero") }
the number is less than zero
62 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ..( ) (
) if( if (input_Try>0) (
if (input_Try %2==0) else ( f
)1 ) if—else(
input_Try=7
) ( input_Try if (input_Try>0) if (input_Try %2==0)
) ( K .
( ) ( ( if (input_Try %2==0)( ) ( (
if (input_Try>0)
input_Try=4
) ( input_Try if (input_Try>0) if (input_Try %2==0)
( else ) (
if (input_Try>0)( ) ( (

the number is positive even
the number is positive Odd
63 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )if—else if( .
. 1 . ) else if( 1
. ) if(

" " Statement1 condition1 Statement2 condition2 condition1
" " Statement2 condition2 condition1
" " condition2 condition2 condition1
" " Statement3 condition3
" " else conditions
if –else if
If ( condi7on1 )
}
)// {
Statement4
//
64 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
( : )
:
) ( .
number_enter )( )( .
) number_enter ) ( (

number_enter=6
) if—else if( ( ) (
else ( else
)
number_enter=14
) 6( ) 5(
++c c #include<stdio.h>
main()
{
}
}
4. cout<<" Acept Devide to 5" ;
else if (number_enter % 7==0)
{
}
}
Acept Devide to 7=9
65 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
number_enter=15
1 ) ( ) (( ) 3(
6 7 B
K . )else(
( ). (
number_enter=20
) (
number_enter=19
) ( ) else(

else)( ( ) (
Acept Devide to 3
Acept Devide to 5

66 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
f ) ( f : . ) (
: K 1 ) if—else if(
++ C
#include<iostream.h> main() {int Day_Number; cin>> Day_Number ; if ( Day_Number==1) cout<<"sunday" ; else if ( Day_Number==2) cout<<"monday" ; else if ( Day_Number==3) cout<<"Tuerday" ; else if ( Day_Number==4) cout<<"wednesday" ; else if ( Day_Number==5)
cout<<"thursday" ; else if ( Day_Number==6) cout<<"fridaay" ; else if ( Day_Number==7) cout<<"saturday" ; else
cout<<"error" ; }
C
#include<stdio.h> main() {int Day_Number; scanf("%d",& Day_Number ); if ( Day_Number==1) printf("sunday"); else if ( Day_Number==2) printf("monday"); else if ( Day_Number==3) printf("Tuerday"); else if ( Day_Number==4) printf("wednesday"); else if ( Day_Number==5)
printf("thursday"); else if ( Day_Number==6) printf("fridaay"); else if ( Day_Number==7) printf("saturday"); else
printf("error"); }
)Thursday(
67 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(Switch—Case
. )switch( ) Case( )Case( ) Case( 1
)Case ( )Case ( )if else if( .)default(

Truth of Case)(: condition Case )Statement ( .
Number )(
Switch--Case
if --elseif
Switch(Truth of Case )
{
//
Switch(Day_Number) Case 51: //do some thing Break;

68 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) Switch—Case(
( ) do some thing( .Break)( ) Case(
" " Statement1 condiHon1 •
Statement2 condiHon2 condiHon1 • " "
" " default conditions •
) case( ) Break(K •
)switch (
1 ( :
1.Ali: his names Ali kammel,20 Year old, third stage
1.Salem: his names Salem kammel,18 Year old, third stage
1.Hussien: his names Hussien Ahmmed Taleb,21 Year old, third stage eng.Computer
Switch(Capatat_symbol) Case 'a': //do some thing Break;
++ C
#include<iostream.h> main() {1.char index_of_Name; 2.Cout<<"Enter First Chat of Student name: "; 3.Cin>> index_of_Name ; 4.switch( index_of_Name ) { 5.case 'A': 6.Cout<<" his names Ali kammel,20 Year old, third stage " ; 7.break; 8.case 'S': 9.Cout<<" his names Salem kammel,18 Year old, third stage " ; 10.break; 11.case 'H': 12.Cout<<" his names Hussien Ahmmed Taleb,21 Year old, third stage eng.Computer " ; 13.break; 14.default: 15.Cout<<"You Not have saved names in this index" ; }}
69 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) index_of_Name( ) ( .
) ( .

) ( ) ( . )switch(
1K ) Ail( 1 ) ( .
)'A'( K
case ) ( ) ( .

C
#include<stdio.h> main() {1.char index_of_Name; 2.printf("Enter First Chat of Student name: "); 3.scanf("%c", index_of_Name) ; 4.switch( index_of_Name ) { 5.case 'A': 6. printf(" his names Ali kammel,20 Year old, third stage ") ; 7.break; 8.case 'S': 9. printf(" his names Salem kammel,18 Year old, third stage ") ; 10.break; 11.case 'H': 12. printf(" his names Hussien Ahmmed Taleb,21 Year old, third stage eng.Computer ") ; 13.break; 14.default: 15. printf("You Not have saved names in this index" ) ; }}
70 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
1 ) if –else if( :
)switch—case(
++ C
#include<iostream.h> main() {int Day_Number ; Cin>> Day_Number ; switch( Day_Number ) { case 1:cout<<"sunday" ; break; case 2: cout<<"monday" ; break; case 3: cout<<"Tuerday" ; break; case 4: cout<<"wednesday" ; break; case 5: cout<<"thursday" ; break; case 6: cout<<"fridaay" ; break; case 7: cout<<"saturday" ; break; default: cout<<"error" ; } }
C
#include<stdio.h> main() {int Day_Number ; scanf("%d",& Day_Number ); switch( Day_Number ) { case 1: printf("sunday"); break; case 2:printf("monday"); break; case 3:printf("Tuerday"); break; case 4:printf("wednesday"); break; case 5:printf("thursday"); break; case 6:printf("fridaay"); break; case 7:printf("saturday"); break; default: printf("error"); } }
)Thursday( ) (
71 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
..! Switch
case ) if( :


++C #include<iostream.h> main() {int Number,Chose_check ; Cout<<"enter your number: "; Cin>> Number ; Cout<<"enter Your Selected check (1) or 2:" ; Cin>> Chose_check ; switch( Chose_check ) { case 1: { if ( Number % 2== 0) cout<<"the number is even"; else cout<<"the number is odd";} break; case 2:{ if ( Number >0) cout<<"the number is more than zero"; else cout<<"the number is less than zero";} break; default: cout<<"Error Choice";}}
C #include<stdio.h> main() {int Number,Chose_check ; Printf("enter your number: "); Scanf("%d",&Number) ; Printf("enter Your Selected check (1) or 2:") ; Scanf("%d", &Chose_check) ; switch( Chose_check ) { case 1:{ if ( Number % 2== 0) Printf("the number is even"); else Printf("the number is odd");} break; case 2:{ if ( Number >0) Printf("the number is more than zero"); else Printf("the number is less than zero");} break; default: Printf("Error Choice");}}

72 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)loop(
!
:!

!
%100
H :!
:
73 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:7 )(For--Loop .
) if(
6 . ) For(
.
• )Initializing :( . ) Ki=0(
• )Boolean_Expression :(
) Boolean_Expression( ) for(
)True ( )False ( .
K )i<5 ( )i=5 ( 1 )False(
• )Update:( )loop( . K)i++ ( )i--( 7 7 7 7 6 )--i++ or ++i , --i or i(

• )statement :( .
.
........ )For(
) Update( ) Initializing( ) Boolean_Expression(
.
. (;;)for ( )for(
For--Loop

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. )4
. 1
K K
B

) ( ) (
++c #include<iostream.h> main()
{1.int i;
2.for (i=0; i<5; i++) 3.cout<<i<<"\t"; }
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
0( ) 4( ) 0(
integer ) i(
1 ( ) .1,2,3,4, 0(

B
( loop )
) . {}(
)i=0(


main()
3.prinC("%d\t",i);
}
74 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
:
) ( .
)( .

) 0,2,4(
B
) ( .


c

75 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. )0 1 2 3 4 ( ) 0( ) 4( :
:
:
integer ) i( ) ( . . 1 )( .
1 K K ( ) .4,3,2,1,0(
) 4,2,0(

:
) ( ) ( . )(
++C #include<iostream.h> main()
{1.int i;
C Include<stdio.h>#
3.printf("%d\t",i);
}
76 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)100—0( :
. : ( ( )(
) )( ) ( ) ( K ) (
: ) integer( ) n( ) ( . 1 ) integer( ) sum( ) ( .
1 ) sum( ( (:
( 7
) K ( ( ) ( . ) n=1( . ) sum( )( .
)sum=0+1 ( )n=3 ( )sum ( K )sum=1+3( K . ) sum=4+5( K ) sum( ) n=5(
( ) ( .
) ( ) ( . )( :
)( ) 100—0( L 7
++C #include<iostream.h> main()
{1.int n;
2.int sum=0;
3.for (n=1; n<100; n=n+2) 4. sum += n ;
5.Cout<<"sum="<<sum; }
{1.int n;
2.int sum=0;
3.for (n=1; n<100; n=n+2) 4. sum += n ;
5.printf("sum=%d",sum); }
Sum=2500

77 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
:
)For ( )

:
) n( ) ( . 1 ) integer( ) sum( ) ( .
)( ) ( )( .
) ( . ) ( . ) ( . ) ( .
) ( . )( : ) (
++C #include<iostream.h> main()
{1.int n,aveg,input_number;
6. aveg=sum/10;
7.Cout<<" aveg ="<< aveg ; }
{1.int n,aveg,input_number;
4. scanf("%d", &input_number); 5. sum += input_number ;}
6. aveg=sum/10;
7. printf(" aveg =%d", aveg ); }
78 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
( :
( 1 : K ( 7 ) .
)
.
: ) ( . ) ( .
( ) ( ) (
)( . ( ) ( .
++C #include<iostream.h>
9.else
C #include<stdio.h>
9.else
10.printf(" The Number is prime" ); }
79 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
1 ) ( . )(
) ( .

. ) ( : B( ( 6 B) 7) 4, 3 , 2
) ( 7 7 ) ( 7 7 ) ( 6 ) booleanx=0( 6
) (
. :
K ( ( : n!=n*(n-1)) ( ) .1*2*3*4*5*6=!6)(
1
++C #include<iostream.h>
5.fact = fact *i;
6.printf("factoral=%d", fact );}
80 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
)i( ) ( .
)fact( ) ( .
) ( .
)2,3,4,5, 1( ) ( .
K )( . ) fact( ) (fact=1*1=1 ) fact( (
)(fact=2*3=6 ) fact( ) (fact=1*2=2
) ( .

. ) ( :
B ) ( )(
) ( i=1
Fact=1*i
Fact=2*3=6
81 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)1234567654321( :
) ( :
:
) ( .
) ( ) ( ) ( ) ( .
( 1 6 ) ( . ) i=7( ) i(
( ( ) ( )( 1) ( ) .
) ( . )( : . ) (
++C #include <iostream.h>
4.for(j=i;j>0;j--)
5.printf("%d",j);}
82 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(For--Loop .
( ( ) for( (
) for(( ) for( )while ,do—while
. ( K
.

1 )( ) for( )( ) for(
)Statement2 ( )Statement1 ( .
) i=0(1
) ( ) ( ( ).(
)(1 )Statement2( ) (
) ( ) (
)Statement1( )( ) K )
) (
For--Loop
{
{
4.Statement1
5.}

83 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) i( ) (

)0,1,2,3,4( ) j( ) i=0(
)0,1,2,3,4( ) j( ) i=1(
) 0,1,2,3,4( ) j( ) i=2(
) 0,1,2,3,4( ) j( ) i=3(
)0,1,2,3,4( ) j( ) i=4(

** . 1


84 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. )( )( :
: 1 ( 1
.....! . 1
:
) K K( ) i( ) ( . 1 1 ) j(
) ( ) ( ) ( ) ( . 1 (

) ( . K ) )"( " ( 1
) ( ) (
++C #include<iostream.h>
{3.cout<<"Multiply tabel for("<<i<<").\n-------------------------------\n";
4.for (j=1; j<=10; j++) 5.Cout<< j<<" * " <<i<<"="<<i*j<<"\n";
6.Cout<<"\n";}
main()
{3.prinC("Multiply tabel for(%d).\n-------------------------------\n", i);
4.for (j=1; j<=10; j++) 5.prinC("%d * %d=%d\n",i, j, i*j);
6. printf("\n");}
}
85 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ( ) ( . ) ( ) ( 1) ( 1 ) ( ) (

) (1 ) ( ) ( . ) ( ) (
" ( 1 ) )"(
( ) ( . 1 ) (
))"( " (
)..( ) ( ) (
K ) ( ) ( K 1 ) (
. ) ( ) (
)(
)(
)(

86 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. :
) ( ) ( ) ( : ( .
) ) 2,3,4,5,6( 1
) i=2( K 1
) i=3( ) 1( )(
. ) 12( )(
:
) ( . ) ( . 1) (
) ( . ) 12( ) 1(
) 1234( ) 123(
) ( ) ( ) ( ) ( . .
++ C #include<iostream.h>
4.cout<<j ;
5.cout<<"\n" ;}
4.printf("%d",j);
}
87 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. :
: . K
) 1( 1
:
) empty( ) star( 1 ) ( .
1) ( ) (
) ( . () ( ( ( 1 () (
)1( . ) (
. ) ( ) ( ) ( ) ( ) 1,2(
) ( ) 1,2,3( . . ) (K K
++ C #include<iostream.h>
{3.for( empty =1; empty < star ; empty ++)
4.cout<<" " ;
4.printf(" " );
}
88 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)* ( :
) 0,0(
. .......
{
Cout<<"\n";}
{
for (j=0; j<5; j++) printf("( %d , %d ) ",i,j);
printf("\n");}
}
89 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(Break
( ( ( ).

) 75( ) 200—1( :
.
) Break(
for (Initializing1; Boolean_Expression1; Update1)
{3.If (i==75)
}
{3.If (i==75)
}
90 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ( ) ( ) ( ) ( .
) ( ) ( )( . .1 K ) ( (
) ( ( K ) ( . ) ( 1 ) (
. ) (
1 ) ( .
.. ) Break(
) Statement1((
. .
) Break(
for (Initializing1; Boolean_Expression1; Update1)
}
K )(

91 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) (;;)for 7 )L )for ( K • ( .
K ( ( (
(
:

++ C #include<iostream.h>
printf("password is error try agin\n…");}}
92 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(continue
( ) Statement( ). ( (

) 75( ) 200—1( :
.)((
) continue(
for (Initializing1; Boolean_Expression1; Update1)
{3.If (i==75)
}
{3.If (i==75)
4.con7nue; 5.printf("%d\t",i) ;}
}
93 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
) ( .
) ( ) ( ) ( ) ( .
) ( ) ( ) ( . ( ) (
1) ( ) ( .
. ( ) ( .

) ( 1

94 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(go to
(: ) .
K ) ( )Statement3 Statement2 Statement4( `) Statement5(
go to)( ) 14—0( :
) go to(
6.goto mpointn;}
95 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
) ( .
) goto( ) goto( )( . .
) ( .
) ( .
) ( ) ( . ) (
.
) Statement3 Statement2 Statement4(
) go to(
Statement5;}
96 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(While
.)For(
• )Initializing :( . ) Ki=0(
• )Boolean_Expression :(
) Boolean_Expression( ) while( )True ( )False ( .
K )i<5 ((
• )Update :( )loop .( K)i++ ( )i--(
• )statement :( .
.
........) while(
) Update( ) Initializing( ) Boolean_Expression(
.
. while(1) ( )while( • )4 0( ) 4( ) 0( :
while--Loop
Initializing
{1.int i=0;
4.i++;} }

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

( ) .1,2,3,4, 0(
.

7 )i++ ++i ( B
) ( ) (
C Include<stdio.h>#
}
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. integer ) i(
1
)0,2,4( K K

. ( loop ) (
B .)
) For(
. )( :
)i=0(
C
97 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
) ( .
)( .
K K
B
) ( .
) ( .
) ( (
*
:

98 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)0 1 2 3 4 ( ) 0( ) 4( :
:
:
integer ) i( ) ( . . 1 )( .
) ( while(i>=0)
K ( ) .4,3,2,1,0( 1
) 4,2,0( K ) ( . ) ( .

:
) ( ) ( . )(
++C #include<iostream.h> main()
{1.int i=4;
4.i--;} }
}
99 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)100—0( :
. : )(
: ( ) integer( ) n( ) ( . 1 ) integer( ) sum( ) ( .
1 ) while(n<100( ) ( . ) n=1( . ) sum( ) ( .
)sum=0+1 ( )n=3 ( )sum ( K )sum=1+3( .) sum=4+5( K ) sum( ) n=5(
) ( . ) ( .
) ( ) ( . )( :
)( ) 100—0( L 7
++C #include<iostream.h> main()
{1.int n=1;
2.int sum=0;
5. n=n+2;}
{1.int n=1;
2.int sum=0;
5. n=n+2;}

100 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
:
( ) while(

:
) ( . 1 ) integer( ) sum( ) ( .
( ) n( ) ( )( . ) ( . ) ( . . ) ( . ) ( . ) ( .
++C #include<i ostream.h> main()
{1.int aveg,input_number;
6.n++;} 7. aveg=sum/10;
{1.int aveg,input_number;
6.n++;}
8. printf(" aveg =%d", aveg ); }
101 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(While .
( .) for(
) for,do—while ( ) while(
. ) while(( ) while(
( K .

) statement( ) While( ) While(
) j( ) i=1( ) 0,1,2,3,4( ) j( ) i=0(
) j( ) i=3( ) 0,1,2,3,4( ) j( ) i=2( ) 0,1,2,3,4(
)0,1,2,3,4( ) j( ) i=4( ) 0,1,2,3,4(
** . 1
while--Loop
Initializing1;
While(Boolean_Expression1)
statement j++;}
i++;}
102 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) .( ) ( :
.) ) for( (:
:
) K K( ) i( ) ( . 1 1 ) j(
) ( ) ( ) ( ) ( .
) ( . K ) )"( " ( 1
) ( ) (
)( ) while( ) while( ) ( .
++C #include<iostream.h>
4. j=1;
7.j++;}
4. j=1;
5.while( j<=10) { 6.printf("%d * %d=%d\n",i, j, i*j);
7.j++;}
}
103 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ( ) ( . ) ( ) ( 1) ( 1 )( ) (
) (
) (1 ) ( ) ( . ) ( ) (
" ( 1 ) )"(
)( ) ( .
( ) ( . 1 ) (
))"( " (
)( ) ( .
)..( ) ( ) (
K ) ( ) ( K )( ) ( ) (
. ) (
)(
)(
)(

104 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(Do-- While
) Do—While( 7B ) . while() For(
. ) while( ) For(
• )Initializing :( . ) Ki=0(
• )Boolean_Expression :(
) Boolean_Expression( ) while( )True ( )False ( .
K )i<5 ((
• )Update :( )loop .( K)i++ ( )i--(
• )statement :( .
.
........) do --while (
) Update( ) Initializing( ) Boolean_Expression(
.
. -- while(1) do ( )do--while( • )4 0( ) 4( ) 0( :
--while—Loop Do
{1.int i=0;

Step By step to Learn C or C++ By:Hussien Ahmmed Taleb

) 0,2,4(K K
B

) ( ) (
C include<stdio.h>#
}
Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. integer ) i(
) ( 1
K K (
B
) ( . . ) while , For (
. )( :
)i=0(
C
105 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
)( .
( ) .1,2,3,4, 0(
.
B
) ( . *
:

106 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)0 1 2 3 4 ( ) 0( ) 4( :
:
:
integer ) i( ) ( . . 1 )( .
) ( while(i>=0)
K ( ) .4,3,2,1,0( 1
) 4,2,0( K ) ( . ) ( .

:
) ( ) ( . )(
++C #include<iostream.h> main()
{1.int i=4;
}
107 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)100—0( :
. : )(
: ( ) integer( ) n( ) ( . 1 ) integer( ) sum( ) ( .
1 ) do-- while(n<100( ( ) ( . ) n=1( . ) sum( ) ( .
)sum=0+1 ( )n=3 ( )sum ( K )sum=1+3( .) sum=4+5( K ) sum( ) n=5(
) ( . ) ( .
) ( ) ( . )( :
)( ) 100—0( L 7
++C #include<iostream.h> main()
{1.int n=1;
2.int sum=0;
6.Cout<<"sum="<<sum;}
{1.int n=1;
2.int sum=0;
6.printf("sum=%d",sum);}
Sum=2500

108 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: )(do-- While .
( . ) for while(
. )while , for , do—while (
)do-while () )do-while ( .
K ( .

) -do-while ( ) do--While(
)statement ( )i=0 ( )j ( )( ) 0,1,2,3,4i=1 (
) i=3( ) 0,1,2,3,4( ) j( ) i=2( ) 0,1,2,3,4( ) j(
)0,1,2,3,4( ) j( ) i=4( ) 0,1,2,3,4( ) j(
** . 1
do--while
Initializing1;
do

109 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) .( ) ( :
.) ) for( :(
:
) K K( ) i( ) ( . 1 1 )j(
) ( ) ( ) ( ) ( .
) ( . K ) )"( " ( 1
) ( ) (
) --while do( ) do--while( ) ( .
)(
4. j=1;
7.j++;} while( j<=10);
main()
4. j=1;
7.j++;} while( j<=10);
}
110 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ( ) ( . ) ( ) ( 1) ( 1 )( ) (
) (
) (1 ) ( ) ( . ) ( ) (
" ( 1 ) )"(
)( ) ( .
( ) ( . 1 ) (
))"( " (
)( ) ( .
)..( ) ( ) (
K ) ( ) ( K ) ( ) ( ) (
. ) (
)(
)(
)(

111 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)..for,while,do—while(
) Do—While( (K . False) ( ) True (
)For ( )while ( ) True ( . False) (
.
) ( ) !Hello( :
.
: ). ) 1,2( (
.) For(
++C #include<iostream.h>
4.cout<<"Hello!\n";
4.prinC("Hello!\n");

112 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
.) While(
.) Do--While(
++C #include<iostream.h>
}
}
113 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
K 1 (
) ( .
( ) ( ) ( ) ( 1 ) for,while(

( ) ( ) ( ) ( 1 ) do--while(



) 0( .
) ( ( 1 ) for,while( ( ( ( ) false=0=>1( ) i<= input_numbe(
(.

) ( ( 1 ) do--while( ) ( 1. ( (





:!

!
%100
H:!
:
115 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:6 6 . ).18126( ) x=15(
< data 18125
15 18126
data 18127
. ) x( K K .
K
K . (
• )arrrayname (
• )size of array (
• )Type ( .
)integer( )integer (7
).first_array( ) integer( :
) 18126(
< data 18125
18126 first_array [0]
18127 first_array [1]
18128 first_array [2]
18129 first_array [3]
18130 first_array [4]
int first_array [5];

first_array

116 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)18126( )first_array [0]( K ....) 18127( )first_array [1](
)first_array [0]( K **
)index( .
• K ) 79(
1) ( )index=2( K . 1 ) index(
)79(
< data 18125
18126 first_array [0]
18127 first_array [1]
data 18131
) ( •

++C C Printf("%d", first_array [2]); cout<< first_array [2];
1 float
first_array [index]

117 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb


< data 18125
34 18126 first_array [0]
26 18127 first_array [1]
43 18128 first_array [2]
23 18129 first_array [3]
54 18130 first_array [4]
data 18131
. ) first_array [0]=34( 6
. 1 :
:
) ( .
) ( ) ( . )first_arry[0]( ) first_arry[i]( ) i=0(
)1 ( )i=5( 1
int first_array [5]={34,26,43,23,54};
++c c #include<stdio.h>
main()
5.for (i=0;i<6;i++)
#include<iostream.h>
5.for (i=0;i<6;i++)
6.cout<< first_arry[i]<<"\t";}
first_array
118 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) enter( )( . ) ( .
). ( ) ( . )first_arry[0]( ) (
)first_arry[2]( ) ( )first_arry[1]( ) ( .

)first_arry[5]( 7 ) ( )first_arry[4]( ) (
) (
L
: ( (
5.for (i=5;i>=0;i--)
)first_arry[2] ( ) first_arry[5] ( L // ;int item
Item= first_arry[5];


119 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. 1 :
: 1
:
) ( .
K 1 ( ) ( . ) ( .
)sum=sum+array1[0]( ) i=0( )( )(
.....! K
) ( .
++c c #include<stdio.h>
main()
2.for (i=0;i<5;i++)
3.scanf("%d",& array1[i] );
4.for (i=0;i<5;i++)
5.sum=sum+array1[i];
#include<iostream.h>
2.for (i=0;i<5;i++)
6.cout<< "sum of array item="<<sum;}
) 11,43,23,56,45( When i=0
sum=sum+array1[0]; sum=0+11 sum=11 When i=1
sum=sum+array1[1]; sum=11+43 sum=54
When i=2
When i=3
When i=4
sum=sum+array1[4]; sum=133+45 sum= 178
120 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
. 1 :
: . .
(
. K
) (
(
++c c #include<stdio.h>
main()
#include<iostream.h>
8.cout<< "max number in array1 is="<<max;}
) 11,32,22,32,43,31,23( ) ( 4. max=array1[0]; max=11
5.When i=0
6. ( array1[0]=11 ) ( max=11 ( ( (
) ( .7 ( 5.When i=1
6. ( array1[1]=32 ) ( max=11 ( 7
7.max =array1[1] max=32 // 5.When i=2
6. ( array1[2]=22 ) ( max=32 ( ( (
) ( .7 ( 5.When i=3
6. ( array1[3]=32 ) ( max=32 (( (
) ( .7 ( 5.When i=4
6. ( array1[4]=43) ( max=32 ( 7
7.max =array1[4] max=43 //
5.When i=5
6. ( array1[5]=31 ) ( max=43 ( ( (
) ( .7 ( 5.When i=6
6. ( array1[6]=23 ) ( max=43 ( ( (
) ( .7 (
121 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
:
) ( . ) (
) max( ) ( .
. ) max(
) ( )( . 1 ) ( ) max(
)max( ( K

)max (
Array1[6] Array1[5] Array1[4] Array1[3] Array1[2] Array1[1] Array1[0]
23 31 43 32 22 32 11
*
) ( .
) (
1
) (
)(
6.if (array1[i] < max )
array1[i]=2* array1[i];


122 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
K .
( . ) ( ) ( K
:
:
) ( .
. ) ( .
array1[i]= array1[i] /4;
++c c #include<stdio.h>
main()
4.prinC("%d\t", array1[i] );}
}
4.cout<< array1[i]<<"\t";}
}
) ( ) i=3( array1[3]= array1[3]+5; array1[3]=32+5 array1[3]=37
123 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: 1 1
) array[0]=50,array[3]=2 K (
) ( 1 ) ( 1 1
) (

array[4] array[3] array[2] array[1] array[0]
64 6 85 42 45
7 7 7
..
: 6 .
1 .
array[4] array[3] array[2] array[1] array[0]
64 6 85 42 45
1
1 .
array[4] array[3] array[2] array[1] array[0]
64 6 85 45 42
( 1
1 .
array[4] array[3] array[2] array[1] array[0]
64 6 85 45 42
1
1 .
array[4] array[3] array[2] array[1] array[0]
64 42 85 45 6
( 1

124 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: .
.
array[4] array[3] array[2] array[1] array[0]
64 42 85 45 6
. (
.
array[4] array[3] array[2] array[1] array[0]
64 42 85 45 6

.
array[4] array[3] array[2] array[1] array[0]
64 45 85 42 6
(
: .
.
array[4] array[3] array[2] array[1] array[0]
64 45 85 42 6

.
array[4] array[3] array[2] array[1] array[0]
64 85 45 42 6

6 : .
array[4] array[3] array[2] array[1] array[0]
64 85 45 42 6

array[4] array[3] array[2] array[1] array[0]
85 64 45 42 6
125 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
K (
.. :
: 6
.
:
)j( ) i( ) ( .
( ) ( .
) ( ) ( .
1 ( 1 ) ( . ). i<5-1( K ( 1
) (
) ( . . 1

) ( . ) (
++c c #include<stdio.h>
int main()
4. for (i=0;i<5;i++)
5.scanf("%d",&array[i]) ;
9.item =array[j];
13.for (i=0;i<5;i++)
14.prinC("%d\n",array[i]);}
3.cout<<"Here is the Array befor sorted enter it\n";
4. for (i=0;i<5;i++)
5.cin>>array[i] ;
9.item =array[j];
13.for (i=0;i<5;i++)
14.cout<<array[i]<<"\n";}
126 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) ( .
) (
) ( K 1 ( ) K K 1( K

8.if (array[j] >array[i])
6. for ( i=0;i<3-1;i++)
7.for ( j=i; j<3;j++)
6. for ( i=0;i<5-1;i=i+2)
7.for ( j=i; j<5;j=j+2)



)(array[2]

127 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
B 6 ) ( :
1 : ) 6 (
:
K K ) ( . K )( ( ) ( (
) bol=0( 1 1 1 ) ( . ) ( ) (
) bol( ) ( .
++c c #include<stdio.h>
#include<conio.h> main()
2.for(i=0;i<5;i++)
3.a[i]=getche();
4.for(i=0;i<5;i++)
8. prinC("\nthe data is symmetric");
9.else 10.prinC("\nthe data is no symmetric");}
#include<iostream.h>
2.for(i=0;i<5;i++)
3.a[i]=getche();
4.for(i=0;i<5;i++)
8. cout<<"\nthe data is symmetric";
9.else 10.cout<<"\nthe data is no symmetric";}
128 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)c( 1) b( ) a( ) ( :
1) a( 1 K :
) c( ) a( . . ) b(
:
) count_b( ) b( ) count_a( ) a( ) ( .
1 ) count_c( ) c(
) a( ) ( .
) 11—5( ) a( ( ) ( .
) ( ) b( ) ( . ) ((
)
) c( ) ( .
) (10( ) 9(
)
main()
{1.int count_a, count_b=0, count_c=0,a[5],b[5], c[5];
2.for( count_a=0; count_a<5; count_a++) 3.scanf("%d",&a[ count_a]);
4.for( count_a=0; count_a<5; count_a++) 5.if ( a[ count_a] %2==0)
{6.b[ count_b ]=a[count_a]; 7.count_b= count_b+1;} 8.else
{9.c[ count_c ]=a[count_a];
10.count_c= count_c+1;} 11.prinC("items in array b is\n"); 12.for( count_a=0; count_a< count_b; count_a++)
13.prinC("%d\t", b[ count_a ]);
14. prinC("\nitems in array c is\n");
15.for( count_a=0; count_a< count_c; count_a++)
16. prinC("%d\t", c[ count_a ]);}
#include<iostream.h>
main()
{1.int count_a, count_b=0, count_c=0,a[5],b[5], c[5];
2.for( count_a=0; count_a<5; count_a++) 3.cin>>a[ count_a];
4.for( count_a=0; count_a<5; count_a++) 5.if ( a[ count_a] %2==0)
{6.b[ count_b ]=a[count_a]; 7.count_b= count_b+1;} 8.else
{9.c[ count_c ]=a[count_a];
10.count_c= count_c+1;} 11.cout<<"items in array b is\n"; 12.for( count_a=0; count_a< count_b; count_a++)
13.cout<< b[ count_a ]<<"\t";
15.for( count_a=0; count_a< count_c; count_a++)
16.cout<< c[ count_a ]<<"\t";}
129 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)b( ) ( .
( )7(
)c( ) ( .
( )(

1 ( ........!


130 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
: 6
) index( ( . (
) K ) 2*3(K ( `
1 ) ( ).1,0( 1
K . K :
K (
• )arrrayname (
• )row( )columns( 1 1 • )Trype of array ( .
integer (7( ) integer(
).first_array( )2*3( ) integer( :
K
)1( 1 ) 0( : K . ) 2( ) 1( 1 ) 0(
)2*3( 0 1 0 (0,0) (0,1)
1 2
int first_array [3][2];
)2*3( 0 1 first_array [0][1] first_array [0][0] 0
1 2
first_array [1][1] first_array [1][0] first_array [2][1] first_array [2][0]


131 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
1 .
) 18126(
< data 18125
18126 first_array [0][0]
18127 first_array [0][1]
18128 first_array [1][0]
18129 first_array [1][1]
18130 first_array [2][0]
18131 first_array [2][1]
data 18132
)18126( )first_array [0][0]( K
.... )18127( )first_array [0][1](
)first_array [0][0]( K
• )index_row( )i(.
• )index_columns ( )j(.
6 ) 79( :
1) 2( )index_row=1( K (
1) 1( )index_columns=0( K
( 1
first_array [index_row][index_columns]

first_array

132 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)79(
< data 18125
18126 first_array [0][0]
18127 first_array [0][1]
18129 first_array [1][1]
18130 first_array [2][0]
18131 first_array [2][1]
++C Cout<< first_array [2][1];
C
Printf("%d", first_array [2][1]);
1 float


< data 18125
34 18126 first_array [0][0]
26 18127 first_array [0][1]
43 18128 first_array [1][0]
23 18129 first_array [1][1]
float first_array [5][3];
int first_array [2][2]={{34,26},{43,23} };

first_array


133 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
K*( (
( : ) 3*4( :
. )( .
1 K )3*4( ) ( .
1 K 1 K ) ( .
1 .
7 ( ) 5*5(
( 1
( . )(3,3),(2,2),(1,1),(0,0 (4,4),(
int first_array [2][2]={0 };
++C



134 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
) j( ) i(
**
K )(4=4+0),(4=3+1),(3=2+2),(4=1+3),(4=0+4 (
. ( K
1
**
6 B )(3,4),(1,4),(1,3),(1,2),(0,4),(0,3),(0,2),(0,1((

If(i==j)
// print the diagonal
(0,4) (0,3) (0,2) (0,1) (0,0)
(1,4) (1,3) (1,2) (1,1) (1,0)
(2,4) (2,3) (2,2) (2,1) (2,0)
(3,4) (3,3) (3,2) (3,1) (3,0)
(4,4) (4,3) (4,2) (4,1) (4,0)
If(i+j=4)
If(i<j)

135 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
**
6 B )(4,3),(4,1),(3,1),(2,1),(4,0),(3,0),(2,0),(1,0( (

**
( K K (
. )(3,0),(2,1),(2,0),(1,2),(1,1),(1,0),(0,3),(0,2),(0,1),(0,0(

(0,4) (0,3) (0,2) (0,1) (0,0)
(1,4) (1,3) (1,2) (1,1) (1,0)
(2,4) (2,3) (2,2) (2,1) (2,0)
(3,4) (3,3) (3,2) (3,1) (3,0)
(4,4) (4,3) (4,2) (4,1) (4,0)
If(i>j)
If(i+j<4)


136 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
( 1 1 (
. )(1,4),(2,4),(2,3),(3,4),(3,3),(3,3),(4,4),(4,3),(4,2),(4,1(

1 **
) j=0( 1 1
) j=3( 1
6
) i=0( 1
)i=3( )i=2(

If((j==0)||(j==3))
If((i==0)||(i==2) ||(i==3))
1

137 Step By step to Learn C or C++ By:Hussien Ahmmed Taleb
)5*5( :
) i==j( :

:
) ( .