Jump to content

my c programs

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
bobwrit

bobwrit

    Newbie

  • Members
  • PipPip
  • 28 posts
here's some of my programs. there all in c. tell me what you think of them.

Attached Files



#2
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
Nice collection there! Some good math stuff there:

arcsine.cpp
case_geo.cpp
cos.cpp
sine.c
tan.cpp

#3
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Which editor are you using? I'm using Dev-C++ and the code looks very strange, with biiiig indents, and stuff like that. I prefer an indent of 2-4 spaces in size.

It's generally a bad idea to use libraries such as conio, when it can be done without. You're trying to use the function, clrscr(), but it have never been a part of the conio-header.
conio.h: Conio.h - Wikipedia, the free encyclopedia

I did go trough all the source, looking for code to be optimized.
In var.c, line 13, you're doing like this:
clas = clas++;
Why use the assignment-operator. I know it's the same result, but why not just use
clas++;
This will be "translated" into
clas = clas + 1;
So you're old thingy will look like this
clas = clas = clas + 1;

In ifbegini.cpp you're using main with no return-type, but still returns something.
main() // Oops
{
    // ...
    return 0;
There's two things wrong in this.
1. You can't return anything with no return-type.
2. main() with any other return type than int, have never been standard-C nor C++.
In the same code, I would also suggest you to use a switch-statement, instead of the if...else if...else-statement. I will make a nicer-looking-code, imho. The same thing I'll say about geometry.cpp, and much of the other code. Generally you're using no return-type for the main()-function, or you're using void, which is also wrong.

You generally have to know whenever it's C or C++-code. Your files is changing between .C and .CPP-extensions, but all the code is C, so it should only be .C, for all the files.

#4
bobwrit

bobwrit

    Newbie

  • Members
  • PipPip
  • 28 posts
I was useing two compilers, mingw and turbo c++. I wrote most of them for a class that I have in c. I do have a tendency to swich my extentions. depending on the compiler typicaly the main without any type returning something is a warning and dosen't do anything to the code. I could leave out the return 0; code out of it if I wanted to but I didn't.

#5
stralol

stralol

    Newbie

  • Members
  • Pip
  • 1 posts
very nice stuffs