VR Indian Wanderers Youtube RSS Feed
Learn with Vikas Suhag
Program to demonstrate working of unary increment and decrement operators in C Language
Nov 26, 2021   Vikas Suhag

unary increment and decrement operators in C Language

// program to demonstrate working of unary increment  and decrement operators
#include <stdio.h>
void main()
{
    int a = 1;
    printf("a value: %d",a); // 1
    int b = a++;  // post increment
    printf("b value after a++ : %d",b); // b=1
    printf("a value after a++ : %d",a); //a=2
    a = 1;
    printf("a value:%d",a);
    b = ++a;  // pre-increment
    printf("b value after ++a : %d",b); //b=2
    printf("a value after ++a : %d",a); //a=2
    
    a = 5;
    printf("a value before decrement: %d",a);
    b = a--;  // post
    printf("b value after a-- : %d",b); // b=5
    printf("a value after a-- : %d",a); // a=4
    a = 5;
    printf("a value: %d",a);
    b = --a;  // pre - decrement
    printf("b value after --a : %d", b);  // b=4
    printf("a value after --a : %d",a); // a=4
    
}


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Youtube RSS Feed
© 2024 Learn with Vikas Suhag. All Rights Reserved.