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 8059293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:37:35+00:00 2026-06-05T09:37:35+00:00

I am wondering how to approach writing a function that would return whether there

  • 0

I am wondering how to approach writing a function that would return whether there were at least three values not equal to 0. I’ve searched for similar problems, but I couldn’t find any effective solution. In order to explain my problem, here is an example:

I have an array which contains these elements: [1,0,2,0,4,0,0,3,0,0]. I want to check if there are at least 3 elements not equal to zero.

My code would return 1 if there are at least 3 elements != 0 , or return 0 if there are less than 3 elements !=0.

So in my example it should return 1.

  • 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-05T09:37:37+00:00Added an answer on June 5, 2026 at 9:37 am

    Count the number of elements not equal to zero. If less than three, return false, else return true.

    In order to obtain the count, loop through the contents of the array using a for loop and then use an if statement to test if the element is zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am wondering if there would be any security flaw in this approach. I am
I am wondering what would be the best approach to store, for let's say
Wondering if there is any way to get the lambda expressions that result from
I was wondering if there is a standard way to approach the kind of
I'm wondering if this is the right approach to writing a thread-safe queue in
I am wondering how the OS is reading/writing to the hard drive. I would
I'm writing/written a value type struct and was wondering if there was a guide
I was wondering whether using a Belt and Braces (Suspenders) approach to programming -
I was wondering if anyone had developed an approach for using NHibernate / Fluent
I am wondering what is the best approach/methods/technology to implement a C# desktop application

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.