C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

learn more… | top users | synonyms

2
votes
1answer
20 views

Doubly Linked List implementation

At university we shortly started using C. I thought it would be a good exercise for almost everything that has to do with basic C to do a doubly linked list implementation. I tried to do it from ...
1
vote
2answers
70 views

CodeChef - Please like me

In a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least ...
-5
votes
0answers
19 views

c programming loops and functions [on hold]

I am a beginner and wants to know much from you as I know you do help the generation in excelling up. what are uses of functions in c programming and explain the types of loops available.
4
votes
2answers
57 views

Performance of Median routine using min performs abysmally

I am writing a routine to calculate median using the minimum of the numbers and then changing the value of the minimum to a large value outside the range of numbers (assuming you know the nature of ...
3
votes
2answers
47 views

CodeChef- Chef and Strange Formula

For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). "k!" means factorial: k! = 1 * 2 * .. * k Chef wants to calculate F(p1) + F(p2) + ... + ...
-1
votes
0answers
18 views

Pointers behaviour in C [on hold]

I was experimenting with pointers. Look at this code: ...
7
votes
2answers
118 views

Manage multiple file writes in C

I have a very simple C program that continuously reads from a temperature sensor and displays the temperature on two 7-segment LEDs. Reading is simple, but to display the LEDs I need to write to 14 ...
-3
votes
0answers
31 views

Simple Manual Todo List [on hold]

I'm working on learning escape sequences and ASCII codes. When I run the following program: ...
0
votes
0answers
13 views

C code to represent a dataset and a 'window' of data

I'm fairly new to C so I'm looking to see if I'm heading in the right direction. This bit of code is to define a structure which represents a dataset (in this case, a GDAL dataset and some ...
0
votes
1answer
41 views

Check if two strings are anagrams - HackerEarth

You are given two strings. You have to check if the strings are permutations of each other and output "YES" or "NO" accordingly without quotes. Input: 2 lines of input each containing a ...
0
votes
3answers
47 views

SPOJ problem - The last digit of a number to a power (follow up)

As a follow up to my post here. Please refer to the problem statement in that post. I have edited this code to make it time efficient, but doing so the size of the source file has crossed the limit ...
2
votes
0answers
29 views

Off-line minimum using disjoint sets - C

The off-line minimum problem asks us to maintain a dynamic set T of elements from the domain (1..n) under the operation INSERT and EXTRACT-MIN. We are give a sequence S of n INSERT and m ...
1
vote
1answer
42 views

SPOJ problem - The last digit of a number to a power

Here is the problem statement: Given integers \$a\$ (\$0 \le a \le 20\$) and \$b\$ (\$0 \le b \le 2,147,483,000\$), where \$a\$ and \$b\$ are not both 0, find the last digit of \$a^b\$. ...
3
votes
3answers
62 views

Generating letter combinations

It's about two months since I posted this question on CodeReview. I've been working hard to improve the code posted there and came up with the following. ...
2
votes
2answers
54 views

Inverting an image

The problem is that I am trying to modify the code to invert the image in C and optimize it to make it run faster than the original by any method I could think of. After tried to use blocking and loop ...
4
votes
3answers
66 views

Bitstream reader

I have a program which reads and analyses MPEG-TS files. I've been using gperftools to identify hotspots and optimize them, and 45% of all samples at this point are in my main bitstream reader ...
1
vote
2answers
107 views

Find the smallest number Q whose product of digits is N

How do I make this efficient? ...
5
votes
2answers
207 views

Printing the n'th prime numbers

This is an online problem. The challenge is to print the kth prime number, for each k given in the input (1 ≤ k ≤ 15000). The first line of input indicates the number of inputs on the subsequent N ...
3
votes
1answer
58 views

Exotic bitmap renderer for core drawing functions

