SlideShare a Scribd company logo
#include
#include
#include
double total(int array[], int n)
{
int i, sum =0;
for (i = 0; i < n; i++)
{
sum = sum + array[i];
}
return sum;
}
int main()
{
srand(time(NULL));
int i, n, rand_number;
printf("Enter an integer: ");
scanf("%d",&n);
int array[n];
for (i = 0; i < n; i++)
{
rand_number = rand() % 1000;
array[i] = rand_number;
}
int max = array[0];
int min = array[0];
int min_pos;
int max_pos;
for (i = 0; i < n; i++)
{
if(array[i] > max)
{
max = array[i];
max_pos = i;
}
if(array[i] < min)
{
min = array[i];
min_pos = i;
}
}
int sum = total(array,n);
double average = sum/n;
printf("min: %d pos: %d ",min, min_pos);
printf("max: %d pos: %d ",max, max_pos);
printf("sum: %d  ",sum);
printf("average: %lf  ",average);
printf("Post|tval ");
printf("----------------------- ");
for (i = 0; i < n; ++i)
{
printf("%dt|t%d ",i,array[i]);
}
printf(" ");
return 0;
}
/*
output:
Enter an integer: 30
min: 5 pos: 28
max: 998 pos: 0
sum: 14093
average: 469.000000
Pos | val
-----------------------
0 | 998
1 | 403
2 | 523
3 | 787
4 | 37
5 | 14
6 | 815
7 | 232
8 | 594
9 | 555
10 | 531
11 | 52
12 | 550
13 | 530
14 | 265
15 | 839
16 | 247
17 | 902
18 | 99
19 | 120
20 | 648
21 | 101
22 | 6
23 | 983
24 | 759
25 | 664
26 | 371
27 | 705
28 | 5
29 | 758
*/
Solution
#include
#include
#include
double total(int array[], int n)
{
int i, sum =0;
for (i = 0; i < n; i++)
{
sum = sum + array[i];
}
return sum;
}
int main()
{
srand(time(NULL));
int i, n, rand_number;
printf("Enter an integer: ");
scanf("%d",&n);
int array[n];
for (i = 0; i < n; i++)
{
rand_number = rand() % 1000;
array[i] = rand_number;
}
int max = array[0];
int min = array[0];
int min_pos;
int max_pos;
for (i = 0; i < n; i++)
{
if(array[i] > max)
{
max = array[i];
max_pos = i;
}
if(array[i] < min)
{
min = array[i];
min_pos = i;
}
}
int sum = total(array,n);
double average = sum/n;
printf("min: %d pos: %d ",min, min_pos);
printf("max: %d pos: %d ",max, max_pos);
printf("sum: %d  ",sum);
printf("average: %lf  ",average);
printf("Post|tval ");
printf("----------------------- ");
for (i = 0; i < n; ++i)
{
printf("%dt|t%d ",i,array[i]);
}
printf(" ");
return 0;
}
/*
output:
Enter an integer: 30
min: 5 pos: 28
max: 998 pos: 0
sum: 14093
average: 469.000000
Pos | val
-----------------------
0 | 998
1 | 403
2 | 523
3 | 787
4 | 37
5 | 14
6 | 815
7 | 232
8 | 594
9 | 555
10 | 531
11 | 52
12 | 550
13 | 530
14 | 265
15 | 839
16 | 247
17 | 902
18 | 99
19 | 120
20 | 648
21 | 101
22 | 6
23 | 983
24 | 759
25 | 664
26 | 371
27 | 705
28 | 5
29 | 758
*/

More Related Content

Similar to #include stdio.h #include stdlib.h #include time.hdouble.pdf

InsertionSort.pdf
InsertionSort.pdfInsertionSort.pdf
InsertionSort.pdf
mayanksanjay007
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
Ashutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
Ashutoshprasad27
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
Cpds lab
Cpds labCpds lab
1D Array
1D Array1D Array
1D Array
A. S. M. Shafi
 
Ada file
Ada fileAda file
Ada file
Kumar Gaurav
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
DR B.Surendiran .
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
apleather
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
scroghamtressie
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
argusacademy
 
Arrays
ArraysArrays
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
anujmkt
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
Dr.Sandhiya Ravi
 

Similar to #include stdio.h #include stdlib.h #include time.hdouble.pdf (20)

