Practice Make Perfect!

find the right most number

Posted by: dzikrina on: July 24, 2008

// find the right most number
# include <iostream>
using namespace std;
int main ()
{
 int num1, num2;
 num1 = 1000;
 num2 = 209;
 
 cout <<”the rightmost number of num1 is “<<num1%10<<endl;
 cout <<”the rightmost number of  num2 is “<<num2%10<<endl;
 
 system (“pause”);
 return 0;
 
}

or you can use this one

 

// find the right most number
# include <iostream>
using namespace std;
int main ()
{
 int num1, num2;
 num1 = 1000;
 num2 = 209;
 
 cout <<num1<<” % 10 = “<<num1%10<<endl;
 cout <<num2<<” % 10 = “<<num2%10<<endl;
 
 system (“pause”);
 return 0;
 
}

4 Responses to "find the right most number"

C++…hmmm…..i haven’t study it yet…….but, i think for the problem above, it is more effective if we use function. Here is the example in C-language :

int main()
{
int num[2];

for(i=0;i numB)
{
return (numA);
}else{
return (numB);
}
}

we did not study the ‘for’ and ‘else’ yet,,,,hehe,,,,

but thank you for your contribution :D

Why ???

i think my comment isn’t same as the comments above !!
is it something wrong??

no your’s are correct Bro,,,

if we already learn “for” and “else” we can use your code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.