I am very interested in inventing the best way possible for rendering bitmaps on-screen using the base drawing functions (putpixel(x, y), ...
3
votes
2answers
45 views

A trivial command line utility for trimming whitespace from lines in C - follow-up 3

The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up 2 Now my code looks like: ...
6
votes
1answer
60 views

Ad hoc implementation of cruise control

I've written a small C program that has ad hoc implementation of cruise control for my Altera DE2 FPGA. It works alright but there are too many global variables. Preferably there should be no global ...
1
vote
2answers
60 views

Function to rotate bitmap image

Presenting you an implementation of the "shear and transpose" method of rotating a bitmap image. It works.. but it works slow, which is fully understandable. It is understandable due to the evident ...
8
votes
3answers
666 views

Find the next multiple of N that is a perfect square number

Given a number \$t\$, (\$1 \leq t \leq 1000\$) that represent testcases and \$t\$ numbers \$n\$ (\$1 \leq n \leq 10^9\$). Show the next multiple of \$n\$ that is a perfect square number. Example of ...
1
vote
1answer
47 views

A trivial command line utility for trimming whitespace from lines in C - follow-up 2

The previous iteration at A trivial command line utility for trimming whitespace from lines in C - follow-up Note: the next iteration at A trivial command line utility for trimming whitespace from ...
5
votes
1answer
45 views

Attempting a fluent API for creating random int arrays

I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: ...
3
votes
2answers
56 views

A trivial command line utility for trimming whitespace from lines in C - follow-up

See the previous iteration: A trivial command line utility for trimming whitespace from lines in C Note: see the next iteration at A trivial command line utility for trimming whitespace from lines in ...
3
votes
1answer
50 views

A trivial command line utility for trimming whitespace from lines in C

I was practicing some C and decided to write this simple command line utility for stripping leading and trailing white-space characters. Note: see the next iteration at A trivial command line utility ...
7
votes
1answer
163 views

Parsing equations from stdin

The program should read equations from stdin, parse them and generate a matrix of the coefficient which represents the system. Example: ...
2
votes
1answer
43 views

Mergesort using map-reduce, multithreads, buffers and condition variables

I wrote a map reduce program which uses multi threads, bounded buffers, condition variables. It works perfectly for some types of inputs. Is there any way I can improve it? Any help is appreciated! ...
5
votes
1answer
73 views

Strongly connected components, component graph, semiconnected graph and new graph from SCCs

I have written a program in C to do the following: Read a matrix (in file format, first line you have the size, then next are the entries). This is done by the "input" function. Find the strongly ...
5
votes
2answers
49 views

Bitmap-based Sieve of Erastothenes

I have written a simple implementation of Sieve of Erasthotenes (in C, MSVC flavour), which I believe is correct (source below). Is there a way to make it faster and more readable? ...
2
votes
1answer
40 views

Simple Linux pipeline

I've compiled a simple Linux pipeline and using my C style and modularization that I will use for my own operating system. Do you have something to say about this code (partly taken from SO)? For ...
3
votes
1answer
92 views

Calculating harmonic sum

The problem is that I have executed the program for the last hour and it hasn't returned a value till now for input 1022. How can I make the program a bit faster? How can I increase the efficiency of ...
5
votes
1answer
64 views

Encoding a string into base64

I'm trying to create a simple HTTP client. In order to make one that is standard compliant, I must be able to extract user information from a URI and convert it to base64 and send it via an ...
2
votes
1answer
50 views

Linked list library in C

I just finished my linked list library in C and I am trying to find out what should be improved. The functions provided by the library are members of the main data structure (very important). The ...
5
votes
1answer
68 views

Reading a matrix and computing the determinant

As one of my first C programs I want to read in a matrix and compute its determinant. I don't pose limits on the size of the matrix and this makes things more complicated. Version 0 ...
6
votes
4answers
147 views

Summarizing calories for a food diary

I'm new to C and I've been working on some code for a project for school. This was the finished result and now that I'm done it, I came back and tried making it better. So I was wondering, how would I ...
6
votes
1answer
407 views

Cutting The Sticks

Problem Statement This is a challenge from HackerRank: You are given N sticks, where each stick has the length of a positive integer. A cut operation is performed on the sticks such that all of ...
3
votes
1answer
92 views

C++/CLI wrapper around a C library

I have a C library written by a third-party company. It calculates photo positions on a book page, position of a photo inside an area (which part of the photo to crop), it fills a book with random ...
3
votes
2answers
74 views

Simple string hashing algorithm implementation

I thought of a simple way to hash a string. By taking the ASCII decimal value of each character, multiplying it by 10, and adding all of the values computed together for each character in a string. Is ...
7
votes
1answer
74 views

Simple C Port Scanner

I have been writing a Simple Port scanner in C, once I got it to work I decided I wanted to make it faster because it takes a very long time for it to get done with scanning all of the ports.Is there ...
3
votes
2answers
82 views

Generic dynamic array

Here is the interface of my generic dynamic array; ...
4
votes
0answers
43 views

Porting x86 assembly that is used to increment a value

I'm working on a port of some existing inline x86_64 assembly code to AArch64 compatible assembly and would appreciate the feedback. I'll post below the original x86 and my ported AArch64 code. The ...
2
votes
1answer
46 views

Kernighan & Ritchie - detabbing program

Task (1.20) Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Also, the condition is is not to use pointers and structs ...
1
vote
3answers
51 views

Print input one word per line

I'm doing K&R C Exercises. I could use a code review to see how I can improve my logic. The excercise is: Write a program that prints its input one word per line with ...
3
votes
1answer
64 views

Sort a linked list with merge sort in C

This is my version of a linked list in C. The function mergeSort requires a reference to the first and to the last nodes, as well as the indices of the first and ...
22
votes
7answers
3k views

Checking if a number is divisible by 9

I tried to develop a new way to check if a number is divisible by 9. I have written my code and it is working fine. I'm not allowed to use *,...
1
vote
0answers
34 views

Calculate median and quartile in C without sorting the array

Here's a piece of working code wrote in C to calculate the median without putting all values in an array and sorting them. It reads values from a file. ...
6
votes
2answers
93 views

Convert a 24bit bitmap to grayscale

I wrote this so I can learn CUDA. This is coded to work on my laptop's Nvidia GeForce GT 540M. Main points I need reviewed: CUDA programming conventions Performance, especially kernel speed C ...
1
vote
0answers
24 views

Reading diagram code for an unpacking state machine [closed]

I would like to ask if I have done my code right from diagram: ...