Question

Ex 3) Trace the following flowchart for when input values are 12, 3, -3, 6, -11, -14, -1, -1, -3, 2, 0 and complete the trace
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given, Flow Chart

& input values are 12,3,-3,6,-11,-14,-1,-1,-3,2,0

From the flow chart, we can understand that, it counts the number of positive numbers 'p' and negative numbers 'n' with a special condition where p <= 2 * n;

Glance through the below images for more understanding!

=>for first pass of input 12,

num <= 12 ; then as 12 > 0; p is increased by 1 i.e; p = p + 1;

as condition num != 0 is satisfied but p <= 2*n is not satisfied as 1<= 0 is not true.

peudocode maini - Trace Table num Output ut p=0, n o . Put CJ num, will num! - 0)44 (P22*n)) { of (num > 0) { P= P + 1; if (n→ flow chart dynebo s Mentioned in Currenquat Start (on and of the program. Tenunator (on Tuminal & Claws stent (or Begin (on

Add a comment
Know the answer?
Add Answer to:
Ex 3) Trace the following flowchart for when input values are 12, 3, -3, 6, -11,...
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
  • Do it on (c) pls..... 1. Assume you have an input file with 6 integer values....

    Do it on (c) pls..... 1. Assume you have an input file with 6 integer values. Scan these values into an appropriate array. 2. Create a user defined function that takes your array as an input and order your array from lowest to highest. Ex. If you have an array called num, then num[0] should contain the smallest value while num[5] will contain the largest value. 3. Output the values between 50-75 into an output file called “results.txt” 4. Any...

  • How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button...

    How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button "problem 2" is clicked, a JavaScript function equivalent to the following flowchart should execute. In other words, your task here is to translate the following flowchart to JavaScript code in P2<yourname>: start sum1 0 sum2 0 P i0 i< 3 iei+1 num sum1 sum1 + num F i <3 ii+1 sum1 sum2 "no" num "yes" sum2 sum2 + num end Hint: for input, use...

  • 1. Solve the options according to a given flowchart below and assume user input as value...

    1. Solve the options according to a given flowchart below and assume user input as value 14 for N.(Aşağida verilen akg diyagramına göre kullanicinin N için 14 değeri girdiğini varsayarak şıkları çözünüz.) a. Fill the table below. (Aşağıdaki tabloyu doldurunuz.) (20 point) Start N, S2:0 に0, N, 1 lo S1, S2 S1- S1-I Stop b. Express what this flowchart computes just in a single sentence. (Bu akiş diyagramınin neyi hesapladiğını sadece bir cümle ile ifade ediniz.) (25 p) 2. Solve...

  • 2. Trace the following algorithm and determine the return value: Name : Algorithm AB Input :...

    2. Trace the following algorithm and determine the return value: Name : Algorithm AB Input : None Output: An integer 1 a = 0 2 b = 20 3 while a < b : 4 a = a + 1 5 b = b - 2 6 end while 7 return a - b

  • EX 1) Determine the outcome of the following code fragment without writing and running the program....

    EX 1) Determine the outcome of the following code fragment without writing and running the program. int num = 0, max = 20; while (num <= max) {     System.out.println(num);     num += 4; } EX 2) Write a code fragment that reads and prints integer values entered by user until a particular sentinel value (stored in constant SENTINEL) is entered. Do not print the sentinel value.                 Ex 3)  Write a method called averageLargestTwo  that accepts three int parameters  and returns the average...

  • Trace the following program, showing the values of the variables and the output generated by the...

    Trace the following program, showing the values of the variables and the output generated by the program. The input file to the program is: 1375 3 8472 2 (SHOW YOUR WORK) #include <stdio.h> #define BASE 10 int find( int, int); int extract( int, int); main() { int a, b; int c, d; while( scanf("%d", &a) != EOF) { scanf("%d", &b); c = find(a, b); if(c >= 0) d = extract(a, c); else d = c; printf("its %d \n", d); }...

  • (60-140) Lab Exercises #3-2 (Due at the end of the lab period) May. 28-30, 2018. Part...

    (60-140) Lab Exercises #3-2 (Due at the end of the lab period) May. 28-30, 2018. Part B: C Programming Exercise a) Implement the algorithm as represented by "factorial, rap", and write an Objective: Programming with loops The factorial for a positive integer n is defined as In addition, it is generally agreed that 0!-1 when n0 Part A: RAPTOR Exercise equivalent C program that not only accomplishes what the flowchart does but also b) Save your program to a file...

  • C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished)...

    C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished) { printf("Enter n > 0 or quit\n"); scanf("%10s", buffer); if (strcmp(buffer, "quit") == 0) { finished = true; } else { // Convert input to number and compute n-th prime num = atoi(buffer); if (num > 0) { res = nth_prime(num); printf("Prime #%d is %d\n", num, res); }...

  • Trace the evaluation of the following expressions, and give their resulting values. Make sure to give...

    Trace the evaluation of the following expressions, and give their resulting values. Make sure to give a value of the appropriate type (such as including a .0 at the end of a double or quotes around a String). 4 + 1 + 9 + "." + (-3 + 10) + 11 / 3 8 + 6 * -2 + 4 + "0" + (2 + 5) 1 + 1 + "8 - 2" + (8 - 2) + 1 +...

  • 6. (a) Each clock cycle, an input is provided to the finite state machine (FSM) below....

    6. (a) Each clock cycle, an input is provided to the finite state machine (FSM) below. Assuming that we start at state 00 and given an input for each tick, fill in the table to show the next state. (b) What bit sequence(s) does this FSM recognize? Your answer should be a string of bits (ex. “01” or “1110”). 11 0- 10 00 01 Time 0 1 2 3 4 5 6 input START 1 0 0 1 1 0...

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