473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

simple coding error

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3.  
  4. int main;
  5. int max;
  6. char M,G,R,Q
  7. int num1
  8. int num2;
  9. int base;
  10. int power;
  11.  
  12.  
  13. {
  14. printf("Welcome to Math Helper v0.1, This program is designed to help you wi$
  15. mulipication, exponents, and finding the greatest common divisor.");
  16.  
  17. printf("Please choose of the following options \n M=Print a muliplication ta$
  18. G-Find the Greatest common divisor \n R-Raise a number to a power \n
  19. Q-quit \n %f  ", char);
  20.  
  21. scanf("%f  "; &MS);
  22.  
  23.  
  24. if (MS=M)
  25. void PrintMultiplicationTable(int max);
  26.  
  27. if (MS=G)
  28. int GreatestCommonDivisor(int num1, int num2);
  29.  
  30. if (MS=R)
  31. int RaiseToPower(int base, int power);
  32.  
  33. if (MS=Q)
  34. exit
  35.  
  36.  
  37.  
  38. return 0;
  39.  
  40. }
  41.  
given is the code i've worked on and i keep getting the same errors on the same lines even though i've corrected them to my best. Please help and show me where and how i can fix if you can. Thank you.
May 11 '08 #1
3 1065
Banfa
9,065 Expert Mod 8TB
If you are getting errors you would like help fixing then you should post the errors you are getting.

Also if this is your complete code then you are lacking the basic structure for a C (or C++) program, please check you text book for the first program example given in it.
May 11 '08 #2
JosAH
11,448 Expert 8TB
I don't consider the above C or C++ code; it lacks the basic structure imposed by
those languages and therefore I don't consider this a 'simple coding error'. Please
rewrite that gibberish to make it suitable for discussion in a proper C or C++ forum.

kind regards,

Jos
May 11 '08 #3
questionit
553 512MB
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3.  
  4. int main;
  5. int max;
  6. char M,G,R,Q
  7. int num1
  8. int num2;
  9. int base;
  10. int power;
  11.  
  12.  
  13. {
  14. printf("Welcome to Math Helper v0.1, This program is designed to help you wi$
  15. mulipication, exponents, and finding the greatest common divisor.");
  16.  
  17. printf("Please choose of the following options \n M=Print a muliplication ta$
  18. G-Find the Greatest common divisor \n R-Raise a number to a power \n
  19. Q-quit \n %f  ", char);
  20.  
  21. scanf("%f  "; &MS);
  22.  
  23.  
  24. if (MS=M)
  25. void PrintMultiplicationTable(int max);
  26.  
  27. if (MS=G)
  28. int GreatestCommonDivisor(int num1, int num2);
  29.  
  30. if (MS=R)
  31. int RaiseToPower(int base, int power);
  32.  
  33. if (MS=Q)
  34. exit
  35.  
  36.  
  37.  
  38. return 0;
  39.  
  40. }
  41.  
given is the code i've worked on and i keep getting the same errors on the same lines even though i've corrected them to my best. Please help and show me where and how i can fix if you can. Thank you.

There are several syntax errors in your program. Use of ';' at incorrect places itself is the cause of errors.
You have also missed ';' at declaration of the char variables and at declaration of 'num1'

You are missing main(), without which the program will not run.

Incorrect syntax is used to check for equality in if().

C/C++ doesn;t allow to use C/C++ keywords as variable names. Please check your first printf() statement to see the error.

Also, syntax of scanf() needs your attention.
Also, you have in the scanf() 'MS', which is not defined in the program.


Moreover, to call a function, function name is used without a ';' in the end.
In case of your example, this is a declaration of a function , not a call to it. Function declaration is not permitted in these places where you have them anyway.

This was just a brief. Please learn more C/C++ and re-write your code and let us know if you get errors again.

Regards
Qi
May 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JC | last post by:
Hi - I'm currently learning PHP using the ORA "cuckoo" book. I'm looking for some reasonably interesting sample code to read and thought that a *simple* Wiki could be ideal. Can anyone recommend...
38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
8
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value...
10
by: Brennan Young | last post by:
Hi there, First I'll apologise for my ignorance! I have been attempting to compile some code that I found on the net. AFAICT it's intended to be portable code (it was available as source and...
2
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then...
7
by: javedna | last post by:
Hi guys Ive got a simple problem, im designing an online questionnaire and on submission the coding that I have used to validate whether a user has filled in all the questions is supposed to...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.