someboddy Posted October 18, 2002 Author Share Posted October 18, 2002 To hell with that! hahaha... too much for my brain! How about this:10 print 10*10run100end There you have the program. command to run it. and the output...... granted, it won't be the next Quake Engine but hey.... hahaha 10 print"End of TapeWurm's Stupid Message"runEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid MessageEnd of TapeWurm's Stupid Message What softwere did you use?tapeworm++?visual tapeworm? Link to comment Share on other sites More sharing options...
someboddy Posted October 18, 2002 Author Share Posted October 18, 2002 type this program: #include <stdio.h> void main(){ int num; printf("ngive me a number "); scanf("%d",&num); if (num>0){ printf("your number is positiven"); } if (num<0){ printf("your number is negativen"); } if (num==0){ printf("your number is zeron"); } } and now I will explain: from now on I will explain only the new commands. if (num>0){this is a "if" command. when the programs reach to a if command, it only does the commands between the "{" and "}", if the term between the baraks is true. that mean, that only if "num>0" when the program reach to the if command, it will do the commands between the "{}" ("printf("your number is positiven");") A if command may have anuther part: the "else" part.if (<term>){<code1>}else{<code2>} if <term> is true, do <code1>, else do <code2>. Link to comment Share on other sites More sharing options...
ken_cinder Posted October 21, 2002 Share Posted October 21, 2002 What softwere did you use?tapeworm++?visual tapeworm?No that wold be good ol BASIC. Thanks for the quick insight on some short programs in C++I've been looking for an excuse to crack open my Viz studio 6 CD's, and something simple like this may just gimme a bit more of a push. Link to comment Share on other sites More sharing options...
someboddy Posted October 21, 2002 Author Share Posted October 21, 2002 type this program:#include <stdio.h> void main(){ int x,sum; printf("ngive me numbersn"); sum=0; x=1; while (x!=0){ scanf("%d",&x); sum=sum+x; } printf("Your numbrs total is %d.n",sum);} the new command is while loop. this is how the wile loop works: while (<term>){<code>} when the program is getting to a while loop, it checks <term>, if <term> is true, the program do <code>, else, it continus the code after the loop.when the program end's <code>, it's check <term> again, if <term> is true, the program do <code>, else, it continus the code after the loop. while loop are good when you dont know how many times the loop shold be, and you dont have this information on a variable. Link to comment Share on other sites More sharing options...
someboddy Posted October 22, 2002 Author Share Posted October 22, 2002 Type this program:#include<stdio.h> void main(){ int a[5],b[5],c[5],i; for (i=0;i<5;i++){ printf("ngive me two numbers('a,b') "); scanf("%d,%d",&a,&b); c=a+b; } for (i=0;i<5;i++){ printf("n %d+%d=%d",a,b,c); } printf("nnn");} there are parts here that I have allrady explaind, so I only explain the new thing: the array. array is a set of variables that have serial numbers. when you want to use one of the variables in the array, you use it like this: <array name>[<variable serial number>]. for example: bla[5],x[7],set[9]. array is defined like a normal variable, only that a array have a "["&"]" around the number of variables. for example:int thing[3]; defines a array with a place for 3 integer variables. the serial number of the first variable in the array is 0. for example:if we have a array: staff[6], then the variables are: 'staff[0]','staff[1]','staff[2]','staff[3]','staff[4]' and 'staff[5]'. instend of puting a number inside the "["&"]", you can put an integer in it, like something. this makes arrays extreamly useful in for loops. Link to comment Share on other sites More sharing options...
someboddy Posted October 23, 2002 Author Share Posted October 23, 2002 this time I have two simple programs:#include <stdio.h> void main(){ float a,b,c; printf("nnGive me two numbers "); scanf("%f,%f",&a,&; c=a+b; printf("n %f+%f=%fnn",a,b,c);} this is a simple adding program, but it have diferent from the program in the second lesson: it uses real numbers, that mean that we can do 4.79+5.3, for example.using real numbers it's vwry similar to using integers but when you defining the variable, write "float " instend of "int ", and when using it in a "printf""scanf", write "%f" instend of "%d". and one more thing: you cant put a real number in a integer. Link to comment Share on other sites More sharing options...
someboddy Posted October 23, 2002 Author Share Posted October 23, 2002 type this program:#include <stdio.h> void main(){ char anser; printf("nnDo you like me?(y/n) "); scanf ("%c",&anser); if (anser=='y') printf("nI like you toonn"); if (anser=='n') printf("nThis means war!!!nn");} the char is a single character variable. Link to comment Share on other sites More sharing options...
someboddy Posted November 1, 2002 Author Share Posted November 1, 2002 type this program:#include<stdio.h>void main(){ char name[100]; printf("nnWhat's your name? "); scanf("%s",&name); printf("Hello %snn",name);} when you make an array of char's, you can use it as a string, but instend of typing "%c", type "%s". Link to comment Share on other sites More sharing options...
someboddy Posted November 1, 2002 Author Share Posted November 1, 2002 These are the basic of c, and as soon as I whill learn C++, I whill teach you that too. Link to comment Share on other sites More sharing options...
emsley Posted November 1, 2002 Share Posted November 1, 2002 Just one question?What the hell would it do if i learned it?People who talk programing are crazy Link to comment Share on other sites More sharing options...
someboddy Posted November 1, 2002 Author Share Posted November 1, 2002 You will be able to create programs and games. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now