Introduction
I have used Swift for windows 1.9 for debugging purpose. But you can use any Swift programming language compiler as per your availability.
Write a Swift program that accept 2 integer values and return true if one of them is 30 or if their sum is 30
Write a Swift program to rotate the elements of an array of integers to left direction
Write a Swift program to create a string made of two copies of the last two characters of a given string
Write a Swift program to return the first half of a given string of even length
Write a Swift program to insert a given string to another given string where the second string will be in the middle of the first string
Write a Swift program to draw a HTML string as bold or italic text
Write a Swift program to test if a given string starts with “test”
Write a Swift program to move the last two characters of a given string to the start string
All swift programs with an examples
Write a Swift program that accept two strings and return their concatenation, except the first char of each string
Write a Swift program to find the larger value of a given array of integers and set all the other elements with that value
Write a Swift program to test if an array of integers contains a 4 or a 8
Write a Swift program to check if a given array of integers contains 4 twice, or 8 twice
Write a Swift program to compute the sum of all the elements of a given array
Write a Swift program to find the largest number among three given integers
Write a Swift program to test whether the last digit of the two given integer values are same or not
Write a Swift program to convert the last three characters in upper case
Write a Swift program to test whether a value presents sequentially three times in an array of integers or not
Write a Swift program that accept 2 integer values and return true if one of them is 30 or if their sum is 30
Write a Swift program to compute the sum of the two integers
Write a Swift program to print ‘Hello World!’
I have used Swift for windows 1.9 for debugging purpose. But you can use any Swift programming language compiler as per your availability.
func countnumber(_ input: [Int]) -> Int {
var ctr = 0
for (index, number) in input.enumerated() {
let nextIndex = index + 1
if nextIndex < input.endIndex && number == 4 && (input[nextIndex] == 4 )
{
ctr += 1
}
}
return ctr
}
print(countnumber([4, 4, 2, 4, 4]))
print(countnumber([4, 4, 3]))
print(countnumber([4, 5, 2, 4]))
func countnumber(_ input: [Int]) -> Int {
var ctr = 0
for (index, number) in input.enumerated() {
let nextIndex = index + 1
if nextIndex < input.endIndex && number == 4 && (input[nextIndex] == 4 )
{
ctr += 1
}
}
return ctr
}
print(countnumber([4, 4, 2, 4, 4]))
print(countnumber([4, 4, 3]))
print(countnumber([4, 5, 2, 4]))
Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …
C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …