my prof give us assignment but she doesn't explain what to do

im just asking what will be the code

to this problem:

write a program that will find the area of square.. (look for the relevant formula)

ty for the one who will help ty very much

What have you tried so far?

Can you take in the input from the user? Do you know the formula for the area of a square (it's not hard and should be on millions of internet sites if you really don't remember)? Bring those two together and output the result.

Write parts of it and check to see that they work before continuing.

//'here is the code to calculate an area of a square or rectangle in C
//'to convert to c++ just read how to use cin and cout and the right include file.
#include <stdio.h>
#include <conio.h>

long width;
long length;


int main(int argc, char *argv)
{
       clrscr();
 
     printf("Enter Width:");
     scanf("%ld",width);
     printf("Enter Length:");
     scanf("%ld",length);

     //** Formula Length Times Width = area of the object
     printf("Area of object:%ld\n",width * length);
     
     printf("Press any key to continue..");
     char c;
     c = getch();

}

Edited 6 Years Ago by technology: n/a

Here is the same code similar to the C code in C++ to save you the bother. Thread Solved.

#include <iostream.h>

int main (int argc, char * argv)
{
   long width;
   long length;
   char c;

   cout << "Enter Width:";
   cin >> width;
   cout << "Enter Length:";
   cin >> length;

   cout << "Area:" << length * width;
   cout << "\n" ;
   cout << "Press any key to continue..";
   cin >> c;
}

Edited 6 Years Ago by technology: n/a

Comments
Bad Form =/

Since the code posted contains a total of ten mistakes and is also meant for a rectangle, the OP will still need to show some initiative of his own.

Since the code posted contains a total of ten mistakes and is also meant for a rectangle, the OP will still need to show some initiative of his own.

what are the ten mistakes pobably posting the code was the ten mistakes, emember im a newbie

Edited 6 Years Ago by technology: n/a

1. Your code is badly formed and partially incorrect.

2. We are not here to solve threads as quickly as possible or to rack up a huge "Thread Solved" count on our profiles. We are here to help inexperienced developers learn how to improve their code and problem solve better. Also, to use our experience to help them learn advanced functionality (Remember having to learn how to implement Threading by yourself?)

3. Feeding code to people who show little or no effort, do not learn. Also, you are assisting in plagiarism. I know several University lecturers in the UK who read Daniweb for such an occurrence. I cannot say for sure about other countries but I imagine some do. Therefore, handing out code is liable to make them fail, or worse, be kicked off the course.

As for the OP: Firstly, if you do not know how to calculate the area of a square, use Google. It's very simple.
Secondly, I imagine it has not been thoroughly explained because it is a very simple task. The only place you would really fall down on are the input and error checking.
In cases like this one, you should really talk to your professor first as they're the ones most likely to give you the best help.

Comments
Seconded
Good

point out the ten mistakes for me to ponder why i exist even

Line 2 (iostream), line 4 (char**), rest is missing std:: name qualifiers.

//'here is the code to calculate an area of a square or rectangle in C
//'to convert to c++ just read how to use cin and cout and the right include file.
#include <stdio.h>
#include <conio.h>

long width;
long length;


int main(int argc, char *argv)
{
       clrscr();

     printf("Enter Width:");
     scanf("%ld",&width);
     printf("Enter Length:");
     scanf("%ld",&length);

     //** Formula Length Times Width = area of the object
     printf("Area of object:%ld\n",width * length);

     printf("Press any key to continue..");
     char c;
     c = getch();

}
Comments
Not C++, spponfeeding and horrible code

Im not the original poster of the question just a newbie posting here to help people so thats all.
I wont be posting complete solutions ever again

Line 2 (iostream), line 4 (char**), rest is missing std:: name qualifiers.

Thanks for the help where there where errors;

I wont be posting complete solutions ever again

That is not wisdom my friend. It is a matter of show-effort-and-we-help!
If he shows enough effort you can help him like that but not give him copy and paste and bang, here is 100%. Some people use week(s) trying to resolve same problem showing a lot of efforts, reading a lot. I think it is fair for big hand to be given to those but not lazy gimme boys.

I would rather get MY 0% than get 100% which is NOT MINE.
I think that should be the motive, but then that is my opinion ;)

Comments
Too true

That is not wisdom my friend. It is a matter of show-effort-and-we-help!
If he shows enough effort you can help him like that but not give him copy and paste and bang, here is 100%. Some people use week(s) trying to resolve same problem showing a lot of efforts, reading a lot. I think it is fair for big hand to be given to those but not lazy gimme boys.

I would rather get MY 0% than get 100% which is NOT MINE.
I think that should be the motive, but then that is my opinion ;)

I thought I had to give 100% solution to any problem that came along but now Im warned becos he was looking for easy solution to his college work I came along and like a mug have given him the work he was looking for. But not anymore full solutions unless its required. I will give hints and guides but not full final code for solutions.

Comments
That's the spirit.

But not anymore full solutions unless its required. I will give hints and guides but not full final code for solutions.

You got it!Cool :)

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