Question

Write a set of statements to perform the following steps: When the variable fruit contains the...

Write a set of statements to perform the following steps: When the variable fruit contains the character uppercase P, increase the value in the integer variable papaya by one. When fruit contains the character uppercase G, increase the value in the integer variable guava by one. When fruit contains anything else, increase the value of the integer variable bananas by one.

C LANGUAGE

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

Hi, Please find my answer. Please let me know in case of any issue.

Given:
    char fruit[SIZE] = // declare

    int i;

    int papaya = 0, guava = 0, bananas = 0;

    for(i=0; i<SIZE; i++){
        if(fruit[i] == 'P')
            papaya++;
        else if(fruit[i] == 'G')
            guava++;
        else
            bananas++;
    }

Add a comment
Know the answer?
Add Answer to:
Write a set of statements to perform the following steps: When the variable fruit contains the...
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
  • 2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z r...

    2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...

  • write Java statements that perform the following functions ? 21 If x is greater than or...

    write Java statements that perform the following functions ? 21 If x is greater than or equal zero, then assign the square root of x to variable sqrtx and print out the result Otherwise, print out an error message about the argument of the square root function and set sqrtx to zero (2) 22 A variable fun is calculated by dividing variable numerator by variable denominator If the absolute value of denominator is less than 1, write "Divide by zero...

  • rite statements to perform the following: (Hint: You may use combined assignment operators!) a. Add 9...

    rite statements to perform the following: (Hint: You may use combined assignment operators!) a. Add 9 to apples and store the result in apples. b. Divide peaches by 13 and store the result in peaches. c. Subtract 17 from oranges and store the result in oranges. d. Multiply payRate by 1.5 and store the result in payRate. 9. Write statements to perform the following operations: Declare two variables p and q. Subtract 250 from p and store the result in...

  • Write a single C++ statements to accomplish each of the following tasks: In one statement, assign...

    Write a single C++ statements to accomplish each of the following tasks: In one statement, assign the sum of the current value of x and y to z and postincrement the value of x. Determine whether the value of the variable count is greater than 10. If it is, print “Count is greater than 10.”. Pre-decrement the variable of x by 1, then subtract it from the variable total. Multiply variable power by x and assign the result to power.  ...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • You perform the following steps: 1. Heat up a balloon that contains 4 mol of helium...

    You perform the following steps: 1. Heat up a balloon that contains 4 mol of helium gas from 293K to 353K.... Problem 2. You perform the following steps: 1. Heat up a balloon that contains 4 mol of helium gas from 293K to 353K. (pressure inside of oven is2 atm) 2. Very slowly squeeze the balloon until the volume decreases from 0.5L to 0.25L 3. Grab the balloon, put it in a container that does not allow it to change...

  • Write a program(Python language for the following three questions), with comments, to do the following:   ...

    Write a program(Python language for the following three questions), with comments, to do the following:    Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...

  • Which response contains all the following statements that are true, and no others? I. A set...

    Which response contains all the following statements that are true, and no others? I. A set of sp2 orbitals can be thought of as one s orbital one-third of the time and two p orbitals two-thirds of the time. II. A set of sp orbitals can accommodate a maximum of six electrons. III. The orbitals resulting from sp3d2 hybridization are directed toward the corners of an octahedron. IV. A set of sp3 orbitals results from the mixing of one s...

  • Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language...

    Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language statements. Assume that each variable (A, B. C, and D) is one word in memory. If notequalto B then C: =5; else C: =10; D: =50;

  • Problems: 1. Write a program to define the following variables, assign them values, and print their...

    Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...

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