Invitation to Attend “Connect, Simulate and Innovate using Arduino on Cloud”, an awareness programme
If you are not an organiser or invigilator of the Subscribed college, please register using this Google form
How to solve the expression (a/b)+(c/d) using typecasting in c
#include <iostream>using namespace std;int main() { int a, b, c, d; cout<<"Enter a and b: "; cin>>a>>b; cout<<"Enter c and d: "; cin>>c>>d; float ans = (a/b)+(c/d); cout<<"Answer(without typecast) = "<<ans<<"\n"; ans = ((float)a/b)+((float)c/d); cout<<"Answer(with typecast) = "<<ans<<"\n"; return 0;}Why the output is in 'int' type but not 'float' type?But the same program in C came with output of 'float' type.
In assignment question, i can understand typecasting of given expression but what is the meaning of real division in type casting?
589 visits
Outline:ଇନକ୍ରିମେଣ୍ଟ ଓ ଡିକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଇନକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଉଦାହରଣ: ++ -ପୋଷ୍ଟଫିକ୍ସ ଇନକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: a++ -ପ୍ରିଫିକ୍ସ ଇନକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: ++a -ଡିକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଉଦାହରଣ: -- -ପୋଷ୍ଟଫିକ୍ସ ଡିକ୍ରିମେଣ୍ଟ --ଉଦାହରଣ: a-- -ପ୍ରିଫିକ୍ସ ଡିକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: --a -ଟାଇପକାଷ୍ଟିଙ୍ଗ -ଏରର୍ସ
ଇନକ୍ରିମେଣ୍ଟ ଓ ଡିକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଇନକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଉଦାହରଣ: ++ -ପୋଷ୍ଟଫିକ୍ସ ଇନକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: a++ -ପ୍ରିଫିକ୍ସ ଇନକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: ++a -ଡିକ୍ରିମେଣ୍ଟ ଅପରେଟର୍ସ -ଉଦାହରଣ: -- -ପୋଷ୍ଟଫିକ୍ସ ଡିକ୍ରିମେଣ୍ଟ --ଉଦାହରଣ: a-- -ପ୍ରିଫିକ୍ସ ଡିକ୍ରିମେଣ୍ଟ -ଉଦାହରଣ: --a -ଟାଇପକାଷ୍ଟିଙ୍ଗ -ଏରର୍ସ
Show video info
Pre-requisite