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 1 of 2.
S.Malathi said:
1 decade ago
13/2 the ans is quotient and 13%2 the ans is remainder.
Vishul said:
1 decade ago
6.5 and remainder is 1
Prashant said:
1 decade ago
Explain briefly.
Shekar c said:
1 decade ago
Int is the default datatype so decimal value is neglected
answer : 6 1
answer : 6 1
Arvind said:
1 decade ago
Yes it may be that int is by default data type in c#.
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
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.
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
Rishabh Shrotriya said:
1 decade ago
Thanks Shivakant yadav thanks for explanation.
Viviek said:
1 decade ago
A/b always output the Quotient.
A%b always output the remainder.
A%b always output the remainder.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers