Skip to main content

Posts

Showing posts from February, 2018

Why we are not use “&” with cin in C++ language but use with scanf() in C language?

Why we are not use “&” with cin in C++ but use with scanf() in C? by Ayush garg Prerequisite for batter understanding – 1. basic in knowledge of polymorphism a concept of object oriented programming . 2.Basic knowledge of function  . When C programmer start studying C++ one doubt always ring in his mind why “&” not used with cin in C++ but use with in scanf() in C? In C++ program write as int a; cin>>a; C++ is the object oriented programming language and   cin is an object. Here concept of operator overloading is used. In C “>>” is called right shift bitwise operator. Here “>>” is overloaded.   When object file create   cin>>a;   Is internally converted into cin.operator>>(a) It means it is a function call. cin.operator>>(a) is function call so its definition must be present somewhere in class form which cin object belong. In C++ there are three type of function call:- 1...

What actually happen when programmer write scanf (“%d”,i) instead of scanf(“%d”,&i) in C language?

what actually happen when C programmer write scanf("%d",i) instead of scanf("%d",&i)?                                       -by Ayush garg Prerequisite for batter understanding- 1     please read why "&" is use with scanf() in C language? Some time programmer made a mistake and instead writing following code //Program 1 void main() {           int I;           scanf(“%d”,&i);           printf(“The value of i=%d”,i); } Programmer   write //program 2 void main() {           int I;           scanf(“%d”,i);           printf(“The value of i=%d”,i); } ...

Why “&” used with scanf() in C language?

Why “&” used with scanf() in C?                                                     -by Ayush garg Prerequisite for the batter understanding- 1. Basic knowledge of the pointer. 2. Basic knowledge of the function. When beginner start studying C one doubt always in his mind. Why “&” is used with scanf() in C. In C “&” called address of operator. When   “&” used with variable it always return the address of that variable and we know that when any variable declare in the program and when program run a memory allocated to it in   RAM. This allocated memory always has some address. In C we have two type of function call:- 1.     Call by value. 2.     Call by reference. Call by value- In call by value the value inside the variable is passed. By using call by value we are not ab...