Pages

Wednesday, January 1, 2025

C- Operator and their uses with examples

C- Operator and their uses with examples



1. Unary Operator
a) num-- means decrement of 5 to 4 as an example! :)

// Online C compiler to run C program online
#include <stdio.h>

int main() {
   int num = 5;
   
   printf("The value of 5 before decrement is:- %d", num);
   printf("\nThe value of 5 using decrement is:- %d", num--);
   printf("\nThe value of 5 after decrement is:- %d", num);
   
    return 0;
}

OUTPUT:-
The value of 5 before decrement is:- 5
The value of 5 using decrement is:- 5
The value of 5 after decrement is:- 4

=== Code Execution Successful ===

b) num++ is the vice-e-versa of num--
// Online C compiler to run C program online
#include <stdio.h>

int main() {
   int num = 5;
   
   printf("The value of 5 before decrement is:- %d", num);
   printf("\nThe value of 5 using decrement is:- %d", num++);
   printf("\nThe value of 5 after decrement is:- %d", num);
   
    return 0;
}


OUTPUT :-
The value of 5 before decrement is:- 5
The value of 5 using decrement is:- 5
The value of 5 after decrement is:- 6

=== Code Execution Successful ===

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...