New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

C++ Errors


Post Reply New Thread Subscribe

 
Thread Tools
Ganondor

 
Member Since: Sep 18, 2007
Posts: 9
Ganondor is on a distinguished road

Ganondor is offline
Ok I have just ended up talking to myself on this thing. I forgot to put two = in the if statement (n1==n2).

[old]Nevermind about the "I can figure it out." I want it to tell me if I enter the first number I entered more than once. It tells me the number is repeated 9 times no matter what.

Code:
#include <iostream>
using namespace std;
int main()
{
        int n1, n2, i, a;
        i=2;
        a=0;
        cout<<"Enter Number 1"<<endl;
        cin>>n1;
        while (i<11)
        {
                cout<<"Enter Number "<<i<<endl;
                cin>>n2;
                if (n2=n1)
                {
                        a=a+1;
                }
                i=i+1;
        }
        if (a>0)
        {
                cout<<n1<<" is repeated "<<a<<" times"<<endl;
        }
        else
        {
                cout<<n1<<" is not repeated"<<endl;
        }
        return 0;
}
This is the old post if anyone is interested.

Ok, I forgot "using namespace std;", so nevermind. Just incase you were wondering, it does not work properly, but I can figure that part out.


I am try to write a simple programe. You enter ten numbers, and it tells you if you entered the first number you entered more than once.[/old]
QUOTE Thanks

Post Reply New Thread Subscribe


« Declaring variables in programming | Creating startup service in Mac »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
PC Games Install Errors aaearhart Running Windows (or anything else) on your Mac 0 04-06-2008 07:56 PM
Mac Master browser requests causing SBS 2003 domain errors OceanDiverChris OS X - Operating System 4 04-26-2007 07:27 PM
4 Kernel Errors on New Macbook FlatlanderIA OS X - Operating System 4 03-25-2007 01:47 PM
Errors Installing OS X on 333mhz iMac swn5363 Apple Desktops 14 12-23-2004 03:48 PM
File association errors pixelmaven Apple Notebooks 4 04-09-2004 07:50 PM

All times are GMT -4. The time now is 09:33 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?