Author Topic: C Programming  (Read 1135 times)

Offline U1G

  • Member
  • Posts: 43
  • Karma: +0/-0
    • View Profile
  • iDevice: iPhone 3G
  • iDroid Version: MoJo 1.5.0
  • Jailbreak: Redsn0w 0.9.7b5
C Programming
« on: February 23, 2011, 07:54:05 PM »
So I decided to take up C programming under the recommendation of nickpack. I can do the basics, create const variables, do math with the varibles (+,*,-,+ etc.) I can set variable storage via char var[] etc. I can create if-else statements and else-if to. I can set it so that the input from the keyboard is converted to.. something using var=atoi(blah). I've been doing this for a few days now, I feel really confident in all this, it's easier than I expected it. But when I look at the source code for all this, D: I feel like a bigger noob.

Code: [Select]
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char num[2];
    int number;
   
    printf("I am your computer, I am a genie!\n");
   
    printf("Enter a number from 0 to 9:\n");
    gets(num);
    number=atoi(num);
   
    if(number<5)
    {
        printf("That number is less than 5!\n");
    }
    else if(number==5)
    {
        printf("You typed in 5!\n");
    }
    else
    {
        printf("That number is more than 5!\n");
    }
        printf("The genie knows all, he sees all!\n");       
        return(0);
}

Here's something basic I put together. Nothing special!