Meh.. I decided to cook up a simple user-based input example. I've decided to do a simple addition program, since it is a good way for people thats learning C to learn how to do user input stuff.
All code commented.
#include <stdio.h> //Include our files.
int main() //Startup our main program.
{
int a,b,answer; //Set a,b,and answer as our integers
printf ("Enter a number:\n"); //Print Enter a number. \n makes a new line
scanf("%d",&a); //Get user input, %d will read our set integer.
scanf("%d",&b); //same as abovee
answer = a+b; //Declare what answer is, then add a+b
printf("%d + %d = %d\n",a,b,answer); //print our problem then, print the answer and create a new line.
scanf("%d"); //Wait for user input to end.
return 0; //End everything! =P
}
edit: forgot to tell...
// is a comment
/*
This is a block
*/
printf prints the user defined text
scanf read's the defined integer.
---------------------
%'s now, this was confusing at first, really this is freaking convinent!
%d decimal integer.
%c single character
%i integer
%e, %f, and %g all are float values
%o octal number
%s cmon! A string =D
%x hexidecimal number
%p I smell pointers =P
%n integer that is equal to the number of characters read, so far...
%u unsinged integer
%[] a set of characters
------------------------------------
\n Makes a new line
------------------------------------
There ya go!