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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:36:20+00:00 2026-06-10T08:36:20+00:00

Im very new to VC++. Yesterday my VC++ instructor gave us this code and

  • 0

Im very new to VC++. Yesterday my VC++ instructor gave us this code and asked us to make it as a exe. I have no idea of where to start and end. How to make this single file into exe. How and where to paste this working code in visual studio. If my question sounds too dumb, sorry. But i’m. Please help me out in making an exe from this single file. By the way this is Josephus circle algorithm

Code :
//////////////////Header file

#include<iostream.h>
template <class T>
class ex
{
    private:
        struct node
        {
            T data;
            struct node *next;
        };
        struct node *head,*front,*rear;
    public:
        ex()
        {
            head=new node;
            head->next=NULL;
            front=rear=head;
        }
        void enqueue(T x);
        T dequeue();
        void print();
        void move_next();
};



//////////////////Implementation file
#include "ex.h"
template <class T>
void ex<T>::enqueue(T x)
{
    node *p;
    p=new node;
    p->data=x;
    if(head->next==NULL)
    {
        front=rear=p;
        head->next=p;
        p->next=p;
    }
    else
    {
        rear->next=p;
        p->next=front;
        rear=rear->next;
    }
}

template<class T>
T ex<T>::dequeue()
{
    node *t;
    T x;
    t=front;
    x=t->data;
    front=front->next;
    rear->next=front;
    delete(t);
    return x;
}

template<class T>
void ex<T>::print()
{
    node *p=front;
    do
    {
        cout<<p->data<<endl;
        p=p->next;
    }while(p!=rear->next);
}

template<class T>
void ex<T>::move_next()
{
    front=front->next;
    rear=rear->next;
}



/////////////////Application file
#include "ex.cpp"
void main()
{
    ex<int> e;
    int m,n,i,d;
    cout<<"Enter the number of people";
    cin>>n;
    cout<<"Enter the number of passes";
    cin>>m;
    for(i=1;i<=n;i++)
        e.enqueue(i);
    cout<<"The players are
";
    e.print();
    cout<<"Eliminated in order
";
    while(n>1)
    {
        for(i=1;i<=m;i++)
            e.move_next();
        d=e.dequeue();
        cout<<d<<endl;
        n--;
    }
    d=e.dequeue();
    cout<<"Winning player:  "<<d<<endl;
}
  • 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-10T08:36:21+00:00Added an answer on June 10, 2026 at 8:36 am

    Make the first file named ex.h

    #include<iostream.h>
    template <class T>
    class ex
    {
        private:
            struct node
            {
                T data;
                struct node *next;
            };
            struct node *head,*front,*rear;
        public:
            ex()
            {
                head=new node;
                head->next=NULL;
                front=rear=head;
            }
            void enqueue(T x);
            T dequeue();
            void print();
            void move_next();
    };
    

    Second file into ex.cpp

    #include "ex.h"
    template <class T>
    void ex<T>::enqueue(T x)
    {
        node *p;
        p=new node;
        p->data=x;
        if(head->next==NULL)
        {
            front=rear=p;
            head->next=p;
            p->next=p;
        }
        else
        {
            rear->next=p;
            p->next=front;
            rear=rear->next;
        }
    }
    
    template<class T>
    T ex<T>::dequeue()
    {
        node *t;
        T x;
        t=front;
        x=t->data;
        front=front->next;
        rear->next=front;
        delete(t);
        return x;
    }
    
    template<class T>
    void ex<T>::print()
    {
        node *p=front;
        do
        {
            cout<<p->data<<endl;
            p=p->next;
        }while(p!=rear->next);
    }
    
    template<class T>
    void ex<T>::move_next()
    {
        front=front->next;
        rear=rear->next;
    }
    

    And the third file into Main.cpp or something.

    #include "ex.cpp"
    void main()
    {
        ex<int> e;
        int m,n,i,d;
        cout<<"Enter the number of people";
        cin>>n;
        cout<<"Enter the number of passes";
        cin>>m;
        for(i=1;i<=n;i++)
            e.enqueue(i);
        cout<<"The players are
    ";
        e.print();
        cout<<"Eliminated in order
    ";
        while(n>1)
        {
            for(i=1;i<=m;i++)
                e.move_next();
            d=e.dequeue();
            cout<<d<<endl;
            n--;
        }
        d=e.dequeue();
        cout<<"Winning player:  "<<d<<endl;
    }
    

    Then compile it. Also, it’s supposed to be int main() not void main()

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

Sidebar

Related Questions

Very new to python and can't understand why this isn't working. I have a
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
This is based on a question I asked yesterday. It got very muddled, so
I'm very new to drupal (started yesterday), I have created a content type called
I am very, very new with MVC (just started yesterday) so this question is
Very new to javascript and html-type stuff. I wanted to just make a quick
I very new to Python, and fairly new to regex. (I have no Perl
I'm very new to android, in fact only started yesterday. I managed to get
I asked a question yesterday about password safety... I am new at security... I
First of all, I am new to R (I started yesterday). I have two

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.