Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Help needed with C++ programming


  • Please log in to reply

#1
akinwale

akinwale

    New Member

  • Member
  • Pip
  • 1 posts
Hi,

I'm new to C++ programming. I'm trying to write a code that prompts for 10 numbers and store them in an array. Then prompt for another number and output the number of scores from the first 10 that match the last score inputted.

I believe I can do the first part of the coding but I'm confused on how to get the number of scores from the array that matches the other number. I would appreciate if anyone would be kind enough to help out.
  • 0

Advertisements


#2
darth_ash

darth_ash

    Member 1K

  • Member
  • PipPipPipPip
  • 1,382 posts
Hi akinwale,

Just run a loop and use an if statement to check if the current element in the array matches the other-number.

for(int i=0;i<10;i++)
{
	 if(scores[i]==toMatch)
		 cout<<scores[i];
}
	

In the above code, scores[10] was your array and toMatch was your other number.

Edited by darth_ash, 28 November 2005 - 01:45 AM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP