SlideShare a Scribd company logo
Practice problems on functions
1. Write a Swift program to compute the sum of the two integers. If the values are equal return the
triple their sum.
2. Write a Swift program to compute and return the absolute difference of n and 51, if n is over 51
return double the absolute difference
3. Write a Swift program that accept two integer values and return true if one of them is 20 or if
their sum is 20.
4. Write a Swift program to accept two integer values and return true if one is negative and one is
positive. Return true only if both are negative.
5. Write a Swift program to add "Is" to the front of a given string. However, if the string already
begins with "Is", return the given string.
6. Write a Swift program to remove a character at specified index of a given non-empty string. The
value of the specified index will be in the range 0..str.length()-1 inclusive
7. Write a Swift program to change the first and last character of a given string.
8. Write a Swift program to add the last character (given string) at the front and back of a given
string. The length of the given string must be 1 or more.
9. Write a Swift program to check if a given non-negative number is a multiple of 3 or a multiple of 5.
10. Write a Swift program to take the first two characters from a given string and create a new string
with the two characters added at both the front and back.
11. Write a Swift program to test a given string whether it starts with "Is". Return true or false.
12. Write a Swift program that return true if either of two given integers is in the range 10..30
inclusive.
13. Write a Swift program to check if a given string begins with "fix", except the 'f' can be any
character or number.
14. Write a Swift program to find the largest number among three given integers.
15. Write a Swift program that accept two integer values and to test which value is nearest to the
value 10, or return 0 if both integers have same distance from 10.
16. Write a Swift program that accept two integer values and test if they are both in the range 20..30
inclusive, or they are both in the range 30..40 inclusive.
17. Write a Swift program that accept two positive integer values and test whether the larger value
is in the range 20..30 inclusive, or return 0 if neither is in that range.
18. Write a Swift program to test whether the last digit of the two given non-negative integer values
are same or not.
19. Write a Swift program to convert the last three characters in upper case. If the string has less
than 3 chars, lowercase whatever is there.
20. Write a Swift program to check if the first instance of "a" in a given string is immediately
followed by another "a".
21. Write a Swift program to create a string made of every other char starting with the first from a
given string. So "Python" will return "Pto"
22. Write a Swift program to count the number of 7's in a given array of integers.
23. Write a Swift program to check if one of the first 4 elements in a given array of integers is a 7.
The length of the array may be less than 4.
24. Write a Swift program to test if the sequence of numbers 0, 1, 2 appears in a given array of
integers somewhere.
25. Write a Swift program to create a new string where all the character "a" have been removed
except the first and last positions.
26. Write a Swift program to create a string taking characters at indexes 0, 2, 4, 6, 8, .. from a given
string
27. Write a Swift program to count the number of times that two 7's are next to each other in a
given array of integers.
28. Write a Swift program to test whether a value presents sequentially three times in an array of
integers or not.
Ad

More Related Content

What's hot (20)

Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and LinkerdService Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Kai Wähner
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
Jeff Holoman
 
Apache Kafka Streams + Machine Learning / Deep Learning
Apache Kafka Streams + Machine Learning / Deep LearningApache Kafka Streams + Machine Learning / Deep Learning
Apache Kafka Streams + Machine Learning / Deep Learning
Kai Wähner
 
A Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
A Modern C++ Kafka API | Kenneth Jia, Morgan StanleyA Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
A Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
HostedbyConfluent
 
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
HostedbyConfluent
 
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
End to end Machine Learning using Kubeflow - Build, Train, Deploy and ManageEnd to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
UC4 SCHEDULING
UC4 SCHEDULINGUC4 SCHEDULING
UC4 SCHEDULING
roelspi
 
Pulsar - Distributed pub/sub platform
Pulsar - Distributed pub/sub platformPulsar - Distributed pub/sub platform
Pulsar - Distributed pub/sub platform
Matteo Merli
 
Inside open metadata—the deep dive
Inside open metadata—the deep diveInside open metadata—the deep dive
Inside open metadata—the deep dive
DataWorks Summit
 
What’s New with Databricks Machine Learning
What’s New with Databricks Machine LearningWhat’s New with Databricks Machine Learning
What’s New with Databricks Machine Learning
Databricks
 
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
HostedbyConfluent
 