InsertionSort.pdf
InsertionSort.pdfInsertionSort.pdf
InsertionSort.pdf
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
array.ppt
array.pptarray.ppt
array.ppt
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
1D Array
1D Array1D Array
1D Array
 
Ada file
Ada fileAda file
Ada file
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
Arrays
ArraysArrays
Arrays
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
 

More from arjunchetri1

The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdfThe products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
arjunchetri1
 
SolutionDividend per share= total dividend paid out to common stoc.pdf
SolutionDividend per share= total dividend paid out to common stoc.pdfSolutionDividend per share= total dividend paid out to common stoc.pdf
SolutionDividend per share= total dividend paid out to common stoc.pdf
arjunchetri1
 
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdf
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdfPure risk is a case where the outcome is strictly defined i.e. eithe.pdf
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdf
arjunchetri1
 
Pauliss rule Electrons fill orbitals having lowest energy states.pdf
Pauliss rule  Electrons fill orbitals having lowest energy states.pdfPauliss rule  Electrons fill orbitals having lowest energy states.pdf
Pauliss rule Electrons fill orbitals having lowest energy states.pdf
arjunchetri1
 
Polymearase Chain Reaction and Electrophoresis can used employed in .pdf
Polymearase Chain Reaction and Electrophoresis can used employed in .pdfPolymearase Chain Reaction and Electrophoresis can used employed in .pdf
Polymearase Chain Reaction and Electrophoresis can used employed in .pdf
arjunchetri1
 
P& loss ac drTo provision for social securituy taxes (amount of g.pdf
P& loss ac drTo provision for social securituy taxes (amount of g.pdfP& loss ac drTo provision for social securituy taxes (amount of g.pdf
P& loss ac drTo provision for social securituy taxes (amount of g.pdf
arjunchetri1
 
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdfOne month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
arjunchetri1
 
Nothing happens.SolutionNothing happens..pdf
Nothing happens.SolutionNothing happens..pdfNothing happens.SolutionNothing happens..pdf
Nothing happens.SolutionNothing happens..pdf
arjunchetri1
 
Intranet Portals1) Intranet portals now a days are at the epicent.pdf
Intranet Portals1) Intranet portals now a days are at the epicent.pdfIntranet Portals1) Intranet portals now a days are at the epicent.pdf
Intranet Portals1) Intranet portals now a days are at the epicent.pdf
arjunchetri1
 
import java.awt.; Using AWT container and component classes im.pdf
import java.awt.;  Using AWT container and component classes im.pdfimport java.awt.;  Using AWT container and component classes im.pdf
import java.awt.; Using AWT container and component classes im.pdf
arjunchetri1
 
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdfIf possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
arjunchetri1
 
How should the judicial system treat juvenile criminal offendersJ.pdf
How should the judicial system treat juvenile criminal offendersJ.pdfHow should the judicial system treat juvenile criminal offendersJ.pdf
How should the judicial system treat juvenile criminal offendersJ.pdf
arjunchetri1
 
coordinated movements of gastrulation begin. This dramatic process t.pdf
coordinated movements of gastrulation begin. This dramatic process t.pdfcoordinated movements of gastrulation begin. This dramatic process t.pdf
coordinated movements of gastrulation begin. This dramatic process t.pdf
arjunchetri1
 
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdfCu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
arjunchetri1
 
Assign a major brain structure to each of the cehalon belowdiencep.pdf
Assign a major brain structure to each of the cehalon belowdiencep.pdfAssign a major brain structure to each of the cehalon belowdiencep.pdf
Assign a major brain structure to each of the cehalon belowdiencep.pdf
arjunchetri1
 
B. Assets are listed in descending order of liquidity.The most liq.pdf
B. Assets are listed in descending order of liquidity.The most liq.pdfB. Assets are listed in descending order of liquidity.The most liq.pdf
B. Assets are listed in descending order of liquidity.The most liq.pdf
arjunchetri1
 
ans) 2 is the true oneone parentheses one thied close parentheses .pdf
ans) 2 is the true oneone parentheses one thied close parentheses .pdfans) 2 is the true oneone parentheses one thied close parentheses .pdf
ans) 2 is the true oneone parentheses one thied close parentheses .pdf
arjunchetri1
 
