what is the difference between int &r and int& r
Answers were Sorted based on User's Feedback
Answer / nakubu
There is no difference; C++ is pretty much whitespace
agnostic. What depends is its use:
int function(int &r)
{
...
}
is a function declaration that accepts an integer pointer as
a parameter, and:
int a = 7;
int &r = a;
will make a reference to an integer.
The spacing around the & makes no difference.
Is This Answer Correct ? | 13 Yes | 0 No |
Answer / kumar sourav
according 2 me int &r is a declaration in which address of
r is of integer datatype whereas int& r is an alias or we
can say it a reference i.e we can put any other variable
instead of r.
Is This Answer Correct ? | 6 Yes | 6 No |
Answer / shiv
according to me int &r is declaration , and int& r is
reference .
Is This Answer Correct ? | 2 Yes | 6 No |
Seat Reservation prog for the theatre. Write a function for seat allocation for the movie tickets. Total no of seats available are 200. 20 in each row. Each row is referred by the Character, "A" for the first row and 'J' for the last. And each seat in a row is represented by the no. 1-20. So seat in diffrent rows would be represented as A1,A2....;B1,B2.....;........J1,J2... Each cell in the table represent either 0 or 1. 0 rep would seat is available , 1 would represent seat is reserved. Booking should start from the last row (J) to the first row(A). At the max 20 seats can be booked at a time. if seats are available, then print all the seat nos like "B2" i.e (2 row, 3 col) otherwise Print "Seats are not available." and we must book consecutive seats only.
A research student is given a singly-linked list. Each node of the list has a color, which is either “Black” or “White”. He must find if there are more black nodes than white nodes, or vice versa. His advisor gives him 5,000Rs to buy a computer to do the work. He goes to the computer store and finds a slightly defective computer which costs a mere 3,000Rs. This computer has the small problem of not being able to do arithmetic. This means that he cannot use a counter to count the nodes in the list to determine the majority color. The computer is otherwise fully functional. He has the evil idea that he could buy the defective computer and somehow use it to do his work, so that he can use the rest of the money on enjoyment. Show how he can accomplish this amazing task. Write code for an algorithm called ‘findMajorityColor’ which takes a singly-linked list, L, with n nodes and returns the majority color among nodes of L. This algorithm should have the same asymptotic running time as counting the nodes (O(n)). Note: No arithmetic is allowed.
Hello, I am trying to write a program in c++ which accepts month and year from the user and prints the calender. So please tell me the algorithm and what is the calender logic.
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
3 Answers TCS, Vimukti Technologies, Wipro,
write a program that reads a series of strings and prints only those strings begging with letter "b"
What will be the output- for(i=1;i<=3;i++) { printf("%d",i); continue; i++; }
Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.
1.program to add any two objects using operator overloading 2.program to add any two objects using constructors 3.program to add any two objects using binary operator 4.program to add any two objects using unary operator
write a program that can locate elements in array.
Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).
We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character