0

Hi i am a begginer in learning computer science and i received a assignment question on arrays.

The question asks me to split the characterArray= joe,487 into two seperate variables, one is a variable called idArray where the numbers 487 will go, then i have to have three spaces for the comma and then the final variable is nameArray which the name joe should go.
my problem is that i do not know how to write this into a pseudocode algorithm.

any help would be greatly apreciated?

Edited by pritaeas: Moved.

5
Contributors
6
Replies
36
Views
3 Years
Discussion Span
Last Post by nouth
0

I can not understand what you are after, this does not sound like problem of finding the correct algorithm for problem, it sounds more like you already have the pseudo code algorithm given to you.

0

All that is give to me is the array joe,487 in blocks and i have to write a solution algorithm that splits the joe away from 487.
And then i have to print the idArray and nameArray .

0

So you must write algorithm to separate the letters 'joe,' from letters '487'? It does look awfully implementation oriented to really be pseudocode.

Edited by pyTony

0

suppose you wanted to find ',' in the array "hello,all"

so the pseudocode would be :-

foreach char c in array
    if c = ","
        print "found you"

you can use this template to solve your question

-1

I,can not understand you but you need to
jeo,487' block and logrithem folow I give you wen example how to use arry

// to accept a list of numbers int a 1-d array, find their sum and average and display them.
#include <iostream.h>
int main()
{
    int a[10], i, n, sum;
    float avg;
        cout<<"Enter no of Elements [1-10] \n";
        cin>>n;
        cout<<"Enter "<<n<<"numbers \n";
        for (i=0; i<n; i++)
             cin>>a[i];
             // finding the sum and average begins
         sum=0;
         for (i=0; i<n; i++)
         sum=sum+a[i];
         avg=(float)sum/n;

         // finding the sum and average ends

         cout<<"the sum is "<<sum<<endl;
         cout<<"the average is "<<avg<<endl;
return 0;
}
0

a is declared to be an array of int type and of size 10. A maximum of 10 numbers can be written into the array.
The variables n, i and sum are declared to be variables of int type where n is to collect the number of values to be read into the array a, which lies within 1 and 10, i is to traverse all of the values in a, and sum is to collect the sum of the values in a.
The variable avg is declared to be a variable of float type and it is to collect the average of values in a.

In the process of finding the sum of all of the n values, initially sum is set to 0. A for loop is used to select each number in the array and it is added to sum with the statement sum=sum+a[i].
The statement avg=(float)sum/n; on its execution, assigns the average value to avg. Note that you have used type-casting to convert sum forcibly to float to get the exact result. Otherwise, the expression sum/n produces only integral part of the quotient since both sum and n are integers. Both sum and avg are then displayed.

http://www.cplusplus.com/doc/tutorial/arrays/

Edited by nouth

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.