webMethods 10.5 and webMethods.io Integration: Everything You Must Know
webMethods 10.5 and webMethods.io Integration: Everything You Must KnowwebMethods 10.5 and webMethods.io Integration: Everything You Must Know
webMethods 10.5 and webMethods.io Integration: Everything You Must Know
Kellton Tech Solutions Ltd
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
Amita Mirajkar
 
北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用
Lorex L. Yang
 
Scaling DevOps of Microservices at Uber (Code Conf 2018)
Scaling DevOps of Microservices at Uber (Code Conf 2018)Scaling DevOps of Microservices at Uber (Code Conf 2018)
Scaling DevOps of Microservices at Uber (Code Conf 2018)
Kiran Bondalapati
 
Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?
confluent
 
웹서버 부하테스트 실전 노하우
웹서버 부하테스트 실전 노하우웹서버 부하테스트 실전 노하우
웹서버 부하테스트 실전 노하우
IMQA
 
Logs, metrics and real time data analytics
Logs, metrics and real time data analyticsLogs, metrics and real time data analytics
Logs, metrics and real time data analytics
Ewere Diagboya
 
[FFE19] Build a Flink AI Ecosystem
[FFE19] Build a Flink AI Ecosystem[FFE19] Build a Flink AI Ecosystem
[FFE19] Build a Flink AI Ecosystem
Jiangjie Qin
 
Building Bots Using IBM Watson
Building Bots Using IBM WatsonBuilding Bots Using IBM Watson
Building Bots Using IBM Watson
Entrepreneur / Startup
 
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and LinkerdService Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Service Mesh with Apache Kafka, Kubernetes, Envoy, Istio and Linkerd
Kai Wähner
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
Jeff Holoman
 
Apache Kafka Streams + Machine Learning / Deep Learning
Apache Kafka Streams + Machine Learning / Deep LearningApache Kafka Streams + Machine Learning / Deep Learning
Apache Kafka Streams + Machine Learning / Deep Learning
Kai Wähner
 
A Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
A Modern C++ Kafka API | Kenneth Jia, Morgan StanleyA Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
A Modern C++ Kafka API | Kenneth Jia, Morgan Stanley
HostedbyConfluent
 
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
HostedbyConfluent
 
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
End to end Machine Learning using Kubeflow - Build, Train, Deploy and ManageEnd to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
UC4 SCHEDULING
UC4 SCHEDULINGUC4 SCHEDULING
UC4 SCHEDULING
roelspi
 
Pulsar - Distributed pub/sub platform
Pulsar - Distributed pub/sub platformPulsar - Distributed pub/sub platform
Pulsar - Distributed pub/sub platform
Matteo Merli
 
Inside open metadata—the deep dive
Inside open metadata—the deep diveInside open metadata—the deep dive
Inside open metadata—the deep dive
DataWorks Summit
 
What’s New with Databricks Machine Learning
What’s New with Databricks Machine LearningWhat’s New with Databricks Machine Learning
What’s New with Databricks Machine Learning
Databricks
 
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
Exactly-Once Semantics Revisited: Distributed Transactions across Flink and K...
HostedbyConfluent
 
webMethods 10.5 and webMethods.io Integration: Everything You Must Know
webMethods 10.5 and webMethods.io Integration: Everything You Must KnowwebMethods 10.5 and webMethods.io Integration: Everything You Must Know
webMethods 10.5 and webMethods.io Integration: Everything You Must Know
Kellton Tech Solutions Ltd
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
Amita Mirajkar
 
北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用北護大/FHIR 開發簡介與應用
北護大/FHIR 開發簡介與應用
Lorex L. Yang
 
Scaling DevOps of Microservices at Uber (Code Conf 2018)
Scaling DevOps of Microservices at Uber (Code Conf 2018)Scaling DevOps of Microservices at Uber (Code Conf 2018)
Scaling DevOps of Microservices at Uber (Code Conf 2018)
Kiran Bondalapati
 
Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?
confluent
 
웹서버 부하테스트 실전 노하우
웹서버 부하테스트 실전 노하우웹서버 부하테스트 실전 노하우
웹서버 부하테스트 실전 노하우
IMQA
 
Logs, metrics and real time data analytics
Logs, metrics and real time data analyticsLogs, metrics and real time data analytics
Logs, metrics and real time data analytics
Ewere Diagboya
 
[FFE19] Build a Flink AI Ecosystem
[FFE19] Build a Flink AI Ecosystem[FFE19] Build a Flink AI Ecosystem
[FFE19] Build a Flink AI Ecosystem
Jiangjie Qin
 

