Computer problems,Computer help
*AX SOFT>>>Programming & Design

How to Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100].?


How to Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100]. If user enters a number out of that range, your program shouldn鈥檛 consider it, and should ask for a new number. The user should enter 0 to stop the loop. When the loop stops, we want your program to display
鈥?the largest TWO numbers entered in the range of [-100 100],
鈥?the smallest TWO numbers entered in the range of [-100 100],
鈥?the average of negative numbers entered in the range of [-100 100], and
鈥?the average of positive numbers entered in the range of [-100 100].

For example if user enters -2 3 -4 -200 5 -3 120 0
Your program should print:
鈥?Two largest numbers are: 5 3
鈥?Two smallest numbers are: -4 -3
鈥?Average of negative values is -3
鈥?Average of positive values is 4

Your loop will be a while loop

anwer = -999;
while (answer!=0)
{
ask user for answer
if(answer<100 and answer>-100)
{
if(answer<smallest)
smallest = answer
if(answer>largest)
largest=answer
}
}

#!/bin/c

public static void main(String[] args){
10:
a=rails.framework.inputLoop(-100,100);
print b;
goto 10
end;
}

You should at least try to do your own homework before asking for someone to do it for you. Give it a try, and ask questions about what you don't understand.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Whats wrong with my code?

    This line is illegal: int 1=1,n,f; as "int" is used to declare a variable of type integer. You could always try saying int one = 1; int f; but I have no idea what the n is doing th...

  • I just moved my asp.net app. project over the devlopment server but having issue with login. unable to loging?

    What kind of authentication are you using? Windows authentication? Forms authentication? A custom solution? I'm lead to believe that perhaps you're using Windows authentication, and th...

  • How can a computer be random?

    hehe, good question. The answer is it can't. In the absence of this, 'pseudorandom' is good enough. If it appears random to us, what's the difference? A common technique use...

  • How do i enable java script on my laptop?

    In firefox you go to tools options content. Then click the check box next to enable java script. In internet explorer you go to tools internet options then click the security tab, set your own cust...

  • What u say about it...???

    Very nice. You will be a successful web designer when you finish school. As the other said, the content has bad spelling and grammar which should be reviewed.

    ...
  • I want visitors to be able to post comments on my webpage and have other visitors view them, is there a way?

    ...

  • What can I do to fix my java applet code?

    Faren = JOptionPane.showInputDialog("X: ) f = Double.parseDouble(Faren); That's 2 line's of code, and you didn't close your String. Change to... Faren = JOptionPane.show...

  • Whats a good program to make a banner for a website?

    i've been doing banners at skool for my it coursework and i had to use dreamweaver to do it

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster