Activity Stream
48,167 MEMBERS
6989 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1.     
    #1
    Banned
    Website's:
    cityvillehelp.com

    Default Turbo C | Weird and amazing

    Why the output of the following program comes False

    PHP Code: 
    #include<stdio.h>
    void main()
    {
    int a=15b=10c=5;
    if(
    a>b>c)
    printf("True");
    else
    printf("False");


    plzz tell me ... help needed
    prateek Reviewed by prateek on . Turbo C | Weird and amazing Why the output of the following program comes False #include<stdio.h> void main() { int a=15, b=10, c=5; if(a>b>c) printf("True"); else printf("False"); Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    i don't know c but i don't think is possible to compare 3 values at once
    maybe a>b and a>c and b>c

  4.     
    #3
    Banned
    Website's:
    cityvillehelp.com
    i don't know c but i don't think is possible to compare 3 values at once
    maybe a>b and a>c and b>c
    oh but

    but when I write
    if(a>b>>c)
    the output becomes true ??

    whyy ??

  5.     
    #4
    Member
    Website's:
    mnchost.com
    Quote Originally Posted by prateek View Post
    Why the output of the following program comes False

    PHP Code: 
    #include<stdio.h>
    void main()
    {
    int a=15b=10c=5;
    if(
    a>b>c)
    printf("True");
    else
    printf("False");


    plzz tell me ... help needed

    because in below statement,the compiler(parser) see...
    a>b>c as ((a>b)>c)
    so ,if a=15,b=10,c=5
    a>b ==> true (returns 1)
    now 1 > 5 (c) ==> false

    Therefore , compiler returns false .The concept of left associativity .

  6.     
    #5
    Respected Member
    the whole concept of your program is wrong, how can you compare values without getting an input from an user and claim it as true or false ?
    If you get an input from an user, and ask for "true or false", that has some sense. If you get my point and agree with what i say, then this must be the program :

    Code: 
    #include<stdio.h> 
    void main() 
    { 
    int a,b,c; 
    scanf(%d %d %d, &a, &b, &c);
    if(a>b&&a>c)
    printf("True"); 
    else 
    printf("False"); 
    }
    If its "greatest of 3 numbers, then the program would be :

    Code: 
    #include<stdio.h> 
    void main() 
    { 
    int a,b,c; 
    scanf(%d %d %d, &a, &b, &c);
    if(a>b&&a>c)
    printf("A is Big"); 
    else 
    if(b>c)
    printf("B is Big"); 
    else
    printf("C is Big");
    }
    any doubts ? feel free to reply

  7.     
    #6
    Member
    Website's:
    mnchost.com
    Quote Originally Posted by prateek View Post
    oh but

    but when I write
    if(a>b>>c)
    the output becomes true ??

    whyy ??
    because ,

    again
    a>b ==> true (return 1)
    1>>5 ==> right shift "1" to five times
    return non-zero value and therefore any equality/operational expression is true by default..

  8.     
    #7
    Banned
    Website's:
    cityvillehelp.com
    Froomple

    actually my exam is next week
    i got some previous year questions and tried to solve them
    and found this question

    the question was what was the output of the program ..


    thanks to all of you epecially Techking
    rep added for all


    edit
    techking
    i can't give rep to u
    You must spread some Reputation around before giving it to Techking again.

  9.     
    #8
    Respected Member
    Quote Originally Posted by prateek View Post
    Froomple

    actually my exam is next week
    i got some previous year questions and tried to solve them
    and found this question

    the question was what was the output of the program ..


    thanks to all of you epecially Techking
    rep added for all
    can you type me the question please ?

  10.     
    #9
    Member
    Website's:
    mnchost.com
    We can do anything in C ?
    for more advanced interesting puzzles specially for microsoft/google interviews ,you can go with
    http://www.techmantr.in/c.php

  11.     
    #10
    Member
    Website's:
    mnchost.com
    PM me too..
    always welcome ..

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Md5 generation on Turbo C
    By prateek in forum Web Development Area
    Replies: 5
    Last Post: 14th Feb 2012, 08:42 PM
  2. Turbo C | scanf() | strange
    By prateek in forum Web Development Area
    Replies: 14
    Last Post: 14th Feb 2012, 04:24 PM
  3. Turbo C | Help Needed
    By prateek in forum Web Application/Script Support
    Replies: 17
    Last Post: 12th Jan 2012, 12:26 PM
  4. [Selling] YaSs3r37's GFX Shop Now Open | Amazing Service At Amazing Prices|
    By yasser37 in forum Completed Transactions
    Replies: 3
    Last Post: 1st Aug 2011, 03:06 PM
  5. Replies: 1
    Last Post: 29th Jul 2011, 09:20 PM

Tags for this Thread

BE SOCIAL