Ask for help in C language

Hello there!

**I’m looking for help in this task. I’ve got it and it has to be done last week but I’ve tried everything (as I know) but it did not help, so if you can solve it, I’ll be very grateful for it.

This is the task:

In this task, the student shall complete the missing function. There is a half-finished program with a function for the output of information to be created.

An example of formatting printing:

ID: 1300 - Terrace Drive 1555
SalesRep: John Camembert
Promised Intrest Rate: 3.51

Only items that are not sold (object-> sold == 0) are to be printed.

And here is the program:

#include <stdio.h>
#include <stdlib.h>

struct sales
int object_id;
char name[64];
char sales_rep[64];
double given_intrest_rate;
uint8_t sold;

struct sales houses[] =
{1298, “Terrace Drive 1223”, “Gwendolyn Toth”, 3.44, 0},
{1299, “Fourth Road 1223”, “Gwendolyn Toth”, 3.31, 1},
{1300, “Terrace Drive 1555”, “John Camembert”, 3.51, 0},
{1301, “Centric Lane 2388”, “John Camembert”, 3.48, 1},
{1302, “Centric Lane 1998”, “John Camembert”, 3.63, 1},
{1303, “Outroff Road 1116”, “Gwendolyn Toth”, 3.37, 0},
{1305, “Suffork Ranch”, “Steven Crown”, 3.61, 1},
{1306, “Fourth Road 1123”, “Steven Crown”, 3.62, 1},
{1307, “Terrace Drive 1955”, “Steven Crown”, 3.37, 0},

void print_all_objects_not_sold(struct sales* objects)

          Enter your code here


int main()

return 0;

Thanks in advance Smiley Happy

I have not done C for a few years, but the basic idea is:

 for (i = 10; i < 10; i++) {
	if (houses[i] != NULL) {
		if (sold.houses[i] == 0) {
			printf("\nID: %d - %d", object_id.houses[i], name.houses[i]);
			printf("SalesRep: %d", sales_rep.houses[i]);
			printf("Promised Interest Rate: %d", given_intrest_rate.houses[i]);

The first for loop iterates through 10 numbers, as that’s how many listings you have (including null). The if statement checks if the current listing contains NULL value, and then the 2nd if statement checks if the house is sold or not, followed by printing the output.

The code above is just to give you an idea/understanding, I’m sure there are easier ways of doing this and I did not test the code (it may not work at all!). So you may have to debug it,

1 Like

void print_all_objects_not_sold(struct sales* objects)
if (objects == NULL) { return; }

int i = 0;
 while ( objects[i].object_id != NULL ) {
	if (objects[i].sold == 0) {
		printf("ID: %d - %s\n", objects[i].object_id, objects[i].name);
		printf("SalesRep: %s\n", objects[i].sales_rep);
		printf("Promised Interest Rate: %4.2f\n\n", objects[i].given_intrest_rate);


1 Like

Hello @SakshamInABox !

I just want thank you for your time.
Its really basic but i am a beginner in programming languages in general and in c In particular but its really helped me and gave me how to start.

Thank you a lot @vcubells

hello there,
can some one help me with a c program for this formula rs=1−(6𝛴ⅆ^2)/𝑛(𝑛^2(−1))

Hi, I usually use this website for programming help They’re great in explaining things and solving any kind of programming or math riddles.