New and completely lost!

How would one go about completing this?


1)Write a program to read in two integers called x and y. (use cin)
2)Check to make sure that y is not 0 because this will cause an error later.
For now you can simply change y to 1 if the user enters a 0 for y.
3)Compute x/y and store the result in z.
4)Output the z to the console (use cout)http://www.cplusplus.com/forum/post.cgi?w=new&i=851#
These are the basics. What have you completed so far?
When you are saying compute are you meaning output the sum to the console?
#include <fstream>
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
int x = 0;
int y = 0;
printf("Enter x:");
scanf("%d",&x);
printf("Enter y:");
scanf("%d",&y);
if (y == 0) y = 1;
double z = (double)x/y;
cout << "z: " << z << endl;
return 0;
}
Topic archived. No new replies allowed.