У нас вы можете посмотреть бесплатно PPS Experiment 5: c program to demonstrate the use of assignment operators and evaluate expressions или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
c program to demonstrate the use of assignment operators and evaluate expressions involving them
Subject: Programming for Problem solving Lab (24AF1000ES107L):
Experiment 5: Write a c program to demonstrate the use of assignment operators and
evaluate expressions involving them.
================================================
We use this type of operator to transform as well as assign the values to any variable in an operation.
In any given assignment operator, the right side is a value, and the left side is a variable.
int x = 33;
The value present on the right side of the operator must have the same data type as that of the variable present on the left side.
In any other case, the compiler raises an error.
Working Of Assignment Operators In C
Example Of Assignment Operators In C
Practice Problems On Assignment Operators In C
Types of Assignment Operators in C:
An assignment operator is basically a binary operator that helps in modifying the variable to its left with the use of the value to its right. We utilize the assignment operators to transform and assign values to any variables.
list of the assignment operators that you can find in the C language:
-------------------------------------
basic assignment ( = ) char grade = 'A';
subtraction assignment ( -= ) a = a - b; a-=b;
addition assignment ( += )
division assignment ( /= )
multiplication assignment ( *= )
modulo assignment ( %= )
bitwise XOR assignment ( ^= )
bitwise OR assignment ( |= )
bitwise AND assignment ( &= )
bitwise right shift assignment ( = )
bitwise left shift assignment ( = )
Working of Assignment Operators in C:
------------------------------------
all the Assignment operators that the C language supports:
Operator name Operator Description Equivalent of
basic assignment = p becomes equal to q N/A
Example p = q
addition assignment += addition of p and q becomes equal to p p = p + q
Example p += q
subtraction assignment -= subtraction of q from p becomes equal to p p = p – q Example p -= q
multiplication assignment *=
The product of p and q becomes equal to p p = p * q
Example p *= q
division assignment /=
The division of p by q becomes equal to p p = p / q
Example p /= q
modulo assignment %= The remainder of p divided by q becomes equal to p
p = p % q
Example p %= q
bitwise AND assignment &= The bitwise AND of p and q becomes equal to p
p = p & q
Example p &= q
bitwise OR assignment |= The bitwise OR of p and q becomes equal to p
p = p | q
Example p |= q
bitwise XOR assignment ^= The bitwise XOR of p and q becomes equal to p
p = p ^ q
Example p ^= q
bitwise left shift assignment = p left shifted by q becomes equal to p
p = p q
Example p = q
bitwise right shift assignment = p right shifted by q becomes equal to p
p = p q
Example p = q
Example of Assignment Operators in C
Let us see below an example to understand how assignment operator work in a C code:
#include stdio.h
#include conio.h
int main() {
int x = 21;
int y ;
y = x;
printf("Line 1 – = Example of the Value of y = %d
", y );
y -= x;
printf("Line 2 – -= Example of the Value of y = %d
", y );
y += x;
printf("Line 3 – += Example of the Value of c = %d
", y );
y /= x;
printf("Line 4 – /= Example of the Value of y = %d
", y );
y *= x;
printf("Line 5 – *= Example of the Value of y = %d
", y );
y = 2;
printf("Line 6 – = Example of the Value of y = %d
", y );
y = 200;
y %= x;
printf("Line 7 – %= Example of the Value of y = %d
", y );
y &= 2;
printf("Line 8 – &= Example of the Value of y = %d
", y );
y = 2;
printf("Line 9 – = Example of the Value of y = %d
", y );
y |= 2;
printf("Line 10 – |= Example of the Value of y = %d
", y );
y ^= 2;
printf("Line 11 – ^= Example of the Value of y = %d
", y );
getch();
return 0;
}
Line 1 = Example of the Value of y = 21
Line 2 -= Example of the Value of y = 0
Line 3 += Example of the Value of c = 21
Line 4 /= Example of the Value of y = 1
Line 5 *= Example of the Value of y = 21
Line 6 = Example of the Value of y = 84
Line 7 = Example of the Value of y = 11
Line 8 &= Example of the Value of y = 2
Line 9 = Example of the Value of y = 0
Line 10 |= Example of the Value of y = 2
Line 11 ^= Example of the Value of y = 0