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

Recommended Answers

All 17 Replies

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.

ty veymuch jonsca

//'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();

}

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;
}
commented: Bad Form =/ +0

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

Sorry, but I think you should Read This Before Posting .. scroll down to the "Don't give away code!" section.

commented: Yes! +15
commented: Bin-gooooooooo as Larry David would say +4

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.

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

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

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.

commented: Good +15
commented: Seconded +4

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();

}
commented: Not C++, spponfeeding and horrible code -3

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

Good, don't =)

But if that's true why did you repost it? :P

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 ;)

commented: Too true +4

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.

commented: That's the spirit. +1

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.