Skip to main content

All Questions

Tagged with
1 vote
1 answer
61 views

How to correctly code to output the summation of all numbers in a given range of index (1 to N) for each query from a given array in C?

Problem: time limit per test: 1.5 seconds memory limit per test: 256 megabytes input: standard input output: standard output Given 2 numbers N and Q, an array A of N number and Q number of pairs L, ...
Didar004's user avatar
2 votes
2 answers
105 views

Variable in for loop not behaving as expected. [C17]

I'm trying to create a piece of code that would divide a set amount of money into their biggest bills constituents. Say, Input = 1200, then the code would print "[2]500 bills, [1]200 bills". ...
MMarqueto's user avatar
0 votes
3 answers
96 views

Assigning values to elements in an array in C (Beginner question)

#include <cs50.h> #include <stdio.h> #include <string.h> int main(void) { int n = get_int("input number: "); int array[8]; int counter = 0; for (int i = 0; ...
VidR's user avatar
  • 15
1 vote
1 answer
53 views

For loop doesnt iterate over all string characters? (BEGINNER QUESTION)

#include <cs50.h> #include <stdio.h> int count_letters(string text); int count_words(string text); int count_sentences(string text); int main(void) { string text = get_string("...
VidR's user avatar
  • 15
1 vote
3 answers
88 views

C: how to convert this code for an use with array?

Consider I'm still a newbie with C, so I made a lot of confusion. This code works fine int error(int a, int b, int c) { if (( a < 0 ) || (a > 255)) { printf("Number is over 255 or ...
elbarna's user avatar
  • 793
1 vote
3 answers
127 views

How to make this while loop finish on new line

#include <stdio.h> int main() { int lista[9999]; int a; int i = 0; while (scanf(" %d", &a) == 1) { lista[i] = a; i++; } return 0; } I ...
Wow1345's user avatar
  • 77
1 vote
1 answer
48 views

i am trying to get some sets of numbers let's say grades from the user. the code does not work since size gets changed to a random num in the loop

i am trying to get some sets of numbers let's say grades from the user. the code does not work since size gets changed to a random num in the loop. I dont understand why size gets a random value after ...
Danial Moghaddam's user avatar
-3 votes
1 answer
113 views

the array and loop program in c is working on one test case but not working on the other one

The software tool is a repository of files, often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, ...
Short's user avatar
  • 11
1 vote
0 answers
53 views

Why does the overflow of string's buffer result in the weird behavior in C? [duplicate]

I just started learning C programming language and was testing out some control flow, stdio functionalities. This is my code: #include <stdio.h> #include <string.h> int main(int argc, ...
Emiya's user avatar
  • 21
-1 votes
3 answers
209 views

Why does my do-while loop exit after one iteration?

Beginner programmer here: I am trying to format a do while loop to work in a way that if the user inputs an incorrect number outside the range of 0-4, then my program should ask the user to input a ...
Summer's user avatar
  • 25
-1 votes
2 answers
93 views

array index increments a[k] = val[i++];

Is this proper way of assigning values? int a[n], val[n]; int i = 0, k = 0; while (i < n && k < n) { a[k] = val[i++]; k++; } I am trying to ...
Dilip Kumar's user avatar
  • 1,746
-1 votes
3 answers
104 views

Review on code from CS50x Problem Set 4 "Filter More" (Grayscale and Blur functions)

description of tasks: https://cs50.harvard.edu/x/2023/psets/4/filter/more/ There are two problems: First one - I've made a function to GRAYSCALE a picture, but for some reason it doesn't round the ...
webmessiah's user avatar
1 vote
2 answers
96 views

I get weird extra letters behind my output in my terminal. Any clue why?

When I run my code (it is a code that replaces vowels (except u) with digits, it works but there is a bug where there are 2 extra characters at the end of the word if the word is beyond 9 or 10 ...
Boriscodes's user avatar
-1 votes
4 answers
240 views

Replacing spaces for TAB with (or without) arrays

I tried to follow some advice and started reading C programming language book. In the book there are several exercise and end of each chapter. I've just did the following exercise: Write a program ...
drain_'s user avatar
  • 53
0 votes
1 answer
132 views

How can i print the count number in first?

Harry Potter is worried about the recent outbreak of Dementor from the Prison of Azkaban. Every Dementor is marked with a specific number. Write a Program to Assist Harry identify all of the Dementor ...
Atik's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
46