-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.c
More file actions
61 lines (49 loc) · 1.33 KB
/
arrays.c
File metadata and controls
61 lines (49 loc) · 1.33 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
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <errno.h>
int main() {
int size = 10;
int n[ size ]; // n is an array of 10 integers
int i,j;
// initialize elements of array n to 0
for ( i = 0; i < size; i++ ) {
n[ i ] = i + 100; // set element at location i to i + 100
};
// output each array element's value
for (j = 0; j < size; j++ ) {
printf("Element[%d] = %d\n", j, n[j] );
};
//int numbers[2][3]={{1,2,3},{4,5,6}}
int rows =3;
int columns = 3;
int numbers[rows][columns];
numbers[0][0]=1;
numbers[0][1]=2;
numbers[0][2]=3;
numbers[1][0]=4;
numbers[1][1]=5;
numbers[1][2]=6;
numbers[2][0]=7;
numbers[2][1]=8;
numbers[2][2]=9;
for(int i=0; i<rows; i++){
for(int j=0; j<columns; j++){
printf("%d ",numbers[i][j]);
}
printf("\n");
}
char cars[][10]={"Mustang","Corvette","Camaro"};
//cars[0]="Tesla"
strcpy(cars[0],"Tesla");
for(int i=0; i< sizeof(cars)/sizeof(cars[0]); i++){
printf("%s\n",cars[i]);
}
return 0;
}
// Bro Code. (2021.10.7.). C Programming Full Course for free [Video]. YouTube. https://www.youtube.com/watch?v=87SH2Cn0s9A