Assignment Operator in C17 Mar 2025 | 4 min read There are different kinds of the operators, such as arithmetic, relational, bitwise, assignment, etc., in the C programming language. The assignment operator is used to assign the value, variable and function to another variable. Let's discuss the various types of the assignment operators such as =, +=, -=, /=, *= and %=. Example of the Assignment Operators: ![]() Simple Assignment Operator (=):It is the operator used to assign the right side operand or variable to the left side variable. Syntax Let's create a program to use the simple assignment operator in C. Program1.c Output The value of n1: 5 The value of n2: 5 The value of c: 10 The value of x: 15 Plus and Assign Operator (+=):The operator is used to add the left side operand to the left operand and then assign results to the left operand. Syntax Let's create a program to use the Plus and assign operator in C. Program2.c Output The value of a: 5 The value of b: 15 Subtract and Assign Operator (-=):The operator is used to subtract the left operand with the right operand and then assigns the result to the left operand. Syntax Let's create a program to use the Subtract and Assign (-=) operator in C. Program3.c Output The value of n1: 5 The value of n2: 5 Multiply and Assign Operator (*=)The operator is used to multiply the left operand with the right operand and then assign result to the left operand. Syntax Let's create a program to use the multiply and assign operator (*=) in C. Program4.c Output The value of n1: 5 The value of n2: 50 Divide and Assign Operator (/=):An operator is used between the left and right operands, which divides the first number by the second number to return the result in the left operand. Syntax Let's create a program to use the divide and assign operator (/=) in C. Program5.c Output The value of n1: 5 The value of n2: 2 Modulus and Assign Operator (%=):An operator used between the left operand and the right operand divides the first number (n1) by the second number (n2) and returns the remainder in the left operand. Syntax Let's create a program to use the divide and assign operator (%=) in C. Program6.c Output Enter the value of n1: 23 Enter the value of n2: 5 The modulus value of n2: 3 |
In this article, we will discuss the kbhit() function in C with its example, advantages, and disadvantages. kbhit() function does not exist in the C standard library. Although, it is frequently used on Windows systems to check whether a keyboard key has been depressed. You can use...
6 min read
The "realloc" is a standard library function in C that is used to resize dynamically allocated memory blocks. The function takes two arguments: a pointer to a iously allocated memory block and the new size to which the memory block needs to be resized. The function works...
7 min read
In this tutorial, we will learn what a buffer is and how to clear the input buffer in both C and C++. What exactly is a Buffer? A buffer is a type of temporary storage. Every standard input and output device have an input and output buffer. In...
3 min read
Digits are a fundamental part of programming languages, as they are used to represent numerical values. These values can be used in a variety of ways, such as performing mathematical operations, controlling the flow of a program, or storing data. In programming languages, digits are typically...
4 min read
In this article, we will discuss the reentrant function in C with its properties and examples. If there is a way to stop a function from running in the middle of it, handle the interrupt service routine, and then restart the earlier running function without impairing it,...
3 min read
This section will discuss the isalpha() function of the C programming language. The islpha() function is a predefined library function of the ctype.h header file that takes an argument as the character type and validates for valid alphabets. If the given character is alphabets (a -...
5 min read
In C programming language, parameters are variables that are used to pass values or references between functions. There are two types of parameters: actual and formal parameters. In this article, we will discuss the difference between actual and formal parameters in C, how they work, and...
6 min read
In this article, we will discuss the with its syntax, example, advantages, and disadvantages. The C programming language has the getopt() function to process command-line parameters. It enables simple command-line options and argument handling for C programs. The getopt() method streamlines the process of parsing command-line options...
9 min read
In an Array, the Peak element is the element that is not smaller than its neighbors. It is one of the frequently asked questions in interviews. It is simple. This tutorial shows different approaches we can follow to solve the question efficiently. Example: Suppose, in the Array [10,...
4 min read
C Program to generate In this program, we are getting input from the user for the limit for fibonacci triangle, and printing the fibonacci series for the given number of times (limit). Let's see the c example to generate fibonacci triangle. Example #include<stdio.h> #include<stdlib.h> int main(){ ...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India