主页  范文大全   奥运彩信   奥运英语   免费资源   PDF资源下载  QQ资源区 在线电影   短信&笑话  QQ表情   彩信在线发   站长Blog   访客留言   科教视频   大论坛

C++ Tutorials: 3, Program Flow (If, Else, While, For) .

作者:学习与生…    文章来源:本站原创    点击数:    更新时间:2008-3-2

         声明:本站所有资料素材均是由站长精心整理搜集的,属于原创。我们同意您的转载和复制,但是在转载复制时请保留文字出处。本站资料全部免费使用,无需注册,力求打造华北最强最大的免费资源网站。

推荐度:★★★★


Program Flow is what you think it is. How the program will flow. As you know the compiler will just go down the code. Program flow is what you use to make it run a certain thing a few times, do something based on a variable, etc... There are some basic comands to program flow. The first two are loops: While and For. When you want something to loop for an amount of times based on a variable, use while. If you know how many times you want something to run, use for. If and else statements are pretty self explanable. Dont be afraid, I will go over all the syntaxes and how to do everything!

The For Loophttp://www.syschat.comUse a for loop when you know how many times you want something to run. For example, we want to have an application that counts from 0 to 50 and count by fives. To do this we would need a for loop. Here is how you do it:

for(DEFINE VARIABLE; WHEN IT SHOULD STOP; How much you count every time the program runs){

Code you want to run.}Ok, so with our 0-50 program, we would do the following:

for(int x = 0; x < 51; x=x+5){

cout

文章录入:xxYsh.com    责任编辑:admin 
发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口