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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:36:43+00:00 2026-05-12T16:36:43+00:00

This is also one of the interview question i have faced recently. Description :

  • 0

This is also one of the interview question i have faced recently.

Description :

The task is $ 100(Please consider some currency) will be given to me.I need to purchase three items itemA,itemB,itemC.The cost of (I am not sure 0.25$ or 0.75 $ are meaningful,so think it as other currency) itemA=0.25$,itemB=0.75$ and itemC=20$. I need to purchase 100 items exactly at 100$ ( I can purchase any number of itemA,itemB,ItemC but total should be 100).


Solution :

using for loop i solved it.

 for (int i = 1; i <= 100; i++)
   {
     for (int j = 1; j <= 100; j++)
     {
       for (int k = 1; k <= 20; k++)
        {
           if ((i * 0.25) + (j * 0.75) + (k * 5) == 100 && (i+j+k)==100)
           {
              Console.WriteLine("item1={0},item2={1},item3={2}", i, j, k);
            }
        }
     }
  }


I got the results too.

item1=1 , item2=93,item3=6 // cost =100,items=100

item1=18,item2=74,item3=8 //cost=100,items=100

item1=35,item2=55,item3=10 //cost=100,items=100

item1=52,item2=36,item3=12 //cost=100,items=100

item1=69,item2=17,item3=14 //cost=100,items=100

The actual task was to give the demo using “linq”.How can i solve the same using Linq?

(Anyhow the interview was over.Ofcourse in next interview nobody will ask it to do).

  • 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-05-12T16:36:44+00:00Added an answer on May 12, 2026 at 4:36 pm
    var r = from i in Enumerable.Range(1, 100) 
            from j in Enumerable.Range(1, 100) 
            from k in Enumerable.Range(1, 20)
            where (i * 0.25) + (j * 0.75) + (k * 5) == 100 && (i+j+k)==100
            select string.Format("item1={0},item2={1},item3={2}", i, j, k);
    
    foreach (var line in r) 
        Console.WriteLine(line);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.