SlideShare a Scribd company logo
1 of 2
Download to read offline
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.

More Related Content

What's hot

AWSのセキュリティについて
AWSのセキュリティについてAWSのセキュリティについて
AWSのセキュリティについてYasuhiro Horiuchi
 
20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App MeshAmazon Web Services Japan
 
Fargate起動歴1日の男が語る運用の勘どころ
Fargate起動歴1日の男が語る運用の勘どころFargate起動歴1日の男が語る運用の勘どころ
Fargate起動歴1日の男が語る運用の勘どころYuto Komai
 
Redshift Spectrumを使ってみた話
Redshift Spectrumを使ってみた話Redshift Spectrumを使ってみた話
Redshift Spectrumを使ってみた話Yoshiki Kouno
 
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjp
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjpAWS LambdaとDynamoDBがこんなにツライはずがない #ssmjp
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjpMasahiro NAKAYAMA
 
Xcode グループとフォルダー参照 #yhios
Xcode グループとフォルダー参照 #yhiosXcode グループとフォルダー参照 #yhios
Xcode グループとフォルダー参照 #yhiosTomohiro Kumagai
 
aws lambdaでpythonを実行するときのチューニング案を試してみた!
aws lambdaでpythonを実行するときのチューニング案を試してみた!aws lambdaでpythonを実行するときのチューニング案を試してみた!
aws lambdaでpythonを実行するときのチューニング案を試してみた!Shun Fukazawa
 
Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Web Services Japan
 
サーバーレスで ガチ本番運用までやってるお話し
サーバーレスで ガチ本番運用までやってるお話しサーバーレスで ガチ本番運用までやってるお話し
サーバーレスで ガチ本番運用までやってるお話しAkira Nagata
 
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきか
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきかElastiCacheを利用する上でキャッシュをどのように有効に使うべきか
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきかAmazon Web Services Japan
 
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンス
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンスAWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンス
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンスAmazon Web Services Japan
 
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由loftwork
 
Treinamento Desk Research
Treinamento Desk ResearchTreinamento Desk Research
Treinamento Desk ResearchEdney Souza
 
SageMaker Neoの可能性について - 第3回 Amazon SageMaker 事例祭り+体験ハンズオン
SageMaker Neoの可能性について- 第3回 Amazon SageMaker 事例祭り+体験ハンズオンSageMaker Neoの可能性について- 第3回 Amazon SageMaker 事例祭り+体験ハンズオン
SageMaker Neoの可能性について - 第3回 Amazon SageMaker 事例祭り+体験ハンズオンtomohiro kato
 
App inventor 3
App inventor 3App inventor 3
App inventor 3Roy Wang
 

What's hot (16)

AWSのセキュリティについて
AWSのセキュリティについてAWSのセキュリティについて
AWSのセキュリティについて
 
20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh
 
Fargate起動歴1日の男が語る運用の勘どころ
Fargate起動歴1日の男が語る運用の勘どころFargate起動歴1日の男が語る運用の勘どころ
Fargate起動歴1日の男が語る運用の勘どころ
 
Redshift Spectrumを使ってみた話
Redshift Spectrumを使ってみた話Redshift Spectrumを使ってみた話
Redshift Spectrumを使ってみた話
 
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjp
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjpAWS LambdaとDynamoDBがこんなにツライはずがない #ssmjp
AWS LambdaとDynamoDBがこんなにツライはずがない #ssmjp
 
Xcode グループとフォルダー参照 #yhios
Xcode グループとフォルダー参照 #yhiosXcode グループとフォルダー参照 #yhios
Xcode グループとフォルダー参照 #yhios
 
aws lambdaでpythonを実行するときのチューニング案を試してみた!
aws lambdaでpythonを実行するときのチューニング案を試してみた!aws lambdaでpythonを実行するときのチューニング案を試してみた!
aws lambdaでpythonを実行するときのチューニング案を試してみた!
 
Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集Amazon Pinpoint × グロースハック活用事例集
Amazon Pinpoint × グロースハック活用事例集
 
