Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6695823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:16:06+00:00 2026-05-26T06:16:06+00:00

I have a C array fftArray[64] that contains values that I want averaged and

  • 0

I have a C array fftArray[64] that contains values that I want averaged and placed into another array frequencyBar[8]. Getting the average of the entire array would be easy enough using a for statement.

int average, sum = 0;
for (i = 0; i < 64; i++)
{
     sum += fftArray[i];
}
average = sum/64;

But I just can’t seem to figure out how to get the average from fftArray[0] through fftArray[8] and store this in frequencyBar[0], the average of fftArray[9] through fftArray[16] and store this in frequencyBar[1], etc. Can anyone help me out with this? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:16:07+00:00Added an answer on May 26, 2026 at 6:16 am

    This looks like a homework assignment, so, rather than give you the outright answer, I’d rather just point you in the right direction…

    use a nested loop (one inside the other). One loop cycles 0-7, the other one 0 – 63. Use the smaller one to populate your sliced averages.

    or better yet use the % operator to see when you’ve gone through 8 elements and do an average of your total, then reset the total for the next set. Then you’ll have learned how to use the % operator too! 🙂

    [EDIT]
    ok, if not homework then something like this… I haven’t written C in 5 years, so treat this as pseudo code:

    //assuming you have a fftArray[64] with data, as per your question
    int i,sum,avCounter,total;
    int averages[8]; 
    for(i=0 , avCounter=0, total=0 ; i<64; ){
        total += fftArray[i];
        if(++i % 8 == 0){   //%gives you the remainder which will be 0 every 8th cycle
          averages[avCounter++] = total / 8
          total = 0;  //reset for next cycle
        }
    }
    

    I think this will work better than a nested loop… but I’m not sure since % is division which is more processor heavy than addition… however… I doubt anyone would notice 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array in following format. I want to convert it into another format
I have array that element is hash a = [{:history_date=>15/07/10}, {:open_price=>7.90}] I want to
I have array data as shown below, I want to store 'sale' value into
I have array and contains 50 values , example [ 'london', 'bluehit', 'green', 'lonpark',
I have array of image url. I want to show the images into UIImageView.
I have a two dimensional array that I need to load data into. I
I have an array of numbers that can be 1-24. ($timelist) I want to
Suppose I have array of points.I want to draw the route of that points
Imagine I have array of values ranging from 1 to 24. I want to
I have array values of up[]={0,0,0,0,0} and view=adult thesetwo value i want to store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.