Cannot assign value to a constant variable : Constant « Data Type « C / ANSI-C






Cannot assign value to a constant variable

#include <stdio.h>

int main(void)
{
  const int i = 10;

  i = 20; /* this is wrong */

  printf("%d", i);

  return 0;
}


           
       








Related examples in the same category

1.Convert inches to yards, feet, and inches
2.Calculate a discounted priceCalculate a discounted price
3.Define a constant value