Answer B. FiberExplanationFiber optic cable is used by the Int.pdf
Answer B. FiberExplanationFiber optic cable is used by the Int.pdfAnswer B. FiberExplanationFiber optic cable is used by the Int.pdf
Answer B. FiberExplanationFiber optic cable is used by the Int.pdf
arjunchetri1
 
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdf
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdfAnswer The outer earPinnaEar canalThe Middle EarTympanic .pdf
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdf
arjunchetri1
 
the carbon 2 and carbon 3 are having one double b.pdf
                     the carbon 2 and carbon 3 are having one double b.pdf                     the carbon 2 and carbon 3 are having one double b.pdf
the carbon 2 and carbon 3 are having one double b.pdf
arjunchetri1
 

More from arjunchetri1 (20)

The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdfThe products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
The products are K2SO4(aq), H2O(l)KOH(aq) + H2SO4(aq) = K2SO4(aq.pdf
 
SolutionDividend per share= total dividend paid out to common stoc.pdf
SolutionDividend per share= total dividend paid out to common stoc.pdfSolutionDividend per share= total dividend paid out to common stoc.pdf
SolutionDividend per share= total dividend paid out to common stoc.pdf
 
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdf
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdfPure risk is a case where the outcome is strictly defined i.e. eithe.pdf
Pure risk is a case where the outcome is strictly defined i.e. eithe.pdf
 
Pauliss rule Electrons fill orbitals having lowest energy states.pdf
Pauliss rule  Electrons fill orbitals having lowest energy states.pdfPauliss rule  Electrons fill orbitals having lowest energy states.pdf
Pauliss rule Electrons fill orbitals having lowest energy states.pdf
 
Polymearase Chain Reaction and Electrophoresis can used employed in .pdf
Polymearase Chain Reaction and Electrophoresis can used employed in .pdfPolymearase Chain Reaction and Electrophoresis can used employed in .pdf
Polymearase Chain Reaction and Electrophoresis can used employed in .pdf
 
P& loss ac drTo provision for social securituy taxes (amount of g.pdf
P& loss ac drTo provision for social securituy taxes (amount of g.pdfP& loss ac drTo provision for social securituy taxes (amount of g.pdf
P& loss ac drTo provision for social securituy taxes (amount of g.pdf
 
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdfOne month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
One month liquidity index=10(.981)+90(.85.92)=0.93Liquidity .pdf
 
Nothing happens.SolutionNothing happens..pdf
Nothing happens.SolutionNothing happens..pdfNothing happens.SolutionNothing happens..pdf
Nothing happens.SolutionNothing happens..pdf
 
Intranet Portals1) Intranet portals now a days are at the epicent.pdf
Intranet Portals1) Intranet portals now a days are at the epicent.pdfIntranet Portals1) Intranet portals now a days are at the epicent.pdf
Intranet Portals1) Intranet portals now a days are at the epicent.pdf
 
import java.awt.; Using AWT container and component classes im.pdf
import java.awt.;  Using AWT container and component classes im.pdfimport java.awt.;  Using AWT container and component classes im.pdf
import java.awt.; Using AWT container and component classes im.pdf
 
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdfIf possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
If possible let T+e1+e2+e2 be non planarThen either one of e1, e2 .pdf
 
How should the judicial system treat juvenile criminal offendersJ.pdf
How should the judicial system treat juvenile criminal offendersJ.pdfHow should the judicial system treat juvenile criminal offendersJ.pdf
How should the judicial system treat juvenile criminal offendersJ.pdf
 
coordinated movements of gastrulation begin. This dramatic process t.pdf
coordinated movements of gastrulation begin. This dramatic process t.pdfcoordinated movements of gastrulation begin. This dramatic process t.pdf
coordinated movements of gastrulation begin. This dramatic process t.pdf
 
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdfCu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
Cu(II)Oxide has solid with mono clinic structure .m.p is 12010 C and.pdf
 
Assign a major brain structure to each of the cehalon belowdiencep.pdf
Assign a major brain structure to each of the cehalon belowdiencep.pdfAssign a major brain structure to each of the cehalon belowdiencep.pdf
Assign a major brain structure to each of the cehalon belowdiencep.pdf
 
B. Assets are listed in descending order of liquidity.The most liq.pdf
B. Assets are listed in descending order of liquidity.The most liq.pdfB. Assets are listed in descending order of liquidity.The most liq.pdf
B. Assets are listed in descending order of liquidity.The most liq.pdf
 
ans) 2 is the true oneone parentheses one thied close parentheses .pdf
ans) 2 is the true oneone parentheses one thied close parentheses .pdfans) 2 is the true oneone parentheses one thied close parentheses .pdf
ans) 2 is the true oneone parentheses one thied close parentheses .pdf
 
