SHARE
TWEET

loops

a guest Sep 22nd, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //loops
  2.  
  3. //java
  4. /*
  5.     for (int counter=0;counter<5;counter+=1)
  6.     {
  7.         System.out.printLn(counter);
  8.     }
  9. */
  10.  
  11. for counter in 1...5
  12. {
  13.    // print (counter)
  14. }
  15.  
  16. //giving other names for our variables (later on clousers)
  17. typealias neven=Int
  18.  
  19. var names:[String] = ["Faiz","Ali","Jordan","Nick"]
  20. var userGrades:[String:neven] = ["Faiz":90,"Ali":95,"Jordan":98,"Nick":100]
  21.  
  22. //foreach
  23. //type I
  24. for nameItem in names {
  25.     print (nameItem)
  26. }
  27.  
  28. //type II
  29. for name in userGrades{
  30.     print ("student name:\(name.key)")
  31. }
  32. //type III
  33. for grade in userGrades.values{
  34.     print (grade)
  35. }
  36.  
  37. //type IV
  38. for idx in 90...100
  39. {
  40.     print (idx)
  41. }
  42.  
  43. //type V
  44. for _ in 1...5
  45. {
  46.     print ("Kapara");
  47. }
  48.  
  49. //while
  50. var x=0
  51. while (x<5){
  52.     print ("kapara on neo")
  53.     x += 1
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top