newbie :P

This is a discussion on newbie :P within the C++ Programming forums, part of the General Programming Boards category; This is the task: Given two positive integers m and n. Determine the number m n last digit sum. Sharing ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Unhappy newbie :P

    This is the task: Given two positive integers m and n. Determine the number m n last digit sum. Sharing the figure should be quantified.


    Code:
    #include <iostream>
    using namespace std;
    int main ()
    {
        int   m,n,k,j=0,sum2=0,sum,sum1=0,z;
    
    
        cout<<"ievadiet skaitli M: \n";
        cin>>m;
        
          cout<<"ievadiet skaitli N: \n";
        cin >>n;
    
    
       for (int  i=0; i<=n; i++)
       {
          sum=m%10;
          
              sum1=sum1+sum;
           
    do
          {      
    m=m-10;
    j++;     
     m=j;
          }
          while (m>=10);
             
    //m=m/10;
    
          
    }     
    
      cout<<sum1<<endl;
    
        
        system("pause");
        return 0;
    }

    Why this program is not the same with it :

    Code:
    #include <iostream>
    using namespace std;
    int main ()
    {
        int   m,n,k,j=0,sum2=0,sum,sum1=0;
    
    
        cout<<"ievadiet skaitli M: \n";
        cin>>m;
        
          cout<<"ievadiet skaitli N: \n";
        cin >>n;
    
    
       for (int  i=0; i<=n; i++)
        {
        sum=m%10;
          
          sum1=sum1+sum;
           
    m=m/10;
       
    }     
    
           cout<<sum1<<endl;
     
        system("pause");
        return 0;
    }
    Last edited by cry4you; 10-09-2009 at 09:51 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 07:46 AM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 02:17 PM
  4. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 03:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21