Answer B. FiberExplanationFiber optic cable is used by the Int.pdf
Answer B. FiberExplanationFiber optic cable is used by the Int.pdfAnswer B. FiberExplanationFiber optic cable is used by the Int.pdf
Answer B. FiberExplanationFiber optic cable is used by the Int.pdf
 
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdf
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdfAnswer The outer earPinnaEar canalThe Middle EarTympanic .pdf
Answer The outer earPinnaEar canalThe Middle EarTympanic .pdf
 
the carbon 2 and carbon 3 are having one double b.pdf
                     the carbon 2 and carbon 3 are having one double b.pdf                     the carbon 2 and carbon 3 are having one double b.pdf
the carbon 2 and carbon 3 are having one double b.pdf
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
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
Jheel Barad
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
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
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
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
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
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
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

#include stdio.h #include stdlib.h #include time.hdouble.pdf

  • 1. #include #include #include double total(int array[], int n) { int i, sum =0; for (i = 0; i < n; i++) { sum = sum + array[i]; } return sum; } int main() { srand(time(NULL)); int i, n, rand_number; printf("Enter an integer: "); scanf("%d",&n); int array[n]; for (i = 0; i < n; i++) { rand_number = rand() % 1000; array[i] = rand_number; } int max = array[0]; int min = array[0]; int min_pos; int max_pos; for (i = 0; i < n; i++) { if(array[i] > max) {
  • 2. max = array[i]; max_pos = i; } if(array[i] < min) { min = array[i]; min_pos = i; } } int sum = total(array,n); double average = sum/n; printf("min: %d pos: %d ",min, min_pos); printf("max: %d pos: %d ",max, max_pos); printf("sum: %d ",sum); printf("average: %lf ",average); printf("Post|tval "); printf("----------------------- "); for (i = 0; i < n; ++i) { printf("%dt|t%d ",i,array[i]); } printf(" "); return 0; } /* output: Enter an integer: 30 min: 5 pos: 28 max: 998 pos: 0 sum: 14093 average: 469.000000 Pos | val ----------------------- 0 | 998
  • 3. 1 | 403 2 | 523 3 | 787 4 | 37 5 | 14 6 | 815 7 | 232 8 | 594 9 | 555 10 | 531 11 | 52 12 | 550 13 | 530 14 | 265 15 | 839 16 | 247 17 | 902 18 | 99 19 | 120 20 | 648 21 | 101 22 | 6 23 | 983 24 | 759 25 | 664 26 | 371 27 | 705 28 | 5 29 | 758 */ Solution #include #include #include
  • 4. double total(int array[], int n) { int i, sum =0; for (i = 0; i < n; i++) { sum = sum + array[i]; } return sum; } int main() { srand(time(NULL)); int i, n, rand_number; printf("Enter an integer: "); scanf("%d",&n); int array[n]; for (i = 0; i < n; i++) { rand_number = rand() % 1000; array[i] = rand_number; } int max = array[0]; int min = array[0]; int min_pos; int max_pos; for (i = 0; i < n; i++) { if(array[i] > max) { max = array[i]; max_pos = i; } if(array[i] < min)
  • 5. { min = array[i]; min_pos = i; } } int sum = total(array,n); double average = sum/n; printf("min: %d pos: %d ",min, min_pos); printf("max: %d pos: %d ",max, max_pos); printf("sum: %d ",sum); printf("average: %lf ",average); printf("Post|tval "); printf("----------------------- "); for (i = 0; i < n; ++i) { printf("%dt|t%d ",i,array[i]); } printf(" "); return 0; } /* output: Enter an integer: 30 min: 5 pos: 28 max: 998 pos: 0 sum: 14093 average: 469.000000 Pos | val ----------------------- 0 | 998 1 | 403 2 | 523 3 | 787 4 | 37
  • 6. 5 | 14 6 | 815 7 | 232 8 | 594 9 | 555 10 | 531 11 | 52 12 | 550 13 | 530 14 | 265 15 | 839 16 | 247 17 | 902 18 | 99 19 | 120 20 | 648 21 | 101 22 | 6 23 | 983 24 | 759 25 | 664 26 | 371 27 | 705 28 | 5 29 | 758 */