Can you take a look of the new code, this one just adds all the numbers entered and print out the sum.
#include <pthread.h>
#include <stdio.h>
int sum; /* this data is shared...
Type: Posts; User: Lina_inverse
Can you take a look of the new code, this one just adds all the numbers entered and print out the sum.
#include <pthread.h>
#include <stdio.h>
int sum; /* this data is shared...
I want to create 2 threads, one does the max and one gives the average of a list of numbers entered in the command line.
#include <stdio.h>
#include <pthread.h>
#include...
So I am very new to multi-thread programming using Pthread in Linux. Can someone show me an example of something like taking a list of numbers on the command line and will then create three separate...
i am asked to find all the possible outputs in this question:
#define N 4
int val = 9;
void handler(sig) { val += 3; return;}
int main() {
pid_t pid;
can u tell me if this is correct?
compiler: spec.tab.o lex.yy.o
gcc spec.tab.o lex.yy.o -ly –ll
lex.yy.c: spec.l
flex spec.l
spec.tab.c: spec.y
bison -vd spec.y
spec.tab.o: spec.tab.c
gcc...
Give a makefile (doesn't have to be a separate file - just what the contents would be) that would generate the application described below. Be sure each generated file has its own rule.
The first...
So I am trying to write this function, read_deck, which is:
**void read_deck(char *filename, queue *deck)**
This function takes a character string of a file name. It opens the file...
Im not sure how to do this, it is in the following link:
http://i.imgur.com/PKfyL.jpg
Hi i am writing this piece of code which takes 3 field , store it into struct, but i dont know how to create the node and the function print_planet_list() should walk through the linked list and...
for (i=0; i<rows; rows++){
for (j=0; j<cols; cols++)
{
ans[i] = ans[i] + mat[i][j] * vec[j];
}
}
still 0s
oh thanks, well i changed to:
#include <stdlib.h>
/* Multiply a matrix by a vector. */
double *matrix_vector_multiply(int rows, int cols,
double **mat, double...
the logic for multiplying a matrix: mat[row][col] and a vector : vec[row]
is the following?
double *ans = malloc(rows * sizeof (double));
int i;
for (i=0; i<rows; rows++)
...
my read_vector is not even letting me enter the numbers for some reason.
For the read matrix function:
double **read_matrix(int rows, int cols){
typedef struct matrix
{
int rows;
int cols;
double **entries;
and btw, how do print out the numbers in the format of : ie. positive .2 is a 2.00e-01
by using a struct, how do i store the inputs into the array?
this is my print vector function:
/* Print a vector with n entries pointed to by vec. */
void print_vector(int n, double *vec){
int i;
for (i=0; i<n; i++) {
printf("%d", vec[i]);
}
changed some things:
double *read_vector(int n){
double *vec = (double *) malloc (sizeof(double)*n);
int i;
for (i=0; i<n; i++)
vec[i] = n;
return vec;
}
how do I read the inputs in?
Hi Im writing a function to read the matrix user enters and print it out, the main function:
double **read_matrix(int rows, int cols);
void print_matrix(int rows, int cols, double **mat);
...
I want to read user's input for my array using pointers, allocated space, read elements and return pointer.
my function is called read:
double read *read_vector (int n) // n is the size of...
edit: o i see what u mean with the [i].. thanks!
it just prints out 0's
12032
thanks for the fgets info. But Im still not too sure how to fix the printing out information.. [i] should be used since im printing solarsys[1], solarsys[2],.. and on. right?
so i have made some changes to the code, the user now can enter all the information in one single line. but when i try to print out the info the user entered, it only displays: 0.00000 for all the...