0

I'm unable to get the first number of my (5) input numbers it's always 4 numbers that are adding to my lastn variable. I'm new and I want to learn c++ more.

result when I compile and run

#include <iostream>

using namespace std;

int main()

{
    int lastn,firstn,main_var;

    do{
        
    cout << "Input five (5) numbers: ";
    cin >> main_var;
    
    lastn=main_var%10;
    cout <<"The last number is:\t"  << lastn << endl << endl;
        
    }
    while(main_var<10);  
    {
        firstn=main_var;
        firstn=main_var/10;
    }
    cout <<"The first number is:\t" << firstn << endl << endl;
    
    cout << firstn << "\t+\t" << lastn <<"\t=\t" << firstn+lastn << endl;
    
return 0;
}
cigien
  • 57,834
  • 11
  • 73
  • 112
Raven
  • 1
  • 2
  • 5
    It looks like you need to do a beginner's tutorial. There's lots of things here that aren't right at all. Stackoverflow is really for when you have a very specific problem/misunderstanding. To help you here I feel that I'd be repeating a tutorial course on variables, assignments, loops, etc. – Elliott Oct 30 '20 at 04:14
  • You should get a [Good C++ Book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list).. Check out the link. – Geno C Oct 30 '20 at 05:05
  • You may want to take a moment and make sure you understand how [do-while loops](https://www.w3schools.com/cpp/cpp_do_while_loop.asp). –  Oct 30 '20 at 05:47

0 Answers0