Tyyppimuunnosten Harjoittelu
Tallenna arvo number muuttujiin n1 ja n2. Käytä eksplisiittistä tyyppimuunnosta tarvittaessa.
main.cs
1234567891011121314151617181920using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = ___; double n2 = ___; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }
Käytä tyyppimuunnosta vain long-muuttujassa.
main.cs
1234567891011121314151617181920using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = (long) number; double n2 = number; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 12
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
What data type should the variable `number` be?
Can you show an example of how to use type casting for the `long` variable?
Should I assign the same value to both `n1` and `n2`?
Awesome!
Completion rate improved to 1.59
Tyyppimuunnosten Harjoittelu
Pyyhkäise näyttääksesi valikon
Tallenna arvo number muuttujiin n1 ja n2. Käytä eksplisiittistä tyyppimuunnosta tarvittaessa.
main.cs
1234567891011121314151617181920using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = ___; double n2 = ___; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }
Käytä tyyppimuunnosta vain long-muuttujassa.
main.cs
1234567891011121314151617181920using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = (long) number; double n2 = number; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 12