Similar to practice problems on functions IN SWIFT (20)

practice problems on array IN SWIFT
practice problems on array IN SWIFTpractice problems on array IN SWIFT
practice problems on array IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
practice problems on array IN SWIFT
practice problems on array IN SWIFTpractice problems on array IN SWIFT
practice problems on array IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
practice problems on array IN SWIFT
practice problems on array  IN SWIFTpractice problems on array  IN SWIFT
practice problems on array IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)
IIUM
 
Java programlist (1)
Java programlist (1)Java programlist (1)
Java programlist (1)
Aditya Aggarwal
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4
ANILBIKAS
 
Programming qns
Programming qnsProgramming qns
Programming qns
Dr.Subha Krishna
 
If switch structure
If switch structureIf switch structure
If switch structure
M Sagheer Malik
 
A10
A10A10
A10
lksoo
 
PYTHON PROGRAMS
PYTHON PROGRAMSPYTHON PROGRAMS
PYTHON PROGRAMS
Alvino rock
 
Master Python in 15 Days.pdf
Master Python in 15 Days.pdfMaster Python in 15 Days.pdf
Master Python in 15 Days.pdf
JorgeTorres560505
 
C code examples
C code examplesC code examples
C code examples
Industrial Electric, Electronic Ind. And Trade Co. Ltd.
 
C programming part4
C programming part4C programming part4
C programming part4
Keroles karam khalil
 
C programming part4
C programming part4C programming part4
C programming part4
Keroles karam khalil
 
Practical java
Practical javaPractical java
Practical java
nirmit
 
1
11
1
Manjunath Naik
 
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
Mark Simon
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
Rishabh-Rawat
 
Java Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdfJava Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdf
ROWELL MARQUINA
 
C_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docx
Pandiya Rajan
 
Ad

More from LOVELY PROFESSIONAL UNIVERSITY (16)

Enumerations, structure and class IN SWIFT
Enumerations, structure and class IN SWIFTEnumerations, structure and class IN SWIFT
Enumerations, structure and class IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Dictionaries IN SWIFT
Dictionaries IN SWIFTDictionaries IN SWIFT
Dictionaries IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Control structures IN SWIFT
Control structures IN SWIFTControl structures IN SWIFT
Control structures IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Arrays and its properties IN SWIFT
Arrays and its properties IN SWIFTArrays and its properties IN SWIFT
Arrays and its properties IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Array and its functionsI SWIFT
Array and its functionsI SWIFTArray and its functionsI SWIFT
Array and its functionsI SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
10. funtions and closures IN SWIFT PROGRAMMING
10. funtions and closures IN SWIFT PROGRAMMING10. funtions and closures IN SWIFT PROGRAMMING
10. funtions and closures IN SWIFT PROGRAMMING
LOVELY PROFESSIONAL UNIVERSITY
 
Variables and data types IN SWIFT
 Variables and data types IN SWIFT Variables and data types IN SWIFT
Variables and data types IN SWIFT
LOVELY PROFESSIONAL UNIVERSITY
 
Soft skills. pptx
Soft skills. pptxSoft skills. pptx
Soft skills. pptx
LOVELY PROFESSIONAL UNIVERSITY
 
JAVA
JAVAJAVA
JAVA
LOVELY PROFESSIONAL UNIVERSITY
 
Unit 5
Unit 5Unit 5
Unit 5
LOVELY PROFESSIONAL UNIVERSITY
 
Unit 4
Unit 4Unit 4
Unit 4
LOVELY PROFESSIONAL UNIVERSITY
 
Unit 3
Unit 3Unit 3
Unit 3
LOVELY PROFESSIONAL UNIVERSITY
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
LOVELY PROFESSIONAL UNIVERSITY
 
Unit 1
Unit 1Unit 1
Unit 1
LOVELY PROFESSIONAL UNIVERSITY
 
COMPLETE CORE JAVA
COMPLETE CORE JAVACOMPLETE CORE JAVA
COMPLETE CORE JAVA
LOVELY PROFESSIONAL UNIVERSITY
 
Data wrangling IN R LANGUAGE
Data wrangling IN R LANGUAGEData wrangling IN R LANGUAGE
Data wrangling IN R LANGUAGE
LOVELY PROFESSIONAL UNIVERSITY
 
Ad

