Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JASdeep11 Group Title

how would i write this into at least one function using what i have already

  • one year ago
  • one year ago

  • This Question is Closed
  1. JASdeep11 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    #include<iostream> using namespace std; int main() { int original, temp1, temp2, sum, remainder; int first, second, third, fourth; cout<<"enter an 8 digit number"<<endl; cin>>original; temp1=original/100; first=original%100; temp2=temp1/100; second=temp1%100; fourth=temp2/100; third=temp2%100; sum=first+second+third+fourth; remainder=sum%26; cout<<"the first number is "<<first<<endl; cout<<"the second number is "<<second<<endl; cout<<"the third number is "<<third<<endl; cout<<"the fourth number is "<<fourth<<endl; cout<<"when the numbers are added it is "<<sum<<endl; cout<<"the remandier is "<<remainder<<endl; cout<<"adding character is : "<<(char)(remainder+65); return 0; }

    • one year ago
  2. eSpeX Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Functions are great for repetitive tasks, take any one of the steps you are repeating and turn it into a function. For example, int get_six(int x){ return x/100; } temp1= get_six(original); temp2=get_six(temp1);

    • one year ago
  3. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Another metric for creating functions, is after you comment your code, if you read down through it, you see "paragraphs" or "stanzas" of code, they'd be candidates for a function.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.