Question

2. (5 marks) Write an algorithm as a flow chart that reads in values for a series of numbers (so you will have to read in ins

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

Algorithm:

1. Start.

2. Initialize counter to zero and n as input number.

3. Start while loop with condition counter<=5

4. read the number, check the condition >=0

5. if the number is greater than or equal to zero print positive

else

increment counter

6. when counter becomes 5 loop terminates.

7. Stop.

Flow Chart:

Start num=0,counter=0 Stop к — IF counter<=5 ОТКАТА Yes Read num IF num >=0 Yes , Print Positive No counter++

C-Program:

#include<stdio.h>

void main()

{

int num,counter=0;

while(counter<=5)

{

scanf("%d",&num);

if(num>=0)

printf("Positive\n");

else

counter++;

}

}

Add a comment
Know the answer?
Add Answer to:
2. (5 marks) Write an algorithm as a flow chart that reads in values for 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
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