Questions tagged [functions]

The tag has no usage guidance.

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

Pset 3 runoff. Votes not updating, trying to understand the code sequencing

Ok so im stuck on the tabulate funtion in runoff for pset3. The issue im having is that when i call to "printf" the candidates vote counts the votes still come out as 0. So i dont think the ...
0
votes
1answer
14 views

Week 2: valid_triangle function example — compiling [errors]

This goes to week 2: Functions mini lecture. We create a custom function for verifying whether we have a valid triangle by assessing it's 3 sides. I wanted to elaborate on the code. Since, this ...
0
votes
1answer
39 views

Why am I receiving a linker error on my function when it is defined in the file?

I'm in week 2 of cs50 and am currently working on the Readabilty problem. I've written a function named count_letters under main and have declared it at the top of the programm. However when I attempt ...
0
votes
1answer
22 views

CS50_Web ORMs,APIs_ lecture 4, classes4.py - Understanding Classes, Objects, Functions and Lists

I've "simplified" the ORMs,APIs- lecture 4_web_classes4.py code to try and understand more about Python classes, objects and list. can anyone help me out? Question 1: Why doesn't print(self....
0
votes
1answer
19 views

Adding a code block to perform operations on float

I am currently on PSET 1 Cash and have my program asking for the amount of change required, not accepting negative values and now I want to add a code block to start performing the operations on my ...
0
votes
1answer
19 views

What is the purpose of using anonymous functions within other functions?

What is the purpose of putting addMarketMethod() within an anonymous function in this example? function drop() { for (var i =0; i < markerArray.length; i++) { setTimeout(function() { ...
0
votes
1answer
31 views

Trying to use functions to modify pset2 Caesar characters, get error: expression result unused for each function

So I'm working on pset2's Caesar and wanted decided it would be better to put the algorithm into functions, with each function operating based on whether a character is uppercase or lowercase. Now ...
0
votes
1answer
70 views

How to get info from an asynchronous javascript function into html - help with callback function

For my final project, I am accessing an API, and I want to display data from that API in a web-page (the API provides data on forecast electricity generation from solar PV in the UK, it's provided by ...
1
vote
1answer
86 views

What should the return type of swap function be?

#include<stdio.h> #include<cs50.h> void swap(int x,int y); int main(void) { int x=get_int(),y=get_int(); printf("1=%i and 2=%i",x,y); swap(x,y); printf("1=%i and 2=%i",x,y); } void swap(...
0
votes
1answer
41 views

Pset3 Find - error in “helper” file - 'expected expression'

This is my code for the helper.c file. The code forms part of the 'find' program. I'm getting an error: 'expected expression' re: the last 'else' statement. I have tried removing the 'else' statement ...
0
votes
1answer
22 views

C : error non-void function search - value (find)

I'm getting error non-void function search should return a value. If I add anything else to last return, such as false 1 or zero, the errors multiply. I've tried moving the indentations as well as ...
0
votes
1answer
60 views

cs50 library in appliance

As I was attempting to run the 'adder' program from the week 1 lecture I realized that not only does my cs50ide not have any of the cs50 functions in it, my window doesn't look anything like the profs....
0
votes
2answers
827 views

strstr function not working

#include <stdio.h> #include<cs50.h> #include <string.h> char array[][80] = {"CS50", "C Programming", "Java", "Python", "PHP",}; void find(char search[]) { for (int i = 0; i ...
0
votes
1answer
156 views

Pset 2 Initials - Function Help

I've written a successful program to complete the Initials section of Pset2 without the use of any functions. However, seeing as I needed to copy/paste a good chunk of code in my program I've decided ...
0
votes
1answer
257 views

Why do we always use anonymous functions in javascript?

I don't understand why do we always use anonymous functions in javascript when we want to execute some code? I know it might sound like a weird question but I am used to C programming and even PHP is ...
1
vote
3answers
138 views

This code of triangle problem always give me “true”.I can,t find bug in this please find the bug

#include <cs50.h> #include <stdio.h> bool triangle (float a, float b, float c); //Declaration of function int main (void) { printf ("Give me three sides of ...
0
votes
2answers
196 views

pset1 water task, function code ignored

I'm trying to grasp the use of functions with the cs50 library to complete the pset1 water task. My code will outright ignore the function I've written, I think this is due to line 10, but what am I ...
0
votes
1answer
55 views

Problem from Section lesson “Function” but I have the following error message

When I compiled my code for the Section video titled, "Functions" where we were to make and define the function valid_triangle, the following error code was printed: triangle.c:15:9: error: expected ...
0
votes
1answer
105 views

Do I understand the code in functions-0.c correctly?

I have questions for lecture in week 2. In function-0.c file, I want to understand each line, so please fix me if I am wrong. // cs50 library is necessary to use GetString #include <cs50.h> // ...