I need help so bad

done
Last edited on
someone please help?
Oh don't worry, I will help. (Of course not to the point of typing this) But dear god... and you JUST moved into the class?

Edit: As listed bellow, that's a good source. Tell us if you need help on that material, I just got you started on the basic stuff below below, so you don't freak out.
Last edited on
I'm sorry to say, but nobody will simply write this for you. I sympathize for your situation but you will need to write some code and show us what you have in order to really get some help. Otherwise, this site offers a lot of great tutorials to get started and honestly this is simple stuff that even someone with 1-2 days experience with C++ could get done in a few hours. Just gotta get some reading done.

http://www.cplusplus.com/doc/tutorial/
Search up for loops, "%" in c++, std, and "stop" you could find fairly easily.
I'll give you help on most of this just to get you going.

1
2
3
4

cout<<"Input n"; //It's how they got the "n" thing going
cin>>n; 

So now you know how to get the variable input thing.
1
2
3
4

n%2 =0 // 0 is what should happen if it's positive here
(n+1)%2 =0 // and odd here

here you now know how to c heck for positive, negative ( x%y x=number being checked if it's divisible by y, y is the one that's checking)

1
2
3
4

while(x==y) // This loop would continue while x equals y and stop once it doesn't.
while (x!=y) // This loop would continue while x is not equal to y, most of you problems would use this

Last edited on
I changed my major and joined this class but its too difficult I dont know that much stuff.
ALL I know is start with this stuff
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;
{
		

	return 0;
}

thats all I know. This assignment due on tomorrow night. i know no one will do my homework but I need help. What stuff do I need to do this homework.
Your program will always have a main() function, that's where it starts.
You can then write as many additional functions as you want.

1
2
3
4
5
int main() // this function returns an int (integer)
{
    return 0; // zero is an integer
// function ends here, after the return statement
}


To use functions provided by C++, like for printing stuff or getting input from the keyboard, you will #include parts of the C++ library. For now, the iostream file is needed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
// you add a
// using namespace std;
// to prevent having to write `std::' in front of C++'s library elements
int main()
{
    // function body, inside the curly braces

    int n; // this variable holds the number the user gives

    std::cout << "Input your number: ";
    std::cin >> n;
    std::cout << "Your number is " << n << ".\n";
// call functions here...
    return 0;
}


You have to learn about control structures: if conditional, and for, while and do-while loops, here:
http://cplusplus.com/doc/tutorial/control/
Then the idiotic "count and print" parts should become easy.

Let's do the square, cube and square root parts.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cmath> // needed for the square root C++ library function, sqrt()

int square(int number)
// function is named square
// takes an integer as a parameter
// returns an integer, which will be the square of "number"
{
    return number * number;
}

int cube(int number)
{
    return number * square(number); // we have to use square()
}

double square_root(int number)
// this function returns a floating point number, not an integer
{
    return std::sqrt(number);
}

int main()
{
    // function body, inside the curly braces

    int n; // this variable holds the number the user gives

    std::cout << "Input your number: ";
    std::cin >> n;
    std::cout << "Your number is " << n << ".\n";

    // notice how the results from the functions are displayed
    // notice how the functions are being fed our n variable
    std::cout << "Square of " << n << " is " << square(n) << '\n';
    std::cout << "Cube of " << n << " is " << cube(n) << '\n';
    std::cout << "Square root of " << n << " is " << square_root(n) << '\n';
    return 0;
}


Good luck with the rest.

Edit: code tags, comments.
Last edited on
u c... well actually its simple... first u shud declare a choice variable( or just a variable! ). eg :
1
2
int ch;
cin>>ch; //getting input from user! 

and based on this choice, go in for a switch...case statement... use the net to get the basics of switch statements... its very simple... and get the cases on and put those operations... if u do all these, making the prog to quit only when the user wants s simple too... so gear up and learn the switch...case statements ( or if statement if u like, but it wud b hectic :/ )
Whether or not you actually succeed at this one particular assignment, I would highly recommend getting some IRL tutoring, ASAP in order to help catch you up on the crucial concepts you're going to need to be able to do well in that class. Check if your institution offers tutoring and see what you can do. Good luck.
Topic archived. No new replies allowed.