Example Arithmetic Operator used in “C” Program
#include<stdio.h>
main()
{
// This program will calculate the drawn salary of an employee
float salary = 5000.00, incentive = 1000, total_sal = 0, penalty = 0, drawn_sal = 0;
int month = 4, ua_leave = 2;
total_sal = (salary * month)+ incentive;
penalty = (salary / 30) * ua_leave;
drawn_sal = total_sal - penalty;
printf("Dear Employee, Your Monthly Salary is Rs %f. Your Incentive amount is Rs %f. Your Total Salary is Rs %f. But
You took un-authorized leave for %d days, So your penalty amount is Rs %f. Now your drawn salary for %d month is
Rs %f",salary,incentive,total_sal,ua_leave,penalty,month,drawn_sal);
}
/* Output will be
Dear Employee, Your Monthly Salary is Rs 5000.000000. Your Incentive amount is Rs 1000.000000. Your Total Salary
is Rs 21000.0 00000. But You took un-authorized leave for 2 days, So your penalty amount is Rs 333.333344. Now
your drawn salary for 4 month is Rs 20666.666016 .
How to use “dev C++” for “C” Program
Download Dev C++ → Right Click on it → Choose Run as administrator →Click Yes → Click Next → Click Next → Click
Finish. (Now Dev C++ is installed in your computer and a shortcut icon will be shown on the desktop)
How to save a program code for “C”
Double Click on the shortcut icon of “Dev C++” → Choose File Menu →New →Source File →type your programming
code → Go to File menu → choose save → Give a name to your program file →then click save as type dropdown
→choose “C Source Files”→ Click “Save”
How to compile & run a program code in “Dev C++”
Go to Execute menu → choose compile →correct the error in the program if it shows →again compile it →if there is
no error now → Click save button →Go to Execute menu →choose run.
Increment & Decrement Operator
The increment operator in “C” Program is represented by “++” sign and the decrement operator is
represented by “- -” sign. Increment operator increases the value of a variable by adding 1. Decrement operator
decreases the value of a variable by subtracting 1.
Example:
X = 5; here the value of x is 5
++x; here the value of x will be 6
Y = 8; here the value of Y is 8
--Y here the value of Y will be 7
Again if we write
--x here the value will be 5