Skip to content

Commit 192b1e2

Browse files
author
Senthil Kumaran
committed
updated with more programs.
1 parent 0582958 commit 192b1e2

8 files changed

Lines changed: 82 additions & 6 deletions

File tree

source/_templates/layout.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
crossorigin="anonymous"></script>
66
{% endblock %}
77

8-
{% block extrabody %}
9-
<h2>Choose only one master - Nature.</h2>
10-
{% endblock %}
11-
128
{% block content %}
139

1410
{{ super() }}

source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@
9999
footer_links = ",".join([
100100
"Senthil Kumaran|https://senthil.learntosolveit.com/",
101101
]),
102-
)
102+
)

source/cprogramming/concepts/concepts.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ C Programming Building Blocks
1414
11. Using extern
1515
12. Using enums
1616
13. Important C headers.
17-
14. Program Structure
17+
14. Program Structure
18+
15. malloc and calloc
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
3+
#define ROWS 5
4+
#define COLS 10
5+
6+
int main(int argc, char *argv[]) {
7+
int multi[ROWS][COLS];
8+
9+
int row, col;
10+
11+
for (row = 0; row < ROWS; row++) {
12+
for (col = 0; col < COLS; col++) {
13+
multi[row][col] = row * col;
14+
}
15+
}
16+
17+
for (row = 0; row < ROWS; row++) {
18+
for (col = 0; col < COLS; col++) {
19+
printf("\n%d ", multi[row][col]);
20+
printf("%d ", *(*(multi + row) + col));
21+
}
22+
}
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include<stdio.h>
2+
3+
int main(int argc, char *argv[]) {
4+
typedef unsigned char byte;
5+
6+
byte b[] = {'b', 'y', 't', 'e', '\0'};
7+
8+
printf("%s", b);
9+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
4+
#define COLS 5
5+
6+
7+
int main(int argc, char *argv[]) {
8+
9+
typedef int RowArray[COLS];
10+
RowArray *rptr;
11+
12+
int nrows = 10;
13+
int row, col;
14+
15+
rptr = malloc(nrows * COLS * sizeof (int));
16+
17+
for (row = 0; row < nrows; row++ ) {
18+
for (col = 0; col < COLS; col++) {
19+
rptr[row][col] = row * col;
20+
}
21+
}
22+
23+
free(rptr);
24+
return 0;
25+
}

source/cprogramming/concepts/cprogs/charater_array_string.c renamed to source/cprogramming/concepts/cprogs/p3_charater_array_string.c

File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
4+
int main(int argc, char *argv[]) {
5+
struct tag {
6+
char lname[20];
7+
char fname[20];
8+
int age;
9+
float rate;
10+
};
11+
12+
struct tag my_struct;
13+
14+
strcpy(my_struct.lname, "Kumaran");
15+
strcpy(my_struct.fname, "Senthil");
16+
17+
printf("\n%s ", my_struct.fname);
18+
printf("%s\n", my_struct.lname);
19+
20+
return 0;
21+
}
22+

0 commit comments

Comments
 (0)