-6
votes
0answers
41 views

a looping statement in C only [closed]

so here is my code and i can't figure out how to do looping statement for the array. any suggestions?? #include <stdio.h> #include <stdlib.h> int main (void) { /*title info*/ char ...
5
votes
3answers
130 views

For loop without the second condition, i.e. the boolean check?

I have to write a function that calculates the floor of log base 16 of an unsigned int passed in. There are restrictions as to what operators and what constants we are allowed to use, and we can only ...
0
votes
3answers
35 views

Linked list appears backwards

I have a linked list that is coming out backwards. I appear to be adding elements to the back of the list, when I want to place them on the front. My nodes appear as follows: struct node{ int data; ...
0
votes
2answers
37 views

Reading and Writing data into a file printing invalid data

The question says to write a program to read several sets of prices and discounts from a file choosing a end-of-data marker such as 0 or -1. It also says to print the original price, discounted ...
0
votes
1answer
54 views

Linked list issue - loop iterates over wrong nodes

If you are not familiar with Josephus problem: There are N soldiers standing in a circle.They all get executed starting by 1 and moving by M.In the end only one of them stands alive. the code below ...
-1
votes
2answers
53 views

Implementing if - else if using bitwise operators [closed]

Assume that the value of test is 1 or 0. Here I can implement the following if statement using bitwise operators as below. if (test) output = a; else output = b; Using bit wise operators ...
0
votes
2answers
59 views

Generate random integer within a range (Infinite loop)

I'm having problems with this code because when I run it i get an infinite loop with the number random generator. What I'm trying to do is to assign to an array , 99 numbers from 1 to 9 and then make ...
-2
votes
5answers
77 views

A tough loop in a contest

Today I got a irritating question in a coding contest. I creamed through the first round but in the second round the following question got me in a trap. Question: Input N = 4 Output: ...
0
votes
2answers
50 views

Endless loop in C while scanning file

I am trying to scan file by using while loop: while(feof(src_file) == 0){ } This method works perfectly fine if there is only one row in scanned file. Otherwise, I get an endless loop. Why is that ...
5
votes
2answers
84 views

Complexity for nested loops dividing by 2

I am trying to figure out the complexity of a for loop using Big O notation. I have done this before in my other classes, but this one is more rigorous than the others because it is on the actual ...
1
vote
1answer
34 views

C program Loops Constantly when ( used comma or letter) ( starts second loop when entered Y or N ), How to fix it?

Here is the Code and it loops when I enter a letter or use a comma instead of dot, f.e. 0,1 or 0,000045 ... etc. It loops constantly how to avoid that? #include <stdio.h> #include ...
-4
votes
1answer
50 views

test each object in a list against every other object in the same list exactly once using python [closed]

To highlight what I am trying to do here is the equivalent in C code. for ( int i = 0; i < COUNT; ++i ) { for ( int j = i + 1; j < COUNT; ++j ) { foo( i, j ); } } ...where ...
1
vote
3answers
55 views

Want to reduce a function by looping through structs

Good Morning All, I'm trying to reduce a function that's very repetitive, but each "repetition" has two structs with struct A.element1 setting struct B.element1. At the moment I have myFunction() ...
-2
votes
3answers
70 views

Concatenating a char into a string

I am trying to read a string from the console. But I want to read it char by char. And I'm having trouble with concatenating the char into the string AND with breaking the loop. Here is the code: ...
0
votes
3answers
92 views

loop not running as intended

I can't find the break in logic here but when run I get an output of 3125 as for what was supposed to be the largest prime factor. 3125 is obviously not prime nor even the largest non-prime factor. ...

1 2 3 4 5 32
15 30 50 per page