Bumpy
why i cant doing Matrix[i][j]?
Vlad
Vlad
In your case I would advice to access it via [i * M + j]
Vlad
FBI
please can someone help me with pointers in C..?
Vlad
Because it knows the row length. And that's why placing second size is mandatory
Bumpy
Wow! great!
Vlad
If you catch my drift
FBI
Vlad
We won't babysit you
FBI
alright
FBI
Bumpy
MRT
Where is programming needed to define a pointer to pointer variable **var?
Dmitrii
Dmitrii
Some 3rd party libs probably or something beyond your control
MRT
Trent
Write a C program that prompts a user to enter an interger, and calculate and display it's factorial.The program should be able to reject any wrong inputs(should reject any input whose factorial cannot be determined)
Trent
Help with the question ☝☝☝
Dmitrii
You know what n! is?
Vlad
MRT
Does anyone know where is the best blockchain teaching university in eu?
MRT
MRT
Where should I start?
MRT
I do not mean solidity
MRT
math :-ss
MRT
it's scary
Dmitrii
MRT
But I dream of blockchain and I learn anyway
Anonymous
MRT
Vlad
Vlad
What does it need blockchain for? XD
MRT
An operating system that keeps your performance to itself forever
Dmitrii
Vedant
Anonymous
BASED on Tigo Pesa service (*150*01#)
Write a C++ program that utilize a switch…….case statement to operate the services. Your program should
display the main menu, and then expand a specific case as per the question.
NOTE:
i. The rest of the cases that does not correspond to your question should be implemented with just a
statement that display the name of the service
ii. In case user entered a wrong value, should be taken back to the previous menu and given an option
to enter another choice/value.
iii. You have to assume the fee charged for each service/amount and include them in your program if
and only if the service is charged.
Q: voucher na packs →Tigo pack →Month + Bonus →Internet→Tsh 20000 GB9
Anonymous
Can I have help on that 😞😞
Anonymous
Dq
Anonymous
AHMED
Anonymous
@everyir98
Bumpy
void buildMatrix(int n , int m) {
int Matrix = NULL;
Matrix = (int)(calloc(n,sizeof(int)));
for (int j = 0; j < n; j++) {
Matrix[j] = (int*)(calloc)(m,sizeof(int));
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
Matrix[i][j] = rand() %10;
}
}
printMatrix(Matrix,n,m);
}
void printMatrix(int **Matrix, int n , int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
printf("%d ", Matrix[i][j]);
}
printf("\n");
}
for (int j = 0; j < n; j++) {
if (Matrix != NULL) {
free(Matrix[j]);
}
}
}
Bumpy
why i get an Segmentation fault (core dumped) error
Vlad
Vlad
ftw
Vlad
Also printMatrix function accepts int**
Vlad
It is not compatible with int*
Vlad
Bumpy
i dont understand why .
Bumpy
in geeks for geeks its like that
Bumpy
i cant send **int as parameter?
Bumpy
oh.. im sorry i didnt saw that :(
Vlad
int Matrix = NULL;
Matrix = (int)(calloc(n,sizeof(int)));
for (int j = 0; j < n; j++) {
Matrix[j] = (int*)(calloc)(m,sizeof(int));
}
->
int** Matrix = calloc(n, sizeof(int*));
for (int j = 0; j < n; j++) {
Matrix[j] = (int*)(calloc)(m, sizeof(int));
}
Bumpy
if i was using in 32bit it was fine?
Vlad
You just hinder portabilty for nothing
Bumpy
👍
Vlad
Also sizeof(*ptr) is a thing. So you'll never mess up
Anonymous
void buildMatrix(int n , int m) {
int Matrix = NULL;
Matrix = (int)(calloc(n,sizeof(int)));
for (int j = 0; j < n; j++) {
Matrix[j] = (int*)(calloc)(m,sizeof(int));
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
Matrix[i][j] = rand() %10;
}
}
printMatrix(Matrix,n,m);
}
void printMatrix(int **Matrix, int n , int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
printf("%d ", Matrix[i][j]);
}
printf("\n");
}
for (int j = 0; j < n; j++) {
if (Matrix != NULL) {
free(Matrix[j]);
}
}
}
typedef struct { int **$; int rows; int cols; int _data[0]; } Matrix;
Matrix* new_Matrix(int rows, int cols) {
Matrix *mat = calloc(sizeof(Matrix) + rows*cols*sizeof(int));
int **$ = malloc(rows*sizeof(int*)); // size of pointer, not int
if(!mat || !$) { free(mat); free($); return NULL; }
mat->$ = $; mat->rows = rows; mat->cols = cols;
for(int i = 0; i < rows; i++) $[i] = &mat->_data[width*i];
return mat;
}
void destroy_Matrix(Matrix *mat) { free(mat->$); free(mat); }
Silent
Could anyone suggest an easy learnable book for C data structures ?
Anonymous
If you can find an old-fashioned Pascal book at a used bookstore it would translate to C pretty good...
Diego
A structure containing an int and a long is literally each thing individually but you can access them with one variable
eric_maina
hi, guys
in c ++
how do I use cin«..; for a user to enter a number which shall not exceed 100,
for example when a user is keying in marks for a subject,the programme shall not allow him/her to enter a number greater than 100
Atropos
Cavidan
Hello
Cavidan
Do you know c++?
Cavidan
Write a C program that discards the elements larger than 4 and smaller than 10 in a user-defined matrix of N * M to a separate array and print this new array on the screen.