programming c language code example

Example 1: c programming language

// this is a single-line comment
/*
this is a multi-line comment!
*/

#include  // this library is included for i/o
#include  // this library is included for some handy functions

// This function will be ran when the program executes
int main() {
 
  printf("Hello, world!\n"); // this prints "Hello, world!" [line break]
  
  char* myString = "An awesome string!"; // declare string variable!
  printf("%s\n", myString); // print myString where %s is
  
  int myInt = 10;
  printf("%d\n", myInt); // print myInt where %d is
  
  double myDouble = 5.2; // declare double (decimal) variable!
  printf("%f\n", myDouble); // print myDouble where %f is
  
  return 0; // < exit out of the program
}

Example 2: c programming language

Do not want to be rude but I learnt this language and found out it has no class.
Prefer languages with class like C++, C#, Java, Python, etc.
Be classy.

Tags:

Misc Example