hello2.c (#2)

  #include <stdio.h>

  int main()
  {
     int age;

     age = 23;
     printf("Hello world!\n");
     printf("My age is %d.\n", age);
     return 0;
  }
  • Here we assign 23 into the variable age.
  • Since age is of type int, you cannot assign a fraction, say 24.5, to it.
  • Remember that in C, the declaration of variables must be before any commands. So, you cannot say:
    printf("Hi!\n");
    int age;
  • In C++, this limitation has been lifted off.

 


Where to go

Chapter 2
News Page
Lesson 1 contents
Contacting Me


Roby Joehanes © 2001

Hosted by www.Geocities.ws

1