• 100% Satisfaction Guarantee
LogicPro, Engineer
Category: Homework
Satisfied Customers: 12937
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
29751445
LogicPro is online now

# QUESTION 1You are given a table that shows the total number

QUESTION 1

You are given a table that shows the total number of cars sold by a local car distributor in Johor Bharu for the first six months in 2008.

Month Jan Feb Mar Apr May Jun
Number of cars sold 191 196 269 308 236 145

Based on the table given above, you are required to write a C program using array to store all the information given above, determine and display the sum of all the odd numbers in the array.

(20 marks)

Anda diberikan jadual yang menunjukkan jumlah jualan kereta bagi sebuah pengedar kereta tempatan di Johor Bharu dalam tempoh enam bulan yang pertama bagi tahun 2008.

Bulan Jan Feb Mar Apr May Jun
Bilangan kereta yang dijual 191 196 269 308 236 145

Berdasarkan jadual yang diberikan di atas, anda dikehendaki untuk menulis aturcara C dengan menggunakan tatasusunan untuk menyimpan semua maklumat di atas, menentukan dan memaparkan jumlah kesemua nombor ganjil dalam tatasusunan berkenaan.

QUESTION 2

By using linked list, Write a complete C program that accepts few integers, traverses it, and returns the data in the linked list that has the smallest value. Then, write a function to reverse the data that already exists in the linked list.

The Createlist(), NewNode(), InsertNode() and TraverseList() functions that you may use in your solution are elaborated in the module.

Sample output:
Enter integers: 23 12 34 56 78 12
Traversing the list : 23->12->34->56>78->12
Minimum value : 12
Reversing the list: 12->78->56->34->12->23

(40 marks)
(Total: 60 marks)
Hi,
Welcome here.
Customer: replied 3 years ago.

Customer: replied 3 years ago.

ok.thank you

Welcome

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.

It will ensure that question is for me.

so you can come back and ask me a question anytime.

Remember, if you need anything else, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions at no extra charge and I’m always here to help.

Thank you for using this site!

Customer: replied 3 years ago.

can u give some explanation of the two scenario in word please bcoz i have to present this assignment in front of tutor and i will be some questions on how i did this assignment

Customer: replied 3 years ago.

sir in question 1 you have to display the month for the odd number of car sold then only sum it.

example:

Month Jan Mar Jun
Number of cars sold(Odd) 191 269 145

then only display sum of all the odd numbers in the array.

Customer: replied 3 years ago.

sir i want to ask char months [6] explain the months

[20] explain what?

In C, to declare string, you need to take char array. To store more than one strings, you need to take array of strings. It means array of char arrays

so months[ 6 ][ 20 ] means, 6 strings of 20 characters

Hi again,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
so you can come back and ask me a question anytime.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro
Hi again,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
so you can come back and ask me a question anytime.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro
Customer: replied 3 years ago.

sir can i ask few questions regarding the assignment u have done for me

let me know the question.
Customer: replied 3 years ago.

include<stdio.h>

typedef struct Node

{

int data;

struct Node *next;

}node;

void insert(node *pointer, int data)

{

/* Iterate through the list till we encounter the last node.*/

while(pointer->next!=NULL)

{

pointer = pointer -> next;

}

/* Allocate memory for the new node and put data in it.*/

pointer->next = (node *)malloc(sizeof(node));

pointer = pointer->next;

pointer->data = data;

pointer->next = NULL;

}

void TraverseList(node *pointer)

{

int x=0;

while(pointer!=NULL)

{

if (x == 1)

{

printf(" --> %d ",pointer->data);

}

else

{

printf("%d ",pointer->data);

x=1;

}

pointer=pointer->next;

}

}

int GetSmallestValue(node *pointer)

{

int smallest = 9999999;

while(pointer!=NULL)

{

if (smallest>pointer->data)

smallest = pointer->data;

pointer = pointer -> next;

}

return smallest;

}

node * ReverseList(node *ptr)

{

node * temp;

node * previous = NULL;

while(ptr != NULL) {

temp = ptr->next;

ptr->next = previous;

previous = ptr;

ptr = temp;

}

return previous;

/// ptr = previous;

}

int main()

{

int num;

node *start,*temp;

start = (node *)malloc(sizeof(node));

temp = start;

temp -> next = NULL;

scanf("%d", &num);

while (num!=-1)

{

insert(start,num);

scanf("%d", &num);

}

printf("Traversing the list: ");

TraverseList(start->next);

printf("\nMinimum value : %d", GetSmallestValue(start->next));

printf("\n");

start->next = ReverseList(start->next);

printf("Reversing the list: ");

TraverseList(start->next);

return 0;

}

in the coding above whats the meaning of i) typedef struct node ,

ii) whats the meaning of temp

iii) why the reverse list got node and not data type like int , get smallest value and etc.

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

is struct Node *next ------->refers to new node izzit.

what is the difference between struct Node and node

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

do u mean the usage of capital N in Node is the same as smaller n in node ah

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

typedef struct Node

{

int data;

struct Node *next;

}node; <------------ why there is a node after the struct has been closed

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

void TraverseList(node *pointer)

{

int x=0;

while(pointer!=NULL)

{

if (x == 1)

{

printf(" --> %d ",pointer->data);

}

else

{

printf("%d ",pointer->data);

x=1;

}

pointer=pointer->next;

}

}

whats the meaning of the above statement sir

My apologies but such type of tutoring is not possible in QA mode. I can provide you only code here.
If you have some other questions, you can post a new question using "For LogicPro only", I will be happy to help you.
Thank you.
Customer: replied 3 years ago.

but sir this is the same assignment you did for me and for certain part you didn't write any comment thats why i feel difficult to understand..i have presentation tomorrow so pls help me.

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
Customer: replied 3 years ago.

void TraverseList(node *pointer)

{

int x=0; ------------------> whats the meaning of this statement sir

while(pointer!=NULL)

{

if (x == 1) ------------------> whats the meaning of this statement sir

{

printf(" --> %d ",pointer->data);

}

else

{

printf("%d ",pointer->data);

x=1; ------------------> whats the meaning of this statement sir

}

pointer=pointer->next;

}

}

i have asked question based on the code..pls refer to the bold and underline words.thnk u.