Thread: HW

  1. #1
    Registered User
    Join Date
    Apr 2020
    Posts
    8

    HW

    What does the following code displays? Assume string s1 is initialized to “dart” and string s2 is initialized to “Dart” . Assume complete program. I think it displays either 0,1,4 or 5
    Code:
    int i = 0;
    Code:
    while (s1 [i] = = s2[i] )
    {
                i++;
    }
    printf(“%d “, i)
    

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Yes, I think 0,1,4, and 5 includes the correct answer.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    Why don't you compile it and see?

    Actually it won't display anything at all because the use of "smart" quotes and a missing semicolon means that it won't compile.

Popular pages Recent additions subscribe to a feed

Tags for this Thread