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

  • SEARCH
  • Home
  • 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 6341109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:57:55+00:00 2026-05-24T19:57:55+00:00

I am learning c++ and I am writing a card dealer program. When I

  • 0

I am learning c++ and I am writing a card dealer program. When I compile my code and I get these errors:

dealer3.cpp:12: error: expected initializer before ‘int’
dealer3.cpp:33: error: expected constructor, destructor, or type conversion before ‘=’ token
dealer3.cpp:34: error: expected constructor, destructor, or type conversion before ‘=’ token
dealer3.cpp:35: error: expected constructor, destructor, or type conversion before ‘=’ token
dealer3.cpp:36: error: expected constructor, destructor, or type conversion before ‘=’ token
dealer3.cpp:37: error: expected constructor, destructor, or type conversion before ‘<<’ token
dealer3.cpp:38: error: expected declaration before ‘}’ token

and here is my code

#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<cmath>

using namespace std;

int randn(int n);
void draw();
int uni(int n);
char *suits[4]={"Hearts","Diamonds","spades","clubs"};
char *ranks[13]={"ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king"};
int drawn[52];
int remaining=52;
int main() {
    int n;
    int i;
    srand(time(NULL));
    while(1) {
       cout<<"enter number of cards to draw"<<endl;
       cin>>n;
       if (n==0) break;

for (i=1; i<=n; i++)
    draw();
}

    return 0;
}
int r;
int s;
int n;
int card;
n=randn(remaining--);
card=uni(n);
    r=card%13;
    s=card/13;
    cout<<ranks[r]<<" of "<<suit[s]<<endl;
}
int uni(int n)
{
int i=0;
while (drawn[i])
    i++;
while (n-->0){
    i++;
while (drawn[i])
    i++;
}
card_drawn([i])=true;
return i;
}
int randn (int n){
return rand()%n;
}

Why is this?

  • 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-24T19:57:56+00:00Added an answer on May 24, 2026 at 7:57 pm

    Actually, this is a nice case where indenting the code would solve your problem (or make the solution very obvious), as it would show up several errors in with your braces. You have several lines of code that are outside of any function that don’t belong there.

    Some formatting hints for you:

    • Indent each nested block of code by a fixed amount of spaces (usually 4).
    • Leave a blank line after every function.
    • When opening a new block for a function or a for-, while– or if-statement (the list goes on), take care that you place your opening brackets consistently (the same style all over your code).
    • make sure that a bracket that closes a block is at the same indentation level as the statement/bracket that opened it.

    Note that most IDEs have some option to automatically fix formatting for you (especially the indentation).

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

Sidebar

Related Questions

I am writing a card playing program as a way of learning C#. I
I'm learning SQL Server Compact for a program I'm writing that requries a local
I'm a university student learning programming. For practice I'm writing a blackjack program. I'm
I'm writing a C code for improving recursive functions learning. My function must calculate
I am writing a small program for my personal use to practice learning C++
I'm learning Python and writing a program that keeps track of the total number
I'm currently learning assembler and writing some program in real mode. I have some
Im writing some C/asm program for the AVR MCU. Im still learning as I
I'm a student just learning xml and c#. I'm writing a program that will
In writing some learning the language code in ruby, as part of a linkedList

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.