Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

write 1 random programm on "dart language"

  1. User

    write 1 random programm on "dart language"

  2. Assistant

    Here is a random program written in Dart language:

    void main() {
      List<String> fruits = ["apple", "banana", "grape", "orange", "pear"];
    
      for (var fruit in fruits) {
        print("I love to eat $fruit!");
      }
    }
    

    This program creates a list of fruits, then iterates through them using a for loop and prints a message for each fruit. The output would be:

    I love to eat apple!
    I love to eat banana!
    I love to eat grape!
    I love to eat orange!
    I love to eat pear!
    
  3. User

    write random programm on “dart language”

  4. Assistant

    Here is another random program written in Dart language:

    void main() {
      int num = 5;
    
      if (num % 2 == 0) {
        print("$num is even");
      } else {
        print("$num is odd");
      }
    }
    

    This program initializes a variable num with a value of 5. It then checks if num is even or odd using the modulo operator (%). If num is even, it prints a message stating that it's even. If num is odd, it prints a message stating that it's odd. The output would be:

    5 is odd