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

conditional operator

Discussion in 'C' started by cindrilla, Dec 2, 2010.

  1. cindrilla

    cindrilla New Member

    Joined:
    Sep 26, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    hyderabad
    hi firnds i hv some probs with using conditional operator
    my program is to find whether a candidate is elgible for voting or not

    first i had made my program as shown below


    #include<stdio.h>
    main()
    {
    printf("enter d age");
    scanf("%d",&a);
    (a>=18) ? printf("ur elgible"); : printf("ur inelgible");
    }


    but this is showing errors as expected ecpression before :
    &
    expected ':' before ';' token
    wht d hell is all this mean
    im using unix mint
     
  2. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
    Probably means remove the semicolon before the colon.

    Jim
     
  3. cindrilla

    cindrilla New Member

    Joined:
    Sep 26, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    hyderabad
    hey ur exact thnx
     

Share This Page