Questions tagged [int]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
19 views

CS50 2018 Lecture 1C. Unable to figure out syntax error in code

My code : #include <stdio.h> #include <cs50.h> int get_positive_int(string prompt); int main(void) { int i = get_positive_int("Positive interegr: "); printf("%i\n", i); } int ...
0
votes
1answer
17 views

Why does my program only work on int numbers, not on float ones?

#include <cs50.h> #include <stdio.h> int main(void) { float change, quarter, dime, nickel, penny; int coins; do { change = get_float("Change: "); } while (change < ...
0
votes
1answer
129 views

Pset1 Cash - Trying to round float value DURING computation and not after

My original code for this problem is as follows: int main(void) { float c = 0; //total coins float $ = get_float("Change: "); while($ <= 0.0099999 && $ >= 0.00000001) { $ = ...
0
votes
1answer
47 views

CS50 pset 1 water negative integers

Below is my code for the pset 1, im not sure why but whenever i put negatives for the "Minutes" i get a negative "Bottles" rather than an error. Help would be appreciated. #include <cs50.h> #...
0
votes
2answers
119 views

pset1 - CS50 directory not found for ./integer. Keep getting bash error - help?

~/workspace/ $ cd pset1 ~/workspace/pset1/ $ ./integer bash: ./integer: No such file or directory
0
votes
1answer
56 views

Vigenere error compiling: type int vs unsigned long

I keep getting this error when trying to compile my vigenere code: error: format specifies type 'int' but the argument has type 'unsigned long' [-Werror,-Wformat] printf("%c", (((plain[j] - 'A' + 1) ...
0
votes
1answer
107 views

pset1 water get_int() problem

Whenever I introduce int get_int() I get an error message: error: initializer element is not a compile-time constant int x = get_int()I have tried permutations of get_int(0 that have been suggested ...
0
votes
1answer
368 views

What is const int?

Can anybody explain What is const int and How it works? It was used in the following code of the find.c The program is as follows: /** * Prompts user for as many as MAX values until EOF is reached, ...
0
votes
1answer
56 views

find.c in Pset 3; int straw = get_int(); ./generate 1000 50 | ./find 127; From where and how it takes 1000?

In the find.c there is the following code for (size = 0; size < MAX; size++) { // wait for hay until EOF printf("\nhaystack[%i] = ", size); int straw = get_int(); // ?...
0
votes
1answer
483 views

Convert String to an Int in Python CAESAR.PY

Please I need help. I dont know how to convert a String in an Int to complete the ASCII Formula in Python. (a = string[i] - 65) HERE IS A FRAGMENT OF MY CODE: for i in range(len(string)): if (...
0
votes
1answer
65 views

Int/Float Conversion

I fail to understand why C outputs a value of 0.000 instead of 0.625. Shouldn't it convert the result of a/b automatically to a float? If I instead write: float a,b; the output is 0.625. Can you tell ...
0
votes
1answer
57 views

difference between string, pointer, array and int

while it hasn't been something which really stopped me from learning, there is something which has been keeping me awake for the last few days... What is the difference between: #define x 5 int i; ...
1
vote
1answer
72 views

Why is int is of 4 bytes in CS 50?

While I was being taught C, it was said that the size of int datatype is 2 bytes. But in CS 50, I am being taught that it is of 4 bytes. Why is that so?
4
votes
1answer
1k views

return value of sizeof()

In 'absolute beginners guide to c' chapter 13 printf("The size of in is %d.\n", sizeof(int)); but clang throws... warning: format specifies type 'int' but the argument has type 'unsigned long' [-...
1
vote
1answer
66 views

In breakout, why use 12 char to store an int?

Here says: Why did we allocate an array of size 12 for our representation of that int as a string? No worries if the reason’s non-obvious, but give some though as to how wide the most positive (or ...
1
vote
1answer
85 views

Convert sold shares to an INT - PSET7

When I query my Database for the number of shares of some user, I get a strange value when converting this value to an int or a float. For instance, my query should return the value of "100" shares ...
4
votes
1answer
496 views

pset3 find INT_MAX

In find.c, there's a conditional that references a constant called "INT_MAX". I looked through all the pset files and couldn't find any reference to this constant. What is it, what does it represent,...
1
vote
1answer
40 views

How to Form a Single Integer from the Elements of an int Array?

Given an array of ints int arr[] = {2, 0, 1, 4}; and I want to manipulate them so that I get the value 2014 and store it in an int variable How can I do that?
0
votes
1answer
46 views

Getting wrong int with arrays

So, My problem here is that I am getting the wrong int from this array and I dont know why. Notice that: pacients.birth = 09/07/1997 in this case. Using GDB, thats what I have: Breakpoint 1, ident ()...