SlideShare a Scribd company logo
Write a C program that generates 50 floating-point random numbers in a rangefrom 0 to 10,000
using different seed values. Five floating-point random numbersper line are required to be
displayed on the output.
Solution
#include <stdlib.h>
#include <time.h>
int main()
{
float r[50];
int i=0;
time_t t;
printf(" 50 random floating numbers are displayed below: ");
for(i=0;i<50;i++)
{
if(i%5 == 0)
printf(" ");//5 floating numbers on 1 line.
srand( i * time(&t) ); // getting different seed numbers with respest to time and i.
r[i] = ((float)(rand())/(float)(RAND_MAX/1000.0)); // random floating number because the seed
is different.
printf("%ft", r[i]);// printing random float numbers
}
}
Write a C program that generates 50 floating-point random numbers in a.docx

More Related Content

More from richard981

Why might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docxWhy might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docx
richard981
 
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docxWhy might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
richard981
 
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docxWhy lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
richard981
 
Why might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docxWhy might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docx
richard981
 
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docxWhy is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
richard981
 
Why is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docxWhy is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docx
richard981
 
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docxWhy does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
richard981
 
why is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docxwhy is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docx
richard981
 
Why is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docxWhy is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docx
richard981
 
Why is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docxWhy is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docx
richard981
 
why EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docxwhy EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docx
richard981
 
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docxWhy is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
richard981
 
why does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docxwhy does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docx
richard981
 
Why does iodine have a much lower melting point than sodium iodide- W.docx
Why does iodine have a much lower melting point than sodium iodide-  W.docxWhy does iodine have a much lower melting point than sodium iodide-  W.docx
Why does iodine have a much lower melting point than sodium iodide- W.docx
richard981
 
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docxWhy do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
richard981
 
Why does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docxWhy does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docx
richard981
 
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docxWhy do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
richard981
 
Why does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docxWhy does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docx
richard981
 
Why do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docxWhy do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docx
richard981
 
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docxWhy do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
richard981
 

More from richard981 (20)

Why might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docxWhy might a small corporation organize as an S corporation- An S corpo.docx
Why might a small corporation organize as an S corporation- An S corpo.docx
 
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docxWhy might elemental bromine and iodine be more soluble in dicholormeth.docx
Why might elemental bromine and iodine be more soluble in dicholormeth.docx
 
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docxWhy lack of control got Comcast in trouble-Solutionthe media player is.docx
Why lack of control got Comcast in trouble-Solutionthe media player is.docx
 
Why might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docxWhy might a company accept a project or investment with an NPV less th.docx
Why might a company accept a project or investment with an NPV less th.docx
 
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docxWhy is Pluto so small- compared to the gas giants- Pick the one best a.docx
Why is Pluto so small- compared to the gas giants- Pick the one best a.docx
 
Why is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docxWhy is it important to use multiple performance measurements when eval.docx
Why is it important to use multiple performance measurements when eval.docx
 
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docxWhy does the absorption spectrum of as semiconductor have a sharp-stee.docx
Why does the absorption spectrum of as semiconductor have a sharp-stee.docx
 
why is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docxwhy is it important to understand culturesSolutionIt important to unde.docx
why is it important to understand culturesSolutionIt important to unde.docx
 
Why is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docxWhy is goal setting important- What are three benefits- What are three.docx
Why is goal setting important- What are three benefits- What are three.docx
 
Why is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docxWhy is frequency reuse of 1 possible and what is the number of users p.docx
Why is frequency reuse of 1 possible and what is the number of users p.docx
 
why EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docxwhy EI can not be used in determining protein primary structures-Solut.docx
why EI can not be used in determining protein primary structures-Solut.docx
 
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docxWhy is anion suppression necessary in ion chromatography-SolutionAnion.docx
Why is anion suppression necessary in ion chromatography-SolutionAnion.docx
 
why does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docxwhy does an atoms electronegativity decrease down a column in the peri.docx
why does an atoms electronegativity decrease down a column in the peri.docx
 
Why does iodine have a much lower melting point than sodium iodide- W.docx
Why does iodine have a much lower melting point than sodium iodide-  W.docxWhy does iodine have a much lower melting point than sodium iodide-  W.docx
Why does iodine have a much lower melting point than sodium iodide- W.docx
 
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docxWhy do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
Why do soluble impurities lower Tf of a solvent- Will insoluble impuri.docx
 
Why does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docxWhy does this kind of error happen- It is something about makefile- an.docx
Why does this kind of error happen- It is something about makefile- an.docx
 
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docxWhy do you think today-'s computer systems are so vulnerable-Solutiono.docx
Why do you think today-'s computer systems are so vulnerable-Solutiono.docx
 
Why does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docxWhy does one firm in the same industry have a high ROE- one firm has a.docx
Why does one firm in the same industry have a high ROE- one firm has a.docx
 
Why do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docxWhy do you think Starbucks has been so concerned with social responsib.docx
Why do you think Starbucks has been so concerned with social responsib.docx
 
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docxWhy do high levels of accruals appear to be mispriced-SolutionRichards.docx
Why do high levels of accruals appear to be mispriced-SolutionRichards.docx
 

Recently uploaded

What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Reflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdfReflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdf
amberjdewit93
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 

Recently uploaded (20)

What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Reflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdfReflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdf
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 

Write a C program that generates 50 floating-point random numbers in a.docx

  • 1. Write a C program that generates 50 floating-point random numbers in a rangefrom 0 to 10,000 using different seed values. Five floating-point random numbersper line are required to be displayed on the output. Solution #include <stdlib.h> #include <time.h> int main() { float r[50]; int i=0; time_t t; printf(" 50 random floating numbers are displayed below: "); for(i=0;i<50;i++) { if(i%5 == 0) printf(" ");//5 floating numbers on 1 line. srand( i * time(&t) ); // getting different seed numbers with respest to time and i. r[i] = ((float)(rand())/(float)(RAND_MAX/1000.0)); // random floating number because the seed is different. printf("%ft", r[i]);// printing random float numbers } }