TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
325k
Binary Arithmetic Operators
May 4 2012 7:18 PM
In C# 7/100 result is 0 (not 0.07). But in the following program in the equation (tax = saleAmount * 7/100;) 7/100 is realized as 0.07. Please explain the reason.
using System;
public class UseSevenPercentSalesTax
{
public static void Main()
{
double myPurchase = 12.99;
ComputeSevenPercentSalesTax(myPurchase);//variable argument
ComputeSevenPercentSalesTax(35.67);//constant argument
double num = 7 / 100;
Console.WriteLine("num = {0}", num);
Console.ReadKey();
}
public static void ComputeSevenPercentSalesTax(double saleAmount)
{//saleAmount - local variable
double tax;
tax = saleAmount * 7/100;
Console.WriteLine("The tax on {0} is {1}", saleAmount, tax.ToString("f"));
}
}
/*
The tax on 12.99 is 0.91
The tax on 35.67 is 2.50
num = 0
*/
Reply
Answers (
2
)
Why does DateTimePicker refuse to update its value?
How To Work with Auto Complete Search box can one suggest me.....