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

PDF
C programs
PDF
Update include ltiostreamgt include ltfstreamgt .pdf
PDF
programs
PDF
Set 6 fundamental of programing file pagea
PDF
Common problems solving using c
PDF
codes.txt.pdf code presentation engineering
DOCX
Oops lab manual
PDF
C programs
Update include ltiostreamgt include ltfstreamgt .pdf
programs
Set 6 fundamental of programing file pagea
Common problems solving using c
codes.txt.pdf code presentation engineering
Oops lab manual

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

PDF
Educational Objectives After successfully completing this assignmen.pdf
DOCX
Ejercicios de programacion
PDF
Program 1 (Practicing an example of function using call by referenc.pdf
PDF
C++ TUTORIAL 4
PDF
PDF
Array notes
PDF
Question 1 has already been posted to Chegg and I am waiting for the.pdf
DOCX
Program 1The following program manipulates array of inte.docx
PDF
c-programming-using-pointers
DOC
Sorting programs
PDF
C++ Nested loops, matrix and fuctions.pdf
PDF
Final DAA_prints.pdf
PDF
C Programming lab
PPT
array.ppt
PDF
Data Structure using C
PDF
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
DOCX
Abebe1
Educational Objectives After successfully completing this assignmen.pdf
Ejercicios de programacion
Program 1 (Practicing an example of function using call by referenc.pdf
C++ TUTORIAL 4
Array notes
Question 1 has already been posted to Chegg and I am waiting for the.pdf
Program 1The following program manipulates array of inte.docx
c-programming-using-pointers
Sorting programs
C++ Nested loops, matrix and fuctions.pdf
Final DAA_prints.pdf
C Programming lab
array.ppt
Data Structure using C
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Abebe1
Ad

More from arjunchetri1 (20)

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

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Structure & Organelles in detailed.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
master seminar digital applications in india
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Presentation on HIE in infants and its manifestations
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
Cell Structure & Organelles in detailed.
Microbial disease of the cardiovascular and lymphatic systems
202450812 BayCHI UCSC-SV 20250812 v17.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
master seminar digital applications in india
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Module 4: Burden of Disease Tutorial Slides S2 2025
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Presentation on HIE in infants and its manifestations
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF

#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 */