-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab03.cpp
More file actions
91 lines (57 loc) · 1.32 KB
/
Copy pathLab03.cpp
File metadata and controls
91 lines (57 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//============================================================================
// Name : Lab03.cpp
// Author : Vijithan Mangaleswaran
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string>
#include <cstdlib>
#include "Lab03.h"
using namespace std;
//Part 2
void PtrArthimetic (int r, int* array){
int i, j, placehold;
for(i = 0; i < r; i++){
for (j = i + 1; j < r; j++){
if (*(array + j) < *(array + i)){
placehold = *(array + i);
*(array + i) = *(array +j);
*(array + j) = placehold;
}
}
}
for (i = 0; i < r; i++)
cout << *(array + i) << " ";
}
int main (int argc, char* argv[]){
int n;
int s[10];
cout << "Enter the array (10 integers): ";
for (n=0; n<argc; n++) {
s[n] = atof(argv[n]);
}
cout << "The numbers in ascending order are:" << endl;
PtrArthimetic (argc, s);
return (0);
}
/*
using namespace std;
int main()
{
int salary[20];
int* ptr;
int i;
ptr = salary;
for (i=0;i<20;++i) {
cout <<"Enter Salary: ";
cin >> *(ptr + i);
}
for (i=0;i<20;++i){
*(ptr + i)= *(ptr + i)+ *(ptr + i)/(i+1);
cout << *(ptr + i) << " ";
}
return 0;
}
*/