- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

A program to add 1 to a given number increments the value of the variable by 1 . This is general used in counters.

There are 2 methods to increase that can be used to increase a given number by 1 −

Simple adding of one to the number and reassigning it to the variable.

Using increment operator in the program.

This method takes the variable, add 1 to it and then reassigns its value.

#include <stdio.h> int main(void) { int n = 12; printf("The initial value of number n is %d \n", n); n = n+ 1; printf("The value after adding 1 to the number n is %d", n); return 0; }

The initial value of number n is 12 The value after adding 1 to the number n is 13

This method uses the increment operator to add 1 to the given number. This is a shorthand trick to add 1 to a number.

#include <stdio.h> int main(void) { int n = 12; printf("The initial value of number n is %d \n", n); n++; printf("The value after adding 1 to the number n is %d", n); return 0; }

The initial value of number n is 12 The value after adding 1 to the number n is 13

- Related Questions & Answers
- Add 1 to a number represented as linked list?
- Add 1 to a number represented as a linked list?
- Add 1 to number represented as array (Recursive Approach)?
- Reduce a number to 1 by performing given operations in C++
- Add 1 to the number represented as array (Recursive Approach)?
- Program to find number of bit 1 in the given number in Python
- How to find the missing number in a given Array from number 1 to n in Java?
- How to add +1 to existing MySQL values?
- How to add 1 day to a Date in iOS/iPhone?
- How to add a vector to a given Numpy array?
- Count number of bits changed after adding 1 to given N in C++
- Find all combinations that add upto given number using C++
- How add 1 day to Date in swift?
- Java program to add a given time to a particular date
- Java Program to generate custom random number -1 or 1

Advertisements