your questions are too difficult a starting point. Try the basic stuff first and work up to arrays and such.
I see it says C program, so the c++ tutorial will not be 100% accurate if you meant that.
consider its buddy site: https://www.learn-c.org/
also, don't pay for help. The rates will be high, the code will probably be too advanced to learn from, and you won't get anywhere that way. Either sit down, roll up your sleeves and get to it or put it down as something you don't want to do.
#include <stdio.h>
#include <stdlib.h>
#define N 7
int main()
{
int demo_values[N] = {44, 75 ,56, 38, 83,10, 37};
// a. calculate and print the sum of all values in the array
int sum_all = 0;
for (int i = 0; i < N; ++i)
sum_all += demo_values[i];
printf("The sum of all values: %d", sum_all);
// b. calculate and print the sum and average of all even numbers
// c. calculate and print the sum of values whose index is an odd number
return EXIT_SUCCESS;
}
1. Define an array.
2. Distinguish between a regular variable and an array.
3. The ages of 10 students are to be collected. Write a pseudocode program to do the following:
a. Accept and store the ages into an array called stu_ages
b. Find and print the sum of odd ages and the average of the ages in the
array stu_ages
c. Find and print the average of the even ages in the array stu_ages
This is good information, but rearrange it like this:
0. The ages of 10 students are to be collected. // <--- Informational for now. Just keep this in your head.
1. Write a pseudocode program to do the following :
2. Define an array.
3. Distinguish between a regular variable and an array.
a.Accept and store the ages into an array called stu_ages
1. Print the array.
// <--- Work on these after you get a. 1. working.
b.Find and print the sum of odd ages and the average of the ages in the
array stu_ages
c.Find and print the average of the even ages in the array stu_ages
Think about what the program will need to do and write the pseudo-code of what the program needs to do in in what order. PLAN your program then program you PLAN.
The instructions are numbered for a reason. Like jonnin mentioned start with the easy parts first. As an idea: Start by asking the user for input. Work out the code then compile and test often until you get what you want.
When you can get the information entered into the array then print it out for now. You can adjust how it prints out later.
pseudocode means different things to different people. Some professors define a full language for it, which defeats its purpose in my book, and others just want english words that sort of look like code (much better).
Wikipedia has pseudocode for many common algorithms:
# Sort an array a[0...n-1].
gaps = [701, 301, 132, 57, 23, 10, 4, 1]
# Start with the largest gap and work down to a gap of 1
foreach (gap in gaps)
{
# Do a gapped insertion sort for this gap size.
# The first gap elements a[0..gap-1] are already in gapped order
# keep adding one more element until the entire array is gap sorted
for (i = gap; i < n; i += 1)
{
# add a[i] to the elements that have been gap sorted
# save a[i] in temp and make a hole at position i
temp = a[i]
# shift earlier gap-sorted elements up until the correct location for a[i] is found
for (j = i; j >= gap and a[j - gap] > temp; j -= gap)
{
a[j] = a[j - gap]
}
# put temp (the original a[i]) in its correct location
a[j] = temp
}
}
So their brand of pcode looks a lot like C/c++ 98 while using # for comments
the 2 things that make pcode work are 1) good comments and 2) use something close enough to a real language that most computer programmers will 'get' what you said.