Variable and Comment in C

Variables are used to store different types of data, such as numbers and characters, in a program. Comments in C are used to provide explanations about the code, improving its readability. They can also be used to temporarily disable code when testing different parts of a program.

Variable

The name variable that is 'vari'+'able' means 'something can changeable'.C variable is a named location in a memory where a program can manipulate the data. This location is used to hold the value of the variable.C variable might be belonging to any of the data types like int, float, char,etc.

Syntax
int variable_Name;
char variable_name;
float Variable_name;
Example
#include<stdio.h>
main()
{
  int x=5;
  float y=12.0;
  char z="vikas";
  printf("%d",x);
  printf("%f",y);
  printf("%c",z);
  x=2;
  y=3.0;
  z="Small Code";
  char z="vikas";
  printf("%d",x);
  printf("%f",y);
  printf("%c",z);
}
Output
12.5
vikas
2
3.0
Small Code

Comment

The comment is a type of code that is compile and run but not shows any type of output in output screen.
it is divided into two type:-

  • Single line Comments.
  • Multiline Comments.

Single line Comments

It start with // and continue until the end of the line.

statement;
Example
#include<stdio.h>
main()
{
    int x=5;
    //char y[]="vikas";
    char z[]="SmallCode";
    printf("%d",x);
    //printf("%s",y);
    printf("%s",z);
}
Output
Small Code

Multiline Comments

It start with /* and continue until the end with */.

/*.................
....statement......
.................*/
Example
#include<stdio.h>
main()
{
    /*int x=5;
    char y[]="vikas";*/
    char z[]="SmallCode";
    /* printf("%d",x);
    printf("%c",y); */
    printf("%c",z);
}
Output
SmallCode