Write a C++ program to show the use of chain assignment.

Q6. Write a C++program to show the use of chain assignment.

Solution:

#include<iostream.h> //standard input/ouput header file

#include<conio.h> //for clrscr()

 

int main()

{

int a,b,c;

 

clrscr(); //to clear the screen

 

a=15;

b=20;

c=a=b; //chain assignment

 

cout<<“\n c=”<<c;

 

getch(); //holds the clear until any key is pressed

return 0; //makes the main() function

}

 

OUTPUT:

c=20

Leave a Reply

Your email address will not be published. Required fields are marked *