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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:09:16+00:00 2026-05-25T21:09:16+00:00

the assignment is: have a number saved in a string, then convert from a

  • 0

the assignment is: have a number saved in a string, then convert from a string to an integer–> convert that number to a decimal number from N-base the user inputs.

#include <iostream>

using namespace std;

int main()
{
    string snum;
    int n=0, base, res;

    cout << "enter n: ";
    cin >> snum;
    cout << "enter base: ";
    cin << base; //THIS IS LINE 13

    for (int i=0; i<snum.length(); i++) // des order
    {
        int digit = snum.at(i) - '0';
        n = (n*1) + digit;
        if (


       base <= 10
        )   res = base * n;

    cout << "n is " << res << endl;

    }

}

Im getting error: NO MATCH BETWEEN SIGNED AND UNSIGNED INTEGER EXPRESSIONS [Line 13]

ty all!!

*if u find any problems in logic please let me know!
*using codeblocks

  • 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-25T21:09:17+00:00Added an answer on May 25, 2026 at 9:09 pm

    with

    cin << base; //THIS IS LINE 13
    

    you mean

    cin >> base;
    

    EDIT:

    you should convert the number differently, instead of grabbing each character take the whole string and convert it to a number. You can use a stream for that or just atoi( sum.c_str() ) to get the integer number.

    thereafter convert the value to whatever base you want.

    e.g.

    snum=12 (converted to integer from input string)
    base=8
    
    12 - 8 (>8, number of times you can subtract) --> 1
    4 - 8 (<8 use remainder) --> 4
    
    output == 14
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a user control that captures some user input and has a
I have an assignment in which I need to create a function that tells
I have this assignment due that requires the usage of FLTK. The code is
I have this assignment where I must delete a chosen element from an array,
I have an assignment that requires us to implement a doubly linked list class.
I have a design and run-time component that contains a large number of event
I have an assignment to measure the number of UDP messages dropped between client(s)
I have a class assignment where I have to write a program that will
I have an assignment where I have questions that ask for the following implementations:
I have two tasks for an assignment, one return the number of bits in

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.