0% found this document useful (0 votes)
39 views

Using System Class (Static Void Main (Int I 1 While (I 5) (Console - Writeline (I) I ++ ) ) )

The document discusses the 'for' loop in programming. It explains that 'for' and 'while' loops function similarly but 'for' is more concise. The structure of a 'for' loop is explained as having three independent statements separated by semicolons: the first statement initializes the counter variable, the second statement defines the condition to be true for the loop to run, and the third statement increments or decrements the counter. Examples are given to illustrate how 'for' loops work and their advantages over 'while' loops.

Uploaded by

fofo1975
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Using System Class (Static Void Main (Int I 1 While (I 5) (Console - Writeline (I) I ++ ) ) )

The document discusses the 'for' loop in programming. It explains that 'for' and 'while' loops function similarly but 'for' is more concise. The structure of a 'for' loop is explained as having three independent statements separated by semicolons: the first statement initializes the counter variable, the second statement defines the condition to be true for the loop to run, and the third statement increments or decrements the counter. Examples are given to illustrate how 'for' loops work and their advantages over 'while' loops.

Uploaded by

fofo1975
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

:

. for

, while for
.
, for
, while :
; using System
class whileloop
{
)( static void Main
{
; int i = 1
)while ( i <= 5
{
;)Console.WriteLine (i
;i ++
}
}
}

for :
; using System
class forloop
{
)( static void Main
{
)for ( int i =1; i <= 5; i++
;)Console.WriteLine (i
}
}

!!!
:
)for ( int i =1; i <= 5; i++
;
:
) ; ; ( for
: ) ( ,
, , .

for
, for . scope

;using System
class checkfor
{
)(static void Main
{
;)for (int i=0; i<= 5; i++
;)Console.WriterLine(i
}
}

, for
, i .
:
.
: . for
:

1 , ,
for .
2 ,
)(,
:
)for ( int x=1, int y=4; x<5 ; y--,x++
3 :
for ..
4 for } {
:
)for ( int i=1;i<=5;i++
{
;)Console.WriteLine("Hello"+i
;)"Console.WriteLine("Just Examle
}

: for
for 1 100 :1
)for (int i=1; i<=100; i++
100 1 :1
)for(int i=100; i>=1; i--
7 77 7 :
)for(int i=7; i<=77; i+=7
20 2 2 :
)for(int i=20; i>=2; i -=2
20171411852 :
)for(int i=2; i<= 20; i += 3
0112233445566778899 :
)for(int i=99; i <= 0; i -= 11
, :
2 , 100 ........ 12+10+8+4+2
, ?
:
//
;using System
using System.Windows.Forms; //
class Sum
{
)(static void Main
{
int sum = 0; //
)for ( int number = 2; number <= 100; number += 2
;sum += number
//
MessageBox.Show( " The Sum is " + sum,
"Sum Even Integer from 2 to 100",
MessageBoxButtons.OK,
;)MessageBoxIcon.Information
}

, Show
, ,
, ,
:

MessageBoxButtons.OK
MessageBoxButtons.OKCancel
MessageBoxButtons.YesNoCancel

MessageBoxButtons.RetryCancel
MessageBoxButtons.AbortRetryIgnore

:

MessageBoxIcon.Information

MessageBoxIcon.Exclamation

MessageBoxIcon.Question

MessageBoxIcon.Error

MessageBox .
, : 1000 ,
, , %5
,
, ]
[ ...
:
=

) (1+

:
;using System
;using System.Windows.Forms
class Interest
{
)(static void Main
{
;decimal amount,principal=(decimal)1000.00
//
double rate= 0.05; //
string output; //
;"output = "Year \t Amount \n
)for (int year =1; year <= 10; year ++
{
;)amount = principal * (decimal)Math.Pow(1.0 + rate, year
;"output += year + "\t" + String.Format("{0 :c}",amount)+ "\n
}
MessageBox.Show(output, "Interest",
MessageBoxButtons.OK,
;)MessageBoxIcon.Information

: decimal ??? double


decimal 27
16 double , . decimal
decimal double double decimal
, : 1000.00
double , principal
Pow double decimal
.
System.Math Pow
, :
x3
x7
(x + 7)y

)Math.Pow(x,3
)Math.Pow(x,7
)Math.Pow(x + 7,y

, double rate double


rate double 1.0

, double output ,
String.Format .
WriteLine , Console
} {0:c
} {0:E ...
:

C c

) ,
( , .

D d

N n

E e

F f

, . 2

G g

, F E .

X x

,
. ...

C c

;)Console.Write("{0:C}", 2.5

$2.50

;)Console.Write("{0:C}", -2.5

)($2.50

D d

;)Console.Write("{0:D5}", 25

00025

E e

;)Console.Write("{0:E}", 250000

2.500000E+005

;)Console.Write("{0:F2}", 25

25.00

;)Console.Write("{0:F0}", 25

25

G g

;)Console.Write("{0:G}", 2.5

2.5

N n

Console.Write("{0:N}",
;)2500000

2,500,000.00

F f

X x

;)Console.Write("{0:X}", 250

FA

;)Console.Write("{0:X}", 0xffff

FFFF

:
1 ?.
2 1 ] 20
[n*......*4*3*2*1 =n ,
, int , long
int , :
!n
1
2
6

!n
1
2
6

number
1
2
3

You might also like