サーバーレスで ガチ本番運用までやってるお話し
サーバーレスで ガチ本番運用までやってるお話しサーバーレスで ガチ本番運用までやってるお話し
サーバーレスで ガチ本番運用までやってるお話し
 
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきか
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきかElastiCacheを利用する上でキャッシュをどのように有効に使うべきか
ElastiCacheを利用する上でキャッシュをどのように有効に使うべきか
 
ΠΛΗ31 ΤΕΣΤ 29
ΠΛΗ31 ΤΕΣΤ 29ΠΛΗ31 ΤΕΣΤ 29
ΠΛΗ31 ΤΕΣΤ 29
 
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンス
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンスAWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンス
AWS Black Belt Techシリーズ リザーブドインスタンス & スポットインスタンス
 
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由
100年先につながる新しい価値を目指して、パナソニックが100BANCHをつくった理由
 
Treinamento Desk Research
Treinamento Desk ResearchTreinamento Desk Research
Treinamento Desk Research
 
SageMaker Neoの可能性について - 第3回 Amazon SageMaker 事例祭り+体験ハンズオン
SageMaker Neoの可能性について- 第3回 Amazon SageMaker 事例祭り+体験ハンズオンSageMaker Neoの可能性について- 第3回 Amazon SageMaker 事例祭り+体験ハンズオン
SageMaker Neoの可能性について - 第3回 Amazon SageMaker 事例祭り+体験ハンズオン
 
App inventor 3
App inventor 3App inventor 3
App inventor 3
 

Similar to practice problems on functions IN SWIFT

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
 
practice problems on array IN SWIFT
practice problems on array IN SWIFTpractice problems on array IN SWIFT
practice problems on array IN SWIFT
 
practice problems on array IN SWIFT
practice problems on array IN SWIFTpractice problems on array IN SWIFT
practice problems on array IN SWIFT
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)
 
Java programlist (1)
Java programlist (1)Java programlist (1)
Java programlist (1)
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4
 
Programming qns
Programming qnsProgramming qns
Programming qns
 
If switch structure
If switch structureIf switch structure
If switch structure
 
A10
A10A10
A10
 
PYTHON PROGRAMS
PYTHON PROGRAMSPYTHON PROGRAMS
PYTHON PROGRAMS
 
Master Python in 15 Days.pdf
Master Python in 15 Days.pdfMaster Python in 15 Days.pdf
Master Python in 15 Days.pdf
 
C code examples
C code examplesC code examples
C code examples
 
C programming part4
C programming part4C programming part4
C programming part4
 
C programming part4
C programming part4C programming part4
C programming part4
 
Practical java
Practical javaPractical java
Practical java
 
1
11
1
 
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...
 
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
 
Java Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdfJava Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdf
 
C_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docx
 

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
 
Dictionaries IN SWIFT
Dictionaries IN SWIFTDictionaries IN SWIFT
Dictionaries IN SWIFT
 
Control structures IN SWIFT
Control structures IN SWIFTControl structures IN SWIFT
Control structures IN SWIFT
 
Arrays and its properties IN SWIFT
Arrays and its properties IN SWIFTArrays and its properties IN SWIFT
Arrays and its properties IN SWIFT
 
Array and its functionsI SWIFT
Array and its functionsI SWIFTArray and its functionsI SWIFT
Array and its functionsI SWIFT
 
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
 
Variables and data types IN SWIFT
 Variables and data types IN SWIFT Variables and data types IN SWIFT
Variables and data types IN SWIFT
 
Soft skills. pptx
Soft skills. pptxSoft skills. pptx
Soft skills. pptx
 
JAVA
JAVAJAVA
JAVA
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 4
Unit 4Unit 4
Unit 4
 
Unit 3
Unit 3Unit 3
Unit 3
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
Unit 1
Unit 1Unit 1
Unit 1
 
COMPLETE CORE JAVA
COMPLETE CORE JAVACOMPLETE CORE JAVA
COMPLETE CORE JAVA
 
Data wrangling IN R LANGUAGE
Data wrangling IN R LANGUAGEData wrangling IN R LANGUAGE
Data wrangling IN R LANGUAGE
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

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.