SlideShare a Scribd company logo
Hello! Can I plz have this in C? This is the second time I submit this question. There are too
many versions not workingin the internet. Can I have a different one that is working?
Thank you!
Write a function that verifies if a given number exists in an array of floats. The function is
supposed to return the first position in where the number is encountered. If the given number
does not exist, the function returns –1.
Then write a program that asks the user to enter an array of floats and calls the function.
The prototype of the function should be like:
int Search (floats a[ ] , int n, float number)
Example:
Consider the following array of floats
2.1Â Â Â Â Â Â 1 9 -14Â Â Â Â Â 17.3Â Â Â 5.9 9 17
0Â Â Â Â Â Â Â Â Â 1 2 3Â Â Â Â Â Â Â Â Â 4Â Â Â Â Â Â Â Â Â
5Â Â Â Â Â Â Â Â Â 6Â Â Â Â Â Â Â Â Â 7
If the number to be searched is 5.4 the function returns –1
If the number to be searched is 9 the function returns 2
Solution
Answer
#include <stdio.h>
int Search(float a[ ],int n,float number)
{
int i,loc=-1;
for(i=0;i<n;i++)
{
if(a[i]==number)
{
loc=i;
break;
}
}
return loc;
}
int main(void)
{
int loc,n,i;
printf(" Enter array size : "); //input array size
scanf("%d",&n);
float arr[n],num;
printf(" Enter array :  "); //Input array of values
for(i=0;i<n;i++)
{
scanf("%f",&arr[i]);
}
printf(" Enter value to Search : "); //input of value to search
scanf("%f",&num);
loc=Search(arr,n,num); //Function call
printf(" Result : %d",loc);
return 0;
}

More Related Content

Similar to Hello! Can I plz have this in C- This is the second time I submit this.docx

ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
priestmanmable
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Notes5
Notes5Notes5
Notes5
hccit
 
Interview questions_mod.pdf
Interview questions_mod.pdfInterview questions_mod.pdf
Interview questions_mod.pdf
Rajb54
 

Similar to Hello! Can I plz have this in C- This is the second time I submit this.docx (20)

ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Week 2.pptx
Week 2.pptxWeek 2.pptx
Week 2.pptx
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better Parts
 
Presentation 2.pptx
Presentation 2.pptxPresentation 2.pptx
Presentation 2.pptx
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
OODP UNIT 2 Function overloading
OODP UNIT 2 Function overloadingOODP UNIT 2 Function overloading
OODP UNIT 2 Function overloading
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
Notes5
Notes5Notes5
Notes5
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested LoopLoops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
 
Interview questions_mod.pdf
Interview questions_mod.pdfInterview questions_mod.pdf
Interview questions_mod.pdf
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 

More from deant5

Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
deant5
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docx
deant5
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx
deant5
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
deant5
 

More from deant5 (20)

Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docxHello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
 
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docxhe above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
 
Halogens tend to have high- I- electronegativities II- solublity in a.docx
Halogens tend to have high-  I- electronegativities II- solublity in a.docxHalogens tend to have high-  I- electronegativities II- solublity in a.docx
Halogens tend to have high- I- electronegativities II- solublity in a.docx
 
Heat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docxHeat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docxhe following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docxhe following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
 
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docxHarriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
 
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docx
 
Gordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docxGordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docx
 
Goodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docxGoodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docx
 
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx
 
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
 
1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx
 
1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx
 
1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
 

Recently uploaded

ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
ashishpaul799
 

Recently uploaded (20)

Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 

Hello! Can I plz have this in C- This is the second time I submit this.docx

  • 1. Hello! Can I plz have this in C? This is the second time I submit this question. There are too many versions not workingin the internet. Can I have a different one that is working? Thank you! Write a function that verifies if a given number exists in an array of floats. The function is supposed to return the first position in where the number is encountered. If the given number does not exist, the function returns –1. Then write a program that asks the user to enter an array of floats and calls the function. The prototype of the function should be like: int Search (floats a[ ] , int n, float number) Example: Consider the following array of floats 2.1      1 9 -14     17.3   5.9 9 17 0         1 2 3         4         5         6         7 If the number to be searched is 5.4 the function returns –1 If the number to be searched is 9 the function returns 2 Solution Answer #include <stdio.h> int Search(float a[ ],int n,float number) { int i,loc=-1;
  • 2. for(i=0;i<n;i++) { if(a[i]==number) { loc=i; break; } } return loc; } int main(void) { int loc,n,i; printf(" Enter array size : "); //input array size scanf("%d",&n); float arr[n],num; printf(" Enter array : "); //Input array of values for(i=0;i<n;i++) { scanf("%f",&arr[i]); } printf(" Enter value to Search : "); //input of value to search scanf("%f",&num); loc=Search(arr,n,num); //Function call printf(" Result : %d",loc); return 0; }