Saturday, 9 June 2018

Assignment Operator


Assignment operator में equal to (=) का use  किया जाता है |

a =5

b =6

a =b

printf ("%d ",a );

output : 6 

इसका मतलब b की value a के अंदर जाके assign हो जाती है |


Shorthand Assignment  Operator

इन्हे compound assignment  भी कहा जाता है |

Shorthand assignment Operator का use , C  language में  single variable  पे arithmetic operation  को short में लिखने के लिए किया जाता है |

जैसे :- arithmetic operation  को लिखने का तरीका इस प्रकार है :-

int a =20 ;

a =a +10  ;

यहाँ पर a =a +10  की जगह shorthand का use करके a +=10 ; भी लिख सकते हो |

इसी प्रकार सभी arithmetic operation  को आप shorthand assignment की तरह short में भी लिख सकते है |

जैसे :
a +=10
a -=10
a *=10
a /=10
a %=10
a &=10
a | =10
a ~ =10
a ^ =10
a >>=10
a <<=10


True /False 

1.  In an assignment statement a=b; which of the following statement is true?


A) The variable a and the variable b are same.
B) The value of variable a is assigned to variable b, and the value of variable b is assigned to variable a.
C) The value of b is assigned to variable a but if b changes later, it will effect the value of variable a.
D)The value of b is assigned to variable a but if b changes later, it will not effect the value of variable a.

2. 3 += 3; evaluates to 6. 




No comments:

Post a Comment

ch-12 File Handling

Mcq 1. What does fp point to in the program?   #include<stdio.h> int main() {   FILE *fp;   fp=fopen("trial",...