C code Definition and 32 Threads
-
M
(CFD) Problem with C code for 1D linear convection equation
This is my c program below. Again everything works as expected up until the highlighted lines or the second for loop. When i run my program to output the arrays contents i get bizarre numbers that are not correct. # include <math.h> # include <stdlib.h> # include <stdio.h> # include <time.h>int...- mcgrane5
- Thread
- 1d C code Cfd Code Convection Linear
- Replies: 1
- Forum: Programming and Computer Science
-
A
Comp Sci Creating Huffman Tree with Coding Frequency
First, I get the string and I find the frequency of the every character. My struct is: typedef struct huffman_tree{ char c; int freq; //unsigned? struct huffman_tree *left; // 0 (left) struct huffman_tree *right; // 1 (right) }huffman_tree; I write this to create Huffman tree...- anonim
- Thread
- C code Coding Tree
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
A
Comp Sci Troubleshooting String and sscanf in C: How to Get Correct Output | Example Code
#include<stdio.h> int main(){ char str[]="My first book"; char *a,*b,*c; sscanf("%s %s %s",a,b,c); printf("a=%s b=%s c=%s",a,b,c); } I want the output: a= My b=first and c=book. But it does not work, why?- anonim
- Thread
- C code String
- Replies: 7
- Forum: Engineering and Comp Sci Homework Help
-
A
Recursively calculate the standard deviation
#include<stdio.h> #include<math.h> double foo(int n, int mean){ double square; if(n==1){ return(1); } if(n!=0){ square=pow(n-mean,2); return( (sqrt(square)+foo(n-1,mean))/(sqrt(n-1)) ); }} int main(){ int num; double mean; int i; int...- anonim
- Thread
- C code deviation Recursion Standard Standard deviation
- Replies: 1
- Forum: Programming and Computer Science
-
A
Comp Sci Calculating a math formula using void function-recursion in C
how can i write a function that calculate math formula using void function-recursion in C?- anonymous33
- Thread
- C code Formula Recursion
- Replies: 4
- Forum: Engineering and Comp Sci Homework Help
-
A
Comp Sci Do-while loop-> exit not working (making a crossword puzzle)
Hello! My homework is making a crossword. I write a code like this: do{ //code printf("Please enter the coordinate and the word: \n"); scanf(" %c%d %s",&row2,&column2,word2); if(row2=='E' && word2=="xit") exit(0); //code }while(count2!=10); But this is...- anonim
- Thread
- C code C language Loop Puzzle
- Replies: 21
- Forum: Engineering and Comp Sci Homework Help
-
F
Converting Simulink model to C code, integration
Dear Forumers,Given a simulink model: http://www.femm.info/Archives/contrib/images/TransientLoudspeaker/SimulinkOverview.png I would like to implement fast code for it.I have no access to matlib or simulink at all, so I tried to implement the simulation in C code. Code for the block...- flowwolf
- Thread
- C code Code Integration Model Simulink
- Replies: 2
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
Understanding 'C Code' & 'No.' in Buck Converter Regulator Datasheet
I have recently come across a datasheet for a buck converter regulator that uses the terms "c code" and "No." for certain capacitors but when going to the manufacturer datasheets for these capacitors they make no reference to any "c code" or one single number for a capacitor. If anyone could...- Mzzed
- Thread
- Buck converter C code Capacitors Code Converter Electronics Regulator
- Replies: 11
- Forum: Electrical Engineering
-
D
Which code segment completes this C code?
Homework Statement This is a question from the test i had today in which we had to look at certain C code segments and deduce which code part is missing in order for the program to do what we desire. Part b) was a short questionnaire to test our knowledge about c types and declarations. Part a)...- diredragon
- Thread
- C code C programming Code Homework
- Replies: 7
- Forum: Engineering and Comp Sci Homework Help
-
V
Why does not this Erdos-Renyi C code work?
Homework Statement I need to write an Erdos-Renyi random graph, by using the adjacency matrix (or alternatively list) and calculate the fitness of the graph. Definition: G(n, p) is a random graph with n vertices where each possible edge has probability p of existing.Homework Equations The...- valesdn
- Thread
- Algorithm C code C programming Code Graph Modelling Work
- Replies: 9
- Forum: Engineering and Comp Sci Homework Help
-
Review C Code: Find & Resolve Issues in Visual Studio & repl.it
Hi, i wrote a code and annotated it but i have few problems with it. First it won't run on Visual Studio but it runs fine on repl.it online site which uses a C ide. Second, it seems wrong when i input 5 45 6 -4 8 3 It should print out 8 3 but for some reason it misses out on 3. Could you see...- doktorwho
- Thread
- C code C programming Code Programming
- Replies: 47
- Forum: Programming and Computer Science
-
Help w/ C Programming Homework - Create Array & Print All Inputs
Homework Statement I am fairly new to C programming. I need to write a code that creates an array of max 300 numbers, ask the user to input the numbers and then print that array. Homework Equations 3. The Attempt at a Solution [/B] Here is my code #include <stdio.h> void main() { int...- doktorwho
- Thread
- Array C code C programming Code Coding
- Replies: 9
- Forum: Engineering and Comp Sci Homework Help
-
A
Comprehending some C code (simple function calls)
Homework Statement Hi, I have a piece of code that I'm trying to comprehend but I don't understand some aspects. Here is that code: #include <stdio.h> /* function prototype declaration for FindSum */ void FindSum(int, int, int *); int main(void) { int a=2, b=5, c=1, x=3, y=4, z=7; /*...- Arnoldjavs3
- Thread
- C code Code Function
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
A
Simple C code and PIC microcontroller: need it looked at
Homework Statement I'm using a PIC 16F877A microcontroller. An LDR and moisture sensor connect to the ADC. The main body of the code is ''void main'', and there is also a sub-code called "void light_the_led'' which is read inside the 'void main code'. I cannot get access easily to hardware or...- axe34
- Thread
- C code Code Microcontroller
- Replies: 5
- Forum: Engineering and Comp Sci Homework Help
-
J
Is there anything wrong with this C code?
I had an interview the other day and the lady was asking me about different ways to find whether there are any repeated elements in an array. At the end of the interview she told me to send her a code sample showing how to implement two of the ways we discussed. I thought that what I wrote was...- Jamin2112
- Thread
- C code Code
- Replies: 17
- Forum: Programming and Computer Science
-
S
C code and seven segment display
I need to write some c code that displays a counter value on four 7 segment displays. The number should increment by one every time a button is pushed. I cannot test this code as my home computer will not run Quartus 2 so I am working blind at the moment, but I would still like to ask some...- Steve Collins
- Thread
- C code Code
- Replies: 9
- Forum: Engineering and Comp Sci Homework Help
-
M
Troubleshooting C Code: Segmentation Fault in GCC on Ubuntu
the following code #include<stdio.h> #include<stdlib.h> int main (int argc, char *argv[]) { int* a; *a=1; return 0; } compiles ok, but throws "Segmentation fault (core dumped)" at runtime why is that? i'm working with gcc in ubuntu. I have been able to compile and run...- matiasmorant
- Thread
- C code Code Error
- Replies: 5
- Forum: Programming and Computer Science
-
J
C code, converting float into integer
Hi guys, i am using the C language and have created the following function: void counter (double c) { FILE *fp; char output[]="output.xls"; int n,p=0; int r=0; int i,j; float x=0; fp=fopen(output,"w"); fprintf(fp,"rmax\tnumber of particles within rmax\r\r\n"); for(n=1;n<=10;n++)...- jam12
- Thread
- C code Code Float Integer
- Replies: 16
- Forum: Programming and Computer Science
-
J
Can execution time of this C code be reduced?
Hi. I've been working on a finite-difference problem in differential equations. I was wondering if this code can be further optimized, perhaps eliminate some if statements or assignment statements. That is, what is the most efficient way to code this or is it already written in the most...- jackmell
- Thread
- C code Code Time
- Replies: 11
- Forum: Programming and Computer Science
-
F
Optimization of C code: smoothing an image.
Homework Statement I need to optimize this given code: /* A struct used to compute averaged pixel value */ typedef struct { int red; int green; int blue; int num; } pixel_sum; /* Compute min and max of two integers, respectively */ static int min(int a, int b) { return (a < b ...- Fronzbot
- Thread
- C code Code Image Optimization
- Replies: 25
- Forum: Engineering and Comp Sci Homework Help
-
F
Optimization of C Code Loop Unrolling
Homework Statement I need to optimize this given code that rotates an image 90 degrees so it runs at least three times faster: void naive_rotate(int dim, pixel *src, pixel *dst) { int i, j; for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) dst[RIDX(dim-1-j, i, dim)] =...- Fronzbot
- Thread
- C code Code Loop Optimization
- Replies: 10
- Forum: Engineering and Comp Sci Homework Help
-
P
Reading separate lines from txt file (C code)
Homework Statement I want to read each line separately in a char array from a text file. As yet, the best I could do is to read the entire file in a single char array. How can I read each line in a separate array? Homework Equations The Attempt at a Solution #include <stdio.h>...- Peon666
- Thread
- C code Code File Lines Reading
- Replies: 12
- Forum: Engineering and Comp Sci Homework Help
-
J
How to Terminate a While Loop in C Programming with a Printed Message or Value?
Im using the c programming language and just wanted to ask a quick question. In a while loop how do you make the program terminate by printing a value or a message here's my code while ((fabs(func(x))>epsilon)) { if(deriv(x)==0) { print the last value of x and stop the whole program} else {...- jam12
- Thread
- C code Code Numerical Numerical methods
- Replies: 7
- Forum: Programming and Computer Science
-
C
Help With C Programming Output | Troubleshooting Solutions
my attempt is (this is c programming) My output is really different. It gives the answer but not a detailed solution as the output above. Pls help me I really don't know how to show the long method :frown:- chemic_23
- Thread
- C code Code
- Replies: 1
- Forum: Programming and Computer Science
-
C
Get Help with C Code: Understanding Linked Lists and Queue Pointers
1. I have this code typedef struct linkedlist {struct linkedlist *next; key_t value;} queue; const queue *tail; queue *create_queue(key_t input) { queue temp; temp.next = NULL; temp.value = input; tail = &temp; printf("%d\n", tail->value); return &temp; } int main() { queue *one...- cshum00
- Thread
- C code Code
- Replies: 3
- Forum: Engineering and Comp Sci Homework Help
-
H
Optimizing C Code: Help with Loops and If Statements for Gear Combinations
Hey I am having some issues with my C code. What it should do is calculate the output speed when a gear combination is used. It loops to find all combinations for 4 gears from 1 to 42, but can be changed. 2 things i can't get working - IF STATEMENT - i want it to only show...- herpamad
- Thread
- C code Code Loop
- Replies: 4
- Forum: Programming and Computer Science
-
A
Investigating Unexpected Outputs in C Code
Hi, I tried to assign inputs to a particular output and I've got some funny results. In this code ive change the value of rpm to into the address of arrays that I've set. The adress correspond to the delay time for spark to occur. Heres my c code : #include <stdio.h> void main()...- akueddy
- Thread
- C code Code
- Replies: 1
- Forum: Programming and Computer Science
-
P
Why is the Third Mass Moving in the X Direction?
Homework Statement http://www2.warwick.ac.uk/fac/sci/physics/teach/module_home/px270/projects/c4s_projects07.pdf it's the first example Homework Equations see aboveThe Attempt at a Solution right i shouldn't have any probs with the programming but i need to understand the calcs that are put...- Pixter
- Thread
- Body C code Code
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
M
MIPS 32 ASM to C code, did i do this right?
have the following MIPS 32 asm code: Assuming B is an array of 10 words whose base address is in register $s0, andvariable c and i are in $s1 and $s2, respectively. What is the C statement implemented by the below MIPS assembly code? add $t0, $s2, $s2 add $t0, $t0, $t0 lw $t1, 0($s0) lw...- mr_coffee
- Thread
- C code Code Mips
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
V
Is Visual Studio Compatible with ANSI C Standards?
I am starting a programing class for scientists and engineers at the end of the month. I wanted to brush up on my C. I used to compile C programs with Visual Studio, but now that no longer seems to work. Even simple example programs in the book generate a litiney of compile errors in Visual...- vociferous
- Thread
- C code Code Visual
- Replies: 7
- Forum: Programming and Computer Science
-
B
Decimal Values & ANSI C Code for Image File
Hi, I have a problem to code this: Image that you have the following file presenting the following decimal values: 2 A 40.0 115.00 1.02842 5.944 10.0528 -1.656 115.00 1.01911 4.678 10.0528 177.078 11 6 100.0 115.00 1.01530 2.392 2.9097 11.933 115.00 1.00338...- brad sue
- Thread
- C code Code File Image
- Replies: 3
- Forum: Programming and Computer Science
-
Handling User Input Errors in C: Looping and Checking for Numeric Range
Hi, I am trying to write a loop that will check a users input to be between a certain numeric range in C. The thing is, I expect the person to enter a number, not a character. When the person enters a character, the loop becomes infinite. Thats the problem. If you look at example source...- Juntao
- Thread
- C code Code
- Replies: 3
- Forum: Introductory Physics Homework Help