重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

以下の5つの問題を教えてください!!
1. What is the difference between a while loop and a do-while loop? Convert the following while loop into a do-while loop.

int sum = 0;
int number;
cin>>number;
while (number!=0)
{
sum += number;
cin>>number;
}


2. Write a “for” loop that prints the numbers from 50 to 100.


3. Convert the following for loop to a while loop.
int sum = 0;
for (int i=0; i <= 1000; i++)
sum = sum + i;

5. Write a loop that generates the following output. You may use any looping statement.

1
5
9
13
17
21
25

For (int i=1 ; i<=25 ; +=4)
Std:: cout << i << std:: endl;

質問者からの補足コメント

  • 5番の問題の

    For (int i=1 ; i<=25 ; +=4)
    Std:: cout << i << std:: endl;
    は無視して下さい

      補足日時:2016/12/10 01:28

A 回答 (1件)

英語で書かれていますが、どんな問題なのかは理解できていますか?


1)
前半はあなたが理解している内容を書く問題です。
回答を英語でしなければならないのか、日本語でいいのか、については、出題者に確認してください。

2)
これができなければ、基礎の基礎からやりなおしてください。

3)
for(式1;式2;式3) 文

{
式1;
while(式2) {
文;
式3;
}
}
とほぼ同等。

5)
何故無視するのですか?
You may use any looping statement.
とあるのだから、 無視する必要無いのでは?
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!