233 views
0 votes
0 votes
#include <iostream>

using namespace std;

int main()
{
    float a,b,c;
    cout<<"Enter a=";
    cin>>a;
    b=a + (1-1);
    cout<<"a + (1-1)="<<b<<endl;
    c=(a+1)-1;
    cout<<" (a+1)-1="<<c;
    getchar();
    
}

Here is a is till 1E-7

c gives us a value .but after a= 1E-8

c gives us 0

can you explain how float data type is working here

Please log in or register to answer this question.

Related questions

511
views
3 answers
1 votes
shiva0 asked Apr 3, 2019
511 views
What is the output of the program? int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d", u.ch[0], u.ch[1], u.i); return 0; }
631
views
1 answers
1 votes
srestha asked Aug 8, 2018
631 views
#include <stdio.h> int main() { long int a = 0x7fffffff * 0x7fffffff; long int b = 0x7fffffff * 0x7fffffffl; printf("a = %ld, b = %ld\n", a, b); return 0; }What will be output if sizeof(int) is 4 and sizeof(long int) is 8.
1.4k
views
2 answers
3 votes
sid1221 asked Jul 25, 2017
1,443 views
#include<stdio.h> int main() { char c = 125; c = c+10; printf("%d", c); return 0; }what will be the output , explain with logic(size of char 1 byte)
428
views
1 answers
0 votes
radha gogia asked Aug 10, 2015
428 views
CASE A: CASE A: &#8234;#&lrm;include&#8236;<stdio.h> int divide( int a, b) { return 7; } int main() { int a=divide(8,3); printf("%d",a); return 0; }CASE B ... then why not in case A , why is the type of b not considered to be of type int ?