Recently uploaded (20)

Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
TechSoup
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
Debunking the Myths behind AI - v1, Carl Dalby
Debunking the Myths behind AI -  v1, Carl DalbyDebunking the Myths behind AI -  v1, Carl Dalby
Debunking the Myths behind AI - v1, Carl Dalby
Association for Project Management
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Lecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptxLecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptx
Arshad Shaikh
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
Rococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th centuryRococo versus Neoclassicism. The artistic styles of the 18th century
Rococo versus Neoclassicism. The artistic styles of the 18th century
Gema
 
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx   quiz by Ridip HazarikaTHE STG QUIZ GROUP D.pptx   quiz by Ridip Hazarika
THE STG QUIZ GROUP D.pptx quiz by Ridip Hazarika
Ridip Hazarika
 
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
Drive Supporter Growth from Awareness to Advocacy with TechSoup Marketing Ser...
TechSoup
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Link your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRMLink your Lead Opportunities into Spreadsheet using odoo CRM
Link your Lead Opportunities into Spreadsheet using odoo CRM
Celine George
 
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFAExercise Physiology MCQS By DR. NASIR MUSTAFA
Exercise Physiology MCQS By DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast BrooklynBridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
Bridging the Transit Gap: Equity Drive Feeder Bus Design for Southeast Brooklyn
i4jd41bk
 
Lecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptxLecture 4 INSECT CUTICLE and moulting.pptx
Lecture 4 INSECT CUTICLE and moulting.pptx
Arshad Shaikh
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 

practice problems on functions IN SWIFT

  • 1. Practice problems on functions 1. Write a Swift program to compute the sum of the two integers. If the values are equal return the triple their sum. 2. Write a Swift program to compute and return the absolute difference of n and 51, if n is over 51 return double the absolute difference 3. Write a Swift program that accept two integer values and return true if one of them is 20 or if their sum is 20. 4. Write a Swift program to accept two integer values and return true if one is negative and one is positive. Return true only if both are negative. 5. Write a Swift program to add "Is" to the front of a given string. However, if the string already begins with "Is", return the given string. 6. Write a Swift program to remove a character at specified index of a given non-empty string. The value of the specified index will be in the range 0..str.length()-1 inclusive 7. Write a Swift program to change the first and last character of a given string. 8. Write a Swift program to add the last character (given string) at the front and back of a given string. The length of the given string must be 1 or more. 9. Write a Swift program to check if a given non-negative number is a multiple of 3 or a multiple of 5. 10. Write a Swift program to take the first two characters from a given string and create a new string with the two characters added at both the front and back. 11. Write a Swift program to test a given string whether it starts with "Is". Return true or false. 12. Write a Swift program that return true if either of two given integers is in the range 10..30 inclusive. 13. Write a Swift program to check if a given string begins with "fix", except the 'f' can be any character or number. 14. Write a Swift program to find the largest number among three given integers. 15. Write a Swift program that accept two integer values and to test which value is nearest to the value 10, or return 0 if both integers have same distance from 10. 16. Write a Swift program that accept two integer values and test if they are both in the range 20..30 inclusive, or they are both in the range 30..40 inclusive. 17. Write a Swift program that accept two positive integer values and test whether the larger value is in the range 20..30 inclusive, or return 0 if neither is in that range. 18. Write a Swift program to test whether the last digit of the two given non-negative integer values are same or not. 19. Write a Swift program to convert the last three characters in upper case. If the string has less than 3 chars, lowercase whatever is there. 20. Write a Swift program to check if the first instance of "a" in a given string is immediately followed by another "a".
  • 2. 21. Write a Swift program to create a string made of every other char starting with the first from a given string. So "Python" will return "Pto" 22. Write a Swift program to count the number of 7's in a given array of integers. 23. Write a Swift program to check if one of the first 4 elements in a given array of integers is a 7. The length of the array may be less than 4. 24. Write a Swift program to test if the sequence of numbers 0, 1, 2 appears in a given array of integers somewhere. 25. Write a Swift program to create a new string where all the character "a" have been removed except the first and last positions. 26. Write a Swift program to create a string taking characters at indexes 0, 2, 4, 6, 8, .. from a given string 27. Write a Swift program to count the number of times that two 7's are next to each other in a given array of integers. 28. Write a Swift program to test whether a value presents sequentially three times in an array of integers or not.