Unary Vs. Binary Operators in C with Example code

//Unary Vs. Binary Operators
// multiplication is a binary operator
//unary operators only needs one operand.

//Let’s make a C program to check this matter in more detail.

#include <stdio.h>
int main(void) {
int bank;
int expenditure;
int final;

bank=1000; //declare variable. we are ignoring pennies here!
final=bank-expenditure; // – is a binary operator here.

printf(“Final bank acccount is %d\n\n”, bank);
printf(“Expense is %d\n\n”, -expenditure); // – is acting like an unary operator
return 0;




Leave a Comment

Your email address will not be published. Required fields are marked *