
harwind
Data Type Mismatch Error in C++ Code: Rectification Needed
I need help with a data type-related problem in my C++ code. I’ve tried a few different approaches and have read various sites like Scaler, but I haven’t had any luck. This is a sample of the code that causes issues:
#include <iostream>
int main() {
float totalAmount;
int discountPercentage;
std::cout << "Enter total amount: ";
std::cin >> totalAmount;
std::cout << "Enter discount percentage: ";
std::cin >> discountPercentage;
float discountedAmount = totalAmount - (totalAmount * discountPercentage / 100);
std::cout << "Discounted Amount: " << discountedAmount << std::endl;
return 0;
}
Despite seemingly correct logic, the code is producing unexpected results. The discount calculation appears to be incorrect. What data type-related error might be causing this issue, and how can I rectify it to ensure accurate discount calculations?
Most Liked

Eiji
I have tried to enter some data and all seems good. Is there anything specific you found? Could you please let us know what’s your input, output and expected result?
1
Popular General Dev topics

Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New

Which screen resolutions do you frequently use?
Note: not the resolution the display is capable of mind, but the resolution you’re using...
New

Figured this would be a cool topic and maybe provide some inspiration for those who are just starting to work from home. Feel free to sha...
New

Inspired by this thread about arcade games - which I initially misread as favorite arcade game soundtracks - I wanted to ask about your f...
New

Thought it might be worth having a dedicated thread for standing desk treadmills (for those interested, here’s our general thread on stan...
New

So, if we can reduce the likelihood, we can reduce the overall risk. That’s good. It’s actually very similar to a very common idea called...
New

TLDR
Hacking 30 Mobile Apps and their APIs with consent of some of the major providers in the area.
100% success rate in hacking the AP...
New

In their weekly newsletter, Jared Santo from the Changelog shared this blog post by Mark Ericksen over at fly.io:
What is really inter...
New

A modern streaming platform for mission critical workloads
Redpanda is a Kafka® compatible event streaming platform. No Zookeeper®, no JV...
New

My brother got a VPS on https://contabo.com hosting provider, but I was not aware of them, and when my brother told me the price and spec...
New
Other popular topics

I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl:
The Ser...
New

This looks like a stunning keycap set :orange_heart:
A LEGENDARY KEYBOARD LIVES ON
When you bought an Apple Macintosh computer in the e...
New

Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New

We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New

Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New

Author Spotlight:
Karl Stolley
@karlstolley
Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New

Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New

Hair Salon Games for Girls Fun
Girls Hair Saloon game is mainly developed for kids. This game allows users to select virtual avatars to ...
New

Background
Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New
Categories:
Sub Categories:
- All
- In The News (10282)
- Dev Chat
- Questions (33)
- Resources (119)
- Blogs/Talks (26)
- Jobs (3)
- Events (15)
- Code Editors (58)
- Hardware (57)
- Reviews (5)
- Sales (16)
- Design & UX (5)
- Marketing & SEO (2)
- Industry & Culture (14)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (4)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /typescript
- /svelte
- /crystal
- /kotlin
- /c-plus-plus
- /tailwind
- /gleam
- /react
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /textmate
- /lisp
- /nixos
- /debian
- /react-native
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /ubuntu
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /julia
- /c
- /slackware
- /neovim