# '==' : value equality-two objects have the same value # is : reference equality- two references refer to the same object a=[ 1 , 2 , 3 ] b=a #two references refer to the same object(b is not the copy of a) print (b==a) print (b is a) c=a[:] #two references refer to the two different object(now c is the copy of a) print (c==a) print (c is a)
//different methods to take a string from user #include <stdio.h> int main () { char str1 [ 10 ]; printf ( "enter a string:" ); gets ( str1 ); //method 1: using gets function printf ( " %s \n " , str1 ); char str2 [ 10 ]; printf ( "enter a string:" ); scanf ( " %s " ,& str2 ); //method 2:using scanf, but with this we cannot use white spaces in string printf ( " %s \n " , str2 ); printf ( "using puts displaying string output \n " ); puts ( str2 ); //puts function is used to display string output return 0 ; }
Comments
Post a Comment