First C program made by me :)

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.

First C program made by me :)

Postby Sethioz » Tue Feb 12, 2008 9:34 am

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();
}
Attachments
303.rar
(4.51 KiB) Downloaded 203 times
User avatar
Sethioz
Admin
Admin
 
Posts: 4757
Joined: Fri Jul 27, 2007 5:11 pm
Location: unknown

Re: First C program made by me :)

Postby Vinlaell » Tue Mar 09, 2010 9:01 pm

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.
Vinlaell
Allie
Allie
 
Posts: 12
Joined: Mon Jan 11, 2010 12:47 pm

Re: First C program made by me :)

Postby TeamRetox » Tue Mar 09, 2010 9:25 pm

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;
}
TeamRetox
Allie
Allie
 
Posts: 222
Joined: Sat Jun 06, 2009 3:48 pm

Re: First C program made by me :)

Postby Sethioz » Tue Mar 09, 2010 10:17 pm

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.
User avatar
Sethioz
Admin
Admin
 
Posts: 4757
Joined: Fri Jul 27, 2007 5:11 pm
Location: unknown


Return to Programming / Coding / Debugging

Who is online

Users browsing this forum: No registered users and 1 guest