Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:19:06+00:00 2026-06-14T19:19:06+00:00

I have this code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _121119_zionAVGfilter_Nave

  • 0

I have this code:

   using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _121119_zionAVGfilter_Nave
{
    class Program
    { 
        static void Main(string[] args)
        {
            int cnt = 0, zion, sum = 0;
            double avg;
            Console.Write("Enter first zion \n");
            zion = int.Parse(Console.ReadLine());
            while (zion != -1)
            {
               while (zion < -1 || zion > 100)
            {
                Console.Write("zion can be between 0 to 100 only! \nyou can rewrite the zion here, or Press -1 to see the avg\n");
                zion = int.Parse(Console.ReadLine());
            }

                cnt++;
                sum = sum + zion;
                Console.Write("Enter next zion, if you want to exit tap -1 \n");
                zion = int.Parse(Console.ReadLine());


            }
            if (cnt == 0)
            {
                Console.WriteLine("something doesn't make sence");
            }
            else
            {
                avg = (double)sum / cnt;
                Console.Write("the AVG is {0}", avg);

            }
       Console.ReadLine(); }
    }
}

The problem here is that if in the beginning I enter a negative or bigger than hundred number, I will get this message: “zion can be between 0 to 100 only! \nyou can rewrite the zion here, or Press -1 to see the avg\n”.
If I then meenter -1, this what that shows up instead of the AVG: “Enter next zion, if you want to exit
tap -1 \n.”
How can I solve this problem so when the number is negative or bigger than hundred and than tap -1 I will see the AVG an not another message?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:19:07+00:00Added an answer on June 14, 2026 at 7:19 pm

    You can just add a flag variable and it’s done.

    namespace _121119_zionAVGfilter
    {
        class Program
        { 
            static void Main(string[] args)
        {
            int cnt = 0, zion, sum = 0;
            double avg;
            int flag = 0;
            Console.Write("Enter first zion \n");
            zion = int.Parse(Console.ReadLine());
            while (zion != -1)
            {                 
                while (zion < -1 || zion > 100)
                {
                    Console.Write("zion can be between 0 to 100 only! \nyou can rewrite the zion here, or Press -1 to see the avg\n");
                    zion = int.Parse(Console.ReadLine());
                    if(zion== -1)
                        flag = 1;
                }                
                cnt++;
                sum = sum + zion;
                if (flag == 1)
                    break;
                Console.Write("Enter next zion, if you want to exit tap -1 \n");
                zion = int.Parse(Console.ReadLine());
                if (cnt != 0) { }
    
            }
            if (cnt == 0)
            {
                Console.WriteLine("something doesn't make sence");
            }
            else
            {
                avg = (double)sum / cnt;
                Console.Write("the AVG is {0}", avg);                
            }            
            Console.ReadLine(); 
          }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data;
I have this code (C#): using System.Collections.Generic; namespace ConsoleApplication1 { public struct Thing {
I have the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using
quick question really: I have this code: using System; using System.Collections.Generic; using System.Linq; using
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
i have this code server part: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
I have this code but I just can't understand it. using System; using System.Collections.Generic;
I am making an overlay. I have this code here using System; using System.Collections.Generic;
i have the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using
i have the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.