[VIEWED 7153
TIMES]
|
SAVE! for ease of future access.
|
|
|
lateralus
Please log in to subscribe to lateralus's postings.
Posted on 07-25-07 7:18
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I need help writing this program in C++....if anyone has some time to write it donw...would really appreciate it. QUESTION: Write a c++ program that will ask you for a number.Expect the user to enter only positive integers from 0 to 32,767.Then tell if it is "prime", "not prime" or an "emirp".The program should continue until a zero is entered.Emirps are special cases in prime numbers that are reversed.For example 37 is an emirp because not only it is prime, but so too is 73 (reverse of 37) The output should consist of a number being investigated followed by the pgrase prime, not prime or emirp.There should be only one result per line. SAMPLE RUN Enter a number 37 37 is an emirp. Enter a number 39 39 is not prime. Enter a number359 359 is an emirp. Enter a number 32713 32713 is an emirp. Enter a number 773 773 is a prime Enter a number 0. system("pause") is to be used. Thanks whoever is interested....
|
|
|
|
MrNobody
Please log in to subscribe to MrNobody's postings.
Posted on 07-25-07 7:42
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
waaiyaaat!!! k ho programming assignment ko solution (code) nai online magne? baru ghanta kam garera padhai ma time diyeko bhaye huncha ni..... ki kaso saathi haru? I hope no one will give any help in this matter....
|
|
|
lateralus
Please log in to subscribe to lateralus's postings.
Posted on 07-25-07 7:46
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
nicely said Mr.nobody......it is an assignment ....i tried doing it...but got stuck with the emirp thingie..."i hope noone will give any help in this matter re"...haha...alright....
|
|
|
MrNobody
Please log in to subscribe to MrNobody's postings.
Posted on 07-25-07 9:58
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
ok to check if the number is "emrip" or not do the following task- 1. check if the number is prime or not. 2. if the number is prime then reverse it.. like if 37 is the input its reverse will be 73. 3. check if the reverse number is prime too. if it is, then the number is "emrip" otherwise its prime only. things look pretty easy.... so try iy
|
|
|
rajeshHamal
Please log in to subscribe to rajeshHamal's postings.
Posted on 07-26-07 12:12
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Don't remember much of a syntax in C++..I can think only in VBA. But the logic I can think of for the "emirp" part is: First: Convert the Number to String. Probably like this: string B = (string) A. Second: Reverse the String using some code (probably the one here: Third: Convert target=_blank>http://uw714doc.sco.com/en/SDK_c++/_Reverse.html) Third: Convert the reverse string back to number. (how?) and then test for prime or no prime. Other guruz might know better. Good luck.
|
|
|
lateralus
Please log in to subscribe to lateralus's postings.
Posted on 07-26-07 12:14
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
how do i reverse a prime number...i.e. how do i get a emrip...---code pls if possible...thanks for the feedback mate..take it easy...peace
|
|
|
rajeshHamal
Please log in to subscribe to rajeshHamal's postings.
Posted on 07-26-07 12:35
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
( Found on http site uw714doc.sco.com/en/SDK_c++/_Reverse.html ) String reverse(String s) { String rslt; for(int i=length(s)-1;i>=0;i--) rslt += s.char_at(i); return rslt; } See if it reverses a string. But first you have to convert your Number to string.
|
|
|
rajeshHamal
Please log in to subscribe to rajeshHamal's postings.
Posted on 07-26-07 12:42
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
or just here... bluefintuna.wordpress.com/2006/08/18/q10235-simply-emirp/ (googled "emirp algorithm")
|
|
|
divdude
Please log in to subscribe to divdude's postings.
Posted on 07-26-07 12:43
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Do something like this, Say you have a prime number, int i=37 Divide i by 10(integer division) so int firstnumber=i/10(=3) int secondnumner=i-firstnumber*10(remember 10 used is the value of decimal place of each number. for larger number it will change) int reversed number=secontNumber*10+firstNumber
|
|
|
sangfroid
Please log in to subscribe to sangfroid's postings.
Posted on 07-26-07 5:53
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
#included using namespace std; int main(int argc, char* argv[]) { int input; cout << "Enter the number to be checked"; cin >> input; cout >> process(input); } String process (int input) { cout >> " This seems to be simple program...Try to do yourself.."; cout >> "Feeding with spoon is bad for health"; cout >> " Abnormal Program Termination"+ int(1/0); exit(0); }
|
|
|
lateralus
Please log in to subscribe to lateralus's postings.
Posted on 07-26-07 6:24
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
actually i finally fixed the problem...and the program ran well...thanks for your guy's help...peace.....now finally i can smoke dem wicked joints of time...later....peace.............
|
|
|
tru
Please log in to subscribe to tru's postings.
Posted on 07-28-07 3:51
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
could u please show me how u did it....im havin lots of trouble and i cant get it right...
|
|