Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imranhsayed/programming-in-c
Programming in C
https://github.com/imranhsayed/programming-in-c
array c c-programming circular-linked-list cprogramming data data-structures-and-algorithms file-handling linked-list pointers
Last synced: about 1 month ago
JSON representation
Programming in C
- Host: GitHub
- URL: https://github.com/imranhsayed/programming-in-c
- Owner: imranhsayed
- License: gpl-3.0
- Created: 2021-10-18T17:54:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-24T13:26:16.000Z (about 2 years ago)
- Last Synced: 2024-10-03T10:41:31.175Z (about 2 months ago)
- Topics: array, c, c-programming, circular-linked-list, cprogramming, data, data-structures-and-algorithms, file-handling, linked-list, pointers
- Language: C
- Homepage:
- Size: 173 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# programming-in-c
Programming in C## Compiling a c program
* Create an executable c program file and execute it.
```gcc example.c -o example && ./example
```### Arrays
#### One dimensional array ( Vectors )
* Syntax:
`int arrayVariableName[size];`* Example one - `int myNums[4];` // Here 4 is the size of the array, means this array can have upto four items.
* Example two `int myNums[] = {1, 4, 6, 8}` // Because we are declaring and initiallzing the array at the same time, we don't need to specify the size 4.#### Two Dimensional array ( Matrices )
* Syntax:
`int arrayVariableName[rowsCount][columnsCount];`* This two dimensional array has two rows and each row has 4 items(colums) in the array. You need to loop through it twice to print their values
* Example: `int myNums[2][4] = { {2, 3, 2, 1}, {2, 5, 4, 2}`* Example Two:
* ```
#include
int main(){
int i=0,j=0;
int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};//Traversing 2D array
for(i=0;i<4;i++){
for(j=0;j<3;j++){
printf("arr[%d] [%d] = %d \n",i,j,arr[i][j]);
}//end of j
}//end of i
return 0;
}
```