Lovely! can't wait for something to come of this!

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Andail on Sun 20/12/2009 08:34:49
I know what your problem is. Since you have little else in your life going on right now, there's so much pressure on you to accomplish something during all those lonely hours in front of the computer.
You need to make that time precious, something rare. You need to fill your days with more than just a monitor staring back at you.
Quote from: SSH on Sun 20/12/2009 09:29:21
User ratings could have half-cups or even smaller fractions.
Quote from: Crimson Wizard on Thu 17/12/2009 14:06:03
There's also this stupid joke that makes CD/DVD player tray eject and close over and over again. I read about that, scanned WinAPI documentation, found needed functions and wrote a small console app that did that. Never made a prank with this though,but I guess its possible if you make an inviisble window and put executable to Windows autorun folder
Quote from: Ben304 on Fri 04/12/2009 11:32:04
I stuck with 2.71 for a fair while, and then for some strange reason decided to try 3.xx.
And I realized how insanely good 3.xx is compared to that old thing.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*define function*/
float area_intg(float *fnc_fx, float *fnc_dx, int lines);
int main(int argc, char* argv[])
{
/*define a float for user-inputed upper limit of integration*/
float user_input, upper_lim, answer;
float *value_x, *value_xmin1, *dx, *fx, *fx_xmin1;
/*Check the upper limit is enter via command-line correctly*/
if (argc != 2)
{
printf("Need to enter upper limit of integration \n");
exit(EXIT_FAILURE);
}
/*Assign the user's string input to the float "upper_lim"*/
user_input = sscanf(argv[1], "%f", &upper_lim);
/*upper_lim = atof(argv[1]);*/
/*Check upper_lim is valid*/
if (upper_lim == 0)
{
printf("Upper limit cannot be 0, this is the lower limit. \n");
exit(EXIT_FAILURE);
}
if (upper_lim >= 1.57)
{
printf("Upper limit cannot exceed pi/2. \n");
exit(EXIT_FAILURE);
}
/*open the file containing data*/
FILE *input;
const char file_input[] = "px270prog3a.dat";
input = fopen(file_input, "r");
/*Find "num_lines" using while loop*/
int num_lines = 0;
float num_on_line;
while (num_on_line <= upper_lim)
{
fscanf(input, "%f", &num_on_line);
num_lines++;
}
/*manually assign number of array arguments, using malloc*/
value_x = (float*) malloc(sizeof(float) * num_lines);
value_xmin1 = (float*) malloc(sizeof(float) * num_lines);
fx = (float*) malloc(sizeof(float) * num_lines);
dx = (float*) malloc(sizeof(float) * num_lines);
/*scan file and store data in arrays*/
int n = 0;
for (n = 0; n < num_lines; n++)
{
fscanf(input, "%f %f", &value_x[n], &fx[n]);
fscanf(input, "%f", &value_xmin1[n-1]);
dx[n] = value_x[n] - value_xmin1[n-1];
}
answer = area_intg(fx, dx, num_lines);
printf("number of lines: %i \nanswer to integral: %f \n", num_lines, answer);
}
float area_intg(float *fnc_fx, float *fnc_dx, int lines)
{
float area;
int j;
for (j = 1; j < (lines); j++)
{
area += fnc_fx[j-1] * fnc_dx[j];
}
return(area);
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.102 seconds with 14 queries.