EXAMPLE OF BASIC CODING IN C PROGRAMING

Some basic examples in the C programming language.

These examples cover some fundamental concepts:

Hello World:

#include<stdio.h> 

int main()

{

 printf(“Hello, World!\n”);

 return 0;

}

 

Variables and Data Types:

#include <stdio.h>

 

int main()

{

  // Variables

  int age = 25;

  float height = 1.75;

  char gender = 'M';

  

  // Data Types

  double weight = 68.5;

}

   

Conditional Statements (if-else):

#include <stdio.h>

  

int main()

{

  // Conditional Statement

  int temperature = 20;

  if (temperature > 30) {

  printf("It's a hot day.\n");

}

  else if (temperature > 20)

{

  printf(“It's a nice day.\n”);

}

  else

{

  printf(“It's a bit chilly.\n”);

}  

  return 0;

}