C# Programming - Operators - Discussion
Discussion Forum : Operators - General Questions (Q.No. 7)
7.
Which of the following is the correct output for the C#.NET code snippet given below?
Console.WriteLine(13 / 2 + " " + 13 % 2);
Discussion:
20 comments Page 2 of 2.
Kazeem mohammad said:
1 decade ago
13/2 = 6 as the operator " / " behavior depends on the operand type only(both the operands are of integer type so the return value of 13/2 is 6).
Same for 13%2 = 1. (both the operands are of integer type so the return value of 13%2 is 1).
Same for 13%2 = 1. (both the operands are of integer type so the return value of 13%2 is 1).
Viviek said:
1 decade ago
A/b always output the Quotient.
A%b always output the remainder.
A%b always output the remainder.
Rishabh Shrotriya said:
1 decade ago
Thanks Shivakant yadav thanks for explanation.
Ram said:
1 decade ago
13/2=6.5 Decimal value=6
13%2 remainder value=1
ans:61
13%2 remainder value=1
ans:61
Shivakant yadav said:
1 decade ago
(13 / 2 + " " + 13 % 2)
so 13/2=6.5 but decimal values are not allows only =6
and 13%2=1 this is returns remainder value.
so 13/2=6.5 but decimal values are not allows only =6
and 13%2=1 this is returns remainder value.
DEEPAK KUMAR said:
1 decade ago
Here the int is taken as datatype so decimal values are not allows
so 13/2 = 6
& " " means blank space
& 13% 2 = 1 bcz % is mode sign and returns reminder value
so 13/2 = 6
& " " means blank space
& 13% 2 = 1 bcz % is mode sign and returns reminder value
Arvind said:
1 decade ago
Yes it may be that int is by default data type in c#.
Shekar c said:
1 decade ago
Int is the default datatype so decimal value is neglected
answer : 6 1
answer : 6 1
Prashant said:
1 decade ago
Explain briefly.
Vishul said:
1 decade ago
6.5 and remainder is 1
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers