Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

(C PROGRAMMING) Write out a main function that scans a list of numbers, and also counts how many number bigger than 0 do not have a negative "counterpart" in the list after them. ****PLEASE NOTE: NO use of break statements, flag variables or continue statements in the code****

  • List of numbers you are scanning is less than 1000 integers
  • Never get the number 0 in the list of numbers.
  • Print out an integer, followed by a newline.

SAMPLE INPUT/OUTPUT

8 2 2 -8 8 3 3 -2

You would print out 3. Explaining this, number by number:

  • The first number is 8; so we look for a -8 and find it. There aren't any numbers without a negative counterpart.
  • The second number is 2; so we look for a -2, and find it at the end of the list. Still, 0 numbers without a negative counterpart.
  • The third number is 2; so we look for a -2, and find it at the end of the list. Still, 0 numbers without a negative counterpart.
  • The fourth number is -8; and we can ignore this because it is negative.
  • The fifth number is 8; but there is no -8 after this number. This means we now have 1 number without a negative counterpart.
  • The sixth number is 3; but there is no -3 after this number. This means we now have 2 numbers without a negative counterpart.
  • The seventh number is 3; like before, it has no counterpart. This means we now have 3 numbers without a negative counterpart.
  • The eighth number is -2; and we can ignore this because it is negative.
  • As a result, we would print out 3.

CODE:

#include <stdio.h>
#include <assert.h>

int main(void) {

printf("solution");

return0;

}

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.