Page 1 of 1

First C program made by me :)

Posted: Tue Feb 12, 2008 9:34 am
by Sethioz
tought that ill post it lol.
its the first program i actually wrote in C. It works thru cmd.
Note that ive never learned C before and it took me only 1-2 hours to write it totally on my own.
C is quite easy actually :)
was thinking to make calculator, but its kind a waste of time. Its very easy to make tho. Kind a got tired of reading C tutorials so blah...but ill make simple calculator next...or something similiar.
:iiN:

edit:
oh yeah .. heres the source code too:

Code: Select all

#include <stdio.h>

int main()
{
  int number;

  printf( "Enter a number to check if its smaller or bigger than 303: " );
  scanf( "%d", &number );
  if ( 303 < number )
    printf( "number is bigger than 303" );
    
  if ( 303 > number )
    printf( "number is smaller than 303" );  
    
  if ( 303 == number )
    printf( "number is equal to 303" );

  getchar();
  printf( "\nPress enter to continue..." );
  getchar();
  printf( "\nEnter a number to check if its equal to 303: " );
  scanf( "%d", &number );
  if ( 303 == number )
    printf( "number is equal to 303" );
    
  else {
    printf( "number is not equal to 303" );
  }
  getchar();
  printf( "\nPress enter to quit..." );
  getchar();
}

Re: First C program made by me :)

Posted: Tue Mar 09, 2010 9:01 pm
by Vinlaell
good job man, looks very similar to my first c experiment too, but C is to me one of the hardest languages since it provides the low level access to get things done, thats why you need to use third party libraries for things like sockets/databases etc or it would most certainly NOT be easy to get a sproject done unlike with a newer managed language like C# you can just click a few times to get database access and widgets etc, C is only easy for making straight to the point tool applications.. like say your playing unreal tournament 3, unrealscript (game engines script language) does not give you access to execute commands on the pc's "cmd"thingie, but coding a C++ server that listenes on a local port for your videogame client to connect to it with unrealscripts "tcplink" class, you can send a command to the c++ server running on local pc to play a mp3, from within unrealscript ingame, this is actualy quite easy with C++and bridges the gap between ingame script and pc command execution.

Re: First C program made by me :)

Posted: Tue Mar 09, 2010 9:25 pm
by TeamRetox
C++ > C badly
C is ugly :(

Code: Select all

#include <windows.h>
#include <iostream>
using namespace std;

int main()
{
    int number;
    cout<<"Enter a number to see if its bigger, lower or equal to 1337"<<endl;
    cin>>number;
    cout<<"You\'ve entered \""<<number<<"\", which is ";
    if(number<1337)
    {
        cout<<"smaller then 1337"<<endl;
    }
    else if(number>1337)
    {
        cout<<"bigger then 1337"<<endl;
    }
    else
    {
        cout<<"equal to 1337"<<endl;
    }
    return 1;
}

Re: First C program made by me :)

Posted: Tue Mar 09, 2010 10:17 pm
by Sethioz
i did that after 1 day of reading about C, i don't think that there's many ppl who can do that without any knownledge of C at all.
I didn't know anything about C before that, i read about it one day (not whole day) and then wrote this, just to test if i can write something.