i need some help.. this is for our C++ project.. :( can somebody help me? i'm just a beginner in C++.. (THANK YOU!)

1) LARGE NUMBER

For the purposes of this problem we will define a large number as a positive whole number with at least eight digits. For example, 123456789 is a large number. Large numbers must NOT be expressed in exponential form.

Write a program that:

(1) asks for two inputs.

WHAT IS THE FIRST LARGE NUMBER?

WHAT IS THE SECOND LARGE NUMBER?

and

(2) then calculates the product of your two large numbers and prints;

THE PRODUCT OF your first large number
AND your second large number
IS the calculated product.

Test your program with 1234512345123451234512345 as your first large number and 9876598765987659876598765 as your second large number.


2) Shampoo Problem

Susan has just bought a new 100 ml bottle of shampoo. Each time she shampoos, she uses 5 ml of liquid. After removing the 5 ml, she replaces it with 5 ml of water and then shakes the bottle. Thus the shampoo gets weaker and weaker after each use. She repeats this procedure until the first occasion the shampoo is half or (less than half) the original concentration. She uses it at this strength until it is gone.

Write a program which

(1) Determines how many shampoos Susan gets before she stops watering it down.

(2) Prints the concentration after each use until the bottle is empty.

this is what i did in problem1:

#include<iostream>
#include<cmath>
using namespace std;

int product(int, int);

long int Array;

int main()
{
long int x, y;
char myArray[255], myarray[255];
char num1, num2;

cout<<"Enter Your First Large Number: "<<endl;
cin>>myArray;

cout<<"Enter Your Second Large Number: "<<endl;
cin>>myarray;

num1=myArray[255];
num2=myarray[255];
x=atoi(&num1);
y=atoi(&num2);

Array=x*y;

cout<<"The Product Of "<<myArray<<" and "<<myarray<<" is "<<Array<<endl;

return 0;
}

but i can't get the exact product of the 2 large numbers..

i have no idea in problem2.. :( can somebody give me an idea with what i'm going to do?

First: Read the rules and use code-tags

but i can't get the exact product of the 2 large numbers..

You're using atoi() (for ints) when you should use atol() (for longs), but even then it won't work
That's the whole point of the assignment. A (signed) long can only hold values up to 4294967295, so there's a bit more logic involved then you would hope (because two numbers with 8 digits multiplied will be far greater then 4294967295)

So read my link in post 1

what will you do if the input is more than 8 digits but the program should only accpet 8 digits? am i going to use if-else statements??

Yes.
First of all: I would use a std::string to get the input in, instead of char array's. But if you are required to use them, you could use the strlen() function to check how long the input is (how many digits)

This article has been dead for over six months. Start a new discussion instead.