Question

In: Computer Science

1. Which if clause, if any, will properly determine if a dollars variable is between .01...

1. Which if clause, if any, will properly determine if a dollars variable is between .01 and 1000.0, inclusive. Assume dollars is declared as a double variable.( C Programming) answer choices

if(dollars >=.01 && 1000.0)

if(dollars >= .01 and dollars <= 1000.0)

if(dollars > .01 & dollars < 1000.0)

if( (1000- dollars) < .01)

None of the above options will properly test the range

2.

Which of the following is false regarding loops?

Group of answer choices

The break statement can be used to break out of a loop.

The continue statement can be used to force the next iteration of a loop

A for loop defined as:

for(int s=0;;){}

is a syntax error

A for loop defined as:

for(int num=0; num < 2883; num++){ }

will iterate 2883 times.

A do...while loop will always iterate at least once.

3.

Given the following code, which, if any, of the following values for firstand sec will cause solution to appear on the screen?

int first;
int sec;
//assume the sec will be assigned here

if(first < -9( {
   if(sec > first && sec <=0) {
printf("solution!");
}
} else {
printf("still solving...");
}

answer choices

first = -72;
sec=-1;

first = -9;
sec=-1;

first = -10;
sec=1;

first = -9;
sec=0;

None of the above values will cause solution to appear on the screen.

4. Write code(C) that will accomplish the same logic as the if stack below. Your answer must not include an if of any kind.

int hr;
printf(
"Enter hour to meet:");
scans("%d, &hr);
if(hr > 0 && hr < 4) {
   printf("Too early") {;
} else if(hr == 7 || hr == 10) {
   printf("I can meet");
} else {
   printf("Unavailable");
}

Solutions

Expert Solution

Ans 1:

None of the above options will properly test the range.

Explaination:

  1. ​​​​​​The correct code should be if(dollars >=.01 && dollars<=1000.0).

Ans 2:

for(int s=0;;){} is a syntax error

Explaination:

  1. The above code is not a syntax error. But will lead to infinity loop.

Ans 3:

first = -72; sec = -1;

Explaination:

  1. Above values will leads to print solution!

Ans 4:

#include<stdio.h>

int main()
{

    int hr;
    printf("Enter hour to meet:");
    scanf("%d", &hr);
    int ch=0; //check value
    //convert all if ito while loop
    while(hr > 0 && hr < 4) 
    {
        printf("Too early");
        ch++;
        break; //exit after first execution
    }
    while(hr == 7 || hr == 10)
    {
        printf("I can meet");
        ch++;
        break;
    } 
    while(ch==0) //if ch==0 no other conditions are true
    {
        printf("Unavailable");
        break;
    }
    return 0;
}

.


Related Solutions

Question 1:   Please explain the difference between the commerce clause and the due process clause. Why...
Question 1:   Please explain the difference between the commerce clause and the due process clause. Why are these two clauses so relevant in state and local tax cases? Please be specific and provide examples in your answer. Question 2: South Dakota v. Wayfair has been called the "tax case of the millennium." Explain why this SCOTUS decision is so important for nexus purposes. Also, what issues were left unanswered by the decision. Question 3: Discuss when a taxable sale occur...
1. The "else" clause is required for a decision statement. 2. A String variable can be...
1. The "else" clause is required for a decision statement. 2. A String variable can be assigned to an integer variable. 3. An integer variable can be assigned to a boolean variable. 4. We can calculate the square root of numbers with the class java.util.Math. 5. String is a Java primitive data type. 6. A ‘Double’ object can be assigned to a ‘String’ data variable. 7. Every Java class has to have a static main() method to avoid compilation error....
1. Explain the difference between a mediator variable and a moderator variable. Which of the two...
1. Explain the difference between a mediator variable and a moderator variable. Which of the two is more commonly seen in resilience research and why?
Subject: Organizaitonal Behavior Question 01: Explain in detail the difference between groups and teams for any...
Subject: Organizaitonal Behavior Question 01: Explain in detail the difference between groups and teams for any project in your organization. Question 02: Summarize the positive and negative impact of individual behavior on overall group and team performances. (7marks) . . Note: The assignment should be in a form of a comprehensive report and it must include the following points: ·         Proper introduction ·         Body of the report equipped with relevant knowledge and discussion ·         Conclusion of the report relevant to the discussion ·         Proper...
Use the data from question 1. Conduct a hypothesis test at α = .01 to determine...
Use the data from question 1. Conduct a hypothesis test at α = .01 to determine if the population variance is greater than 904.75. Question 1: 1. Consider the following sampled data: s 2 = 906.304, n = 31. Calculate the following confidence intervals for the population variance: (a) 90% (b) 95% (c) 99%
Determine the independent and dependent variable in each of the following scenarios: a. The relationship between...
Determine the independent and dependent variable in each of the following scenarios: a. The relationship between smoking and lip cancer b. The relationship between income and the highest level of education attained -
is there any relation between the consumer preferences and two variable input profuction model?
is there any relation between the consumer preferences and two variable input profuction model?
In order to determine if there is any difference between the mean daily sales of 2...
In order to determine if there is any difference between the mean daily sales of 2 locations of an electronics chain, the data below has been gathered. At a 1% level of significance, test to determine if there is a significant difference in the mean daily sales of the 2 locations. What is your conclusion? Center City Location Suburban Mall Location Sample size 16 13 Sample Mean $36,500 $38,000 Sample Standard Deviation $3,000 $4,200
1.       Which statement(s) is (are) correct? a.       The planning horizon for any business is between three...
1.       Which statement(s) is (are) correct? a.       The planning horizon for any business is between three and five years. b.      Forecasts that extend beyond the planning horizon are less credible. c.       The planning horizon should be the furthest point in the future considered by the business plan. d.      The planning horizon for a hotel owner is determined by the length of the management contract. 2.       What statement would a hotel owner prefer to see in the business plan for a...
You have 3 billion dollars in the fund, which you can invest in any combination of...
You have 3 billion dollars in the fund, which you can invest in any combination of Australian stocks, US stocks, and Australian Treasury. The idea is to use your knowledge of portfolio theory to make an argument for having an internationally diversified portfolio, rather than just holding domestic assets. The data are monthly returns and the relevant sample statistics are summarized in the following table: Stock E[R] Var(R] Cov(Aus, US) Aus Index 0.00959 0.00222 0.00088 US Index 0.00727 0.00348 Aus...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT