C Programming Tutorial - Math Operators




Hey Guys,

     In this article we are going to talk about math operators.

#include<stdio.h>

int main() {
   int weight = 596;
   printf("If I eat a watermelon I will weigh %d lbs \n", weight +-*/%{modulus is for remainder} 12); {Possible mathematical operations}
}

If I eat a watermelon I will weigh 8 lbs {Output for modulus}

int main() {
  int a = 86;
  int b = 21;
  printf("%d\n", a/b);
{this is for integer}

  
  float c =86.0;
  float d =21.0;
  printf ("%f\n", c/d);
}
{this is for float.}


The output is

4
4.095238

Comments