Question

1) Write a code segment that provides at least three possible outcomes (i.e., IF with a...

1) Write a code segment that provides at least three possible outcomes (i.e., IF with a couple of ELSE blocks).

2) Write a FOR loop that would cause a section of code to be executed 10 times.

3) Write a WHILE loop that would cause a section of code to be executed 10 times.

4) What is a variable?

5) Name 5 different “data types” used in C++ programming.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1)
int num = 15;
if(num < 18) {
    cout << "Young" << endl;
} else if(num <= 60) {
    cout << "Adult" << endl;
} else {
    cout << "Old" << endl;
}

2)
for(int i=0; i<10; i++) {
    cout << "Hello" << endl;
}

3)
int i=0;
while(i<10) {
    cout << "Hello" << endl;
    i++;
}

4)
Variables are simply names used to refer to some location in memory

5)
bool
char
int
float
long
Add a comment
Know the answer?
Add Answer to:
1) Write a code segment that provides at least three possible outcomes (i.e., IF with a...
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
  • Please use C programming to write a code segment as an answer. Instead of using an...

    Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please implement a code segment by using a do-while loop. What is the output of the code? #include <stdio.h> void main() {        int i = 0;        while (i < 5);        {               printf(“%d ”, ++i);        } }

  • Assume that, there is no strlen() function defined for us. Write a code segment using while...

    Assume that, there is no strlen() function defined for us. Write a code segment using while loop that will calculate the length of the following declaration. char stringVar[10] = “Hello”; Note that, the length of the C-string variable stringVar is 5. Can someone help me with this?

  • 31. The following code segment is syntactically correct:              int number{20};          cout << number <<...

    31. The following code segment is syntactically correct:              int number{20};          cout << number << setbase(16) << " " << number                               << setbase(10) << " " << number                                 << showpos << " " << number << endl;                 T__   F__       32. The following statement wants to determine if ‘count’ is outside the     range of 0 through 100:             if (count < 0 && count > 100)                                             T__   F__ 33. There is...

  • What will be the value of x after the following code is executed? int x =...

    What will be the value of x after the following code is executed? int x = 5; while (x <50) { x += 5; } a) 50 b) 45 c) Infiniteloop d) 55 Given the following code segment: Scanner in = new Scanner (System.in); boolean done = false; while (!done) { int input = in.next(); if(input.equalsIgnoreCase("q")) done = false; } What will cause the loop to terminate? a) When the user enters -1 b) The loop will never terminate c)...

  • Linux & Unix Write a bash program to indent the code in a bash source file....

    Linux & Unix Write a bash program to indent the code in a bash source file. Conditions:     The source file will contain only printing characters, spaces, and newlines. It is not necessary to check for invalid input.     The source file will not contain comments (words beginning with #). Requirements:     Read from standard input, write to standard output.     Code inside while statements should be indented 2 spaces. Be sure your program includes all of the following:    ...

  • 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 (...

  • 1. What kind of exception will be generated when the code segment below is executed? Why?...

    1. What kind of exception will be generated when the code segment below is executed? Why? int numerator 10; int denominator 0; int wholePart numerator/denominator Questions 2 and 3 refer to the Person constructor below. Person constructor has two String parameters, a first nam and a last name. the constructor initializes the e-mail address to the first letter of the first name followed by the fir five letters of the last name followed by @jc.com. If the last name has...

  • How would I change the following C code to implement the following functions: CODE: #include <stdio.h>...

    How would I change the following C code to implement the following functions: CODE: #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { if (argc != 2) printf("Invalid input!\n"); else { FILE * f = fopen (argv[1], "r"); if (f != NULL) { printf("File opened successfully.\n"); char line[256]; while (fgets(line, sizeof(line), f)) { printf("%s", line); } fclose(f); } else { printf("File cannot be opened!"); } } return 0; } QUESTION: Add a function that uses fscanf like this:...

  • Write code in R or Rstudio (Programming) You track your commute times for three weeks (15...

    Write code in R or Rstudio (Programming) You track your commute times for three weeks (15 days), recording the following times in minutes: 17, 16, 20, 24, 22, 15, 21, 25, 17, 90, 16, 17, 22, 20, 20. Enter the data into a 3-by-5 matrix, where rows are weeks and columns are weekdays. Please answer the following questions and provide the necessary code. (a) Name each column with the weekday abbreviations, i.e., Mon, Tue, Wed, Thu, and Fri (b) Find...

  • 1) A: List all possible outcomes (the sample space) for the tree diagram below B: Calculate...

    1) A: List all possible outcomes (the sample space) for the tree diagram below B: Calculate the number of all possible outcomes: bb 2) Based on the tree diagram below, how many ways can a coin be tossed four times and get exactly 3 tails? Hнн HHT HHHH HHHT HHTH H HTT HTHH HTHT HTTH HTTT THH T THT TTHS THHH THHT THTH THTT TTHH ΤΤΗΤ ΤΤΤΗ ΤΤΤΤ ΤΤΤ 3) How many 12-letter "words" (real or made-up) can be made...

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
ADVERTISEMENT