Here is a simple program in python:
def main(): fuzzy = 3 buzzy = 6.5 catsages(fuzzy,buzzy) raw_input("press <Ret> to end program.") print "Goodbye!" def catsages(age1, age2): cats = age1 + age2 dogyears(cats) def dogyears(age): if age < 0: print "Negative age?!? Back to the future." elif age < 3 or age > 110: print "Frankly, I don't believe you." else: print "That is ", age*7, "in dog years."
And here is its translation into C++ code:
#include <iostream> using namespace std; void catsages(int age1, float age2); void dogyears(float age); int main() { int fuzzy = 3; float buzzy = 6.5; catsages(fuzzy,buzzy); cout << "press any letter key then <Ret> to end program."; char x; cin >> x; cout << "Goodbye!" << endl; } void catsages(int age1, float age2){ float cats = age1 + age2; dogyears(cats); } void dogyears(float age) { if (age < 0) cout << "Negative age?!? Back to the future." << endl; else if (age < 3 || age > 110) cout << "Frankly, I don't believe you." << endl; else cout << "That is "<< age*7 << "in dog years." << endl; }
Discussion
No comments yet.