Question

10. Write the heading (the first line) of a for statement whose loop control variable alpha counts from 37 through 1 in steps of 1. 11. What is the output of the following code fragment? (All variables are of type int.) limit 8 cout <<H loopCount = 10; do cout x E; loopCount++ } while (loopCount <= limit); cout << LP

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

1)

Heading will be..

for(int alpha=37;alpha>=1;alpha--)

CODE:

#include<iostream>
using namespace std;
int main(){

   for(int alpha=37;alpha>=1;alpha--){
       cout<<alpha<<" ";
   }
   return 0;
}

OUTPUT:

Debug : Programe Console terminated> CPP Workspace.exe [C/C++Application] CAUsers Mohammad Shahrukh Desktoplc language workspaceleclipse c\CPP_WorkspaceDebugCPP_Works oject/source/mainProgram.c 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 876 5 4 3 2 1 >=1; alpha--)(

2)

Given code:

#include<iostream>
using namespace std;
int main(){

   int limit = 8;
   cout<<'H';
   int loopCount =10;
   do{
       cout<<'E';
       loopCount++;
   }while(loopCount<=limit);
   cout<<"LP";

   return 0;
}

nainc.cpp #include<iostream> 2using namespace std; int main(){ 5 //set limit to 8 int limit- 8; //print H cout<<H 9 I/set loop count to 10 Oint loopCount-10; //do loop 2 do //print E cout<<E //increase loop count loopCountt+; //if loop count less than limit //as though loop count is 10 is condition failed hence it //will not loop further while (loopCount<=limit) ; 2 //will print LP cout<<LP return 0;

So output will be HELP

Add a comment
Know the answer?
Add Answer to:
10. Write the heading (the first line) of a for statement whose loop control variable alpha...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A. What is the output of the following C++ code fragment? (all variables are of type...

    A. What is the output of the following C++ code fragment? (all variables are of type int) int count-1; int y-100; while (count 3) y=y-1 ; count+t cout << y << endl; cout<< count <<endl What is the value of x after control leaves the following while loop? (all variables are of type int) B. int x0 while (x < 20) sum- sum+x cout << sum<< endl;

  • Class: C++ Final Exam Dates Multiple Choice Identify the choice thar best completes the statement or...

    Class: C++ Final Exam Dates Multiple Choice Identify the choice thar best completes the statement or answer the question N 1. In s tructures, the computer repeats particular statements a certain number of times depending on some condition(s) a. looping C. selection b. branching d. sequence 2. What is the output of the following CH code? count = 1; num - 25; while (count < 25) numnum - 1: count++; cout << count << " " << num << endl;...

  • 2. What is the output of the following code fragment? n = 1; while (n <=...

    2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...

  • 41. Executing the "continue" statement from within a loop     causes control to go     A....

    41. Executing the "continue" statement from within a loop     causes control to go     A. to the next line of code     B. out of the loop     C. to the beginning of the loop          D. to check the loop condition for repeating the loop     E. none of the above      42. The 'default' statement inside a 'switch()' is optional.          T__   F__             43. The following 'switch' implementation is legal:              int i = 2;        ...

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

  • If you write a loop, and mistakenly omit the statement that alters to loop control variable,...

    If you write a loop, and mistakenly omit the statement that alters to loop control variable, the most likely result is _________. a. garbage output b. hardware failure c. an infinite loop d. not enough output

  • Control Structures and Subroutines I. A while loop whose condition is not made false is called...

    Control Structures and Subroutines I. A while loop whose condition is not made false is called an infi nite loop. However, it is infinite, in the sense of continuing to run forever, only in theory. The loop will stop at some point. Why? 2. To evaluate the if statements in this question below, assume that a Print statement simply prints whatever is in quotes after it. The phrases after a semicolon in the third code fragment are comments and are...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT