Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Identify syntax errors in the following program. After corrections, what output would you expect when you execute it
C#
#define PI 3.14159
Main()
{
Int R, C
Float perimeter
Float area;
C = PI
R = 5;
Perimeter = 2.0*C*R;
Area = C*R*R;
Printf("%f" "%d", &perimeter, &area) }


What I have tried:

I've tried thinking on the errors that are present in that program. And the output I'll have when I finally remove the errors and run it.
Posted
Updated 27-Mar-23 3:47am
v2
Comments
Richard Deeming 16-Jun-21 8:44am    
Nobody here is going to do your homework for you.

If you really don't know where to start, then talk to your teacher.
CHill60 16-Jun-21 9:09am    
I guess your first problem is that it is not C# :laugh:
Richard MacCutchan 16-Jun-21 9:57am    
Nor is it plain C. So your first challenge is to convert it into an actual compilable language.

We're more than willing to help anyone with a genuine problem but we will not do your homework for you!

The first problem is that you have tagged your question as "C#" but you have posted what looks to be C++. One of the things you will need to learn as you go through your course is to be precise.

If you have not been taught the basic syntax of C++ (such as what a main function should look like, how are statement blocks terminated, how to use standard functions like printf) then you really need to start at the beginning of your course reference material, or talk to your tutor.

If you do not have access to a compiler then you could try one of the on-line ones (e.g. https://www.tutorialspoint.com/compile_cpp_online.php[^] )
Hint: Only try to fix the very first compilation error each time - many of the subsequent errors reported will disappear when you fix the first one.

Once you have something that can run, don't just look at the answer. Walk through the program with a pencil and paper and work out the interim steps for yourself
 
Share this answer
 
v2
If you can't work out what errors the compiler is going to give you from that code, then try compiling it.

Then fix the first error and compile it again. Repeat until you run out of compiler errors.
Then you can run it - or better run it in your head - and see what it does.

I'll give you a hint: Case sensitivity - Wikipedia[^]
 
Share this answer
 
That's C, not C#.

I'll give you a hint. There's over a dozen problems to fix.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900