1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C pgm to find the number entered is int or float???

Discussion in 'C' started by nim, Sep 25, 2009.

  1. nim

    nim New Member

    Joined:
    Sep 25, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    Please help me with C code to find the number entered is integer or float?????

    Thanks in advence.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    First of all have you decided how to determine whether a number is integer or float? If you haven't done this yet then you won't be able to write a program to do it.
    If you've decided that, have you started yet? What code do you have? Does it work? If not, what does it do wrong? What input did you give and what output did you get?
     
  3. mrvool

    mrvool New Member

    Joined:
    Aug 18, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi Dear,
    Please try this code easy and simple....

    Code:
    #include <stdio.h>
    #include <conio.h>
    void main()
    {
    float f;
    int i;
    printf("Enter a number : ");
    scanf("%f",&f);
    i=f;
    if(i==f)
        printf("\nYou have Enterd an Intiger number");
    else
        printf("\nYou have Enterd a float number");
    getch();
    }
    
     
    Last edited by a moderator: Aug 18, 2012

Share This Page