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

  • Home
  • SEARCH
  • 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 8600583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:38:58+00:00 2026-06-12T01:38:58+00:00

I was trying out the time -p command on Linux and I wrote some

  • 0

I was trying out the time -p command on Linux and I wrote some code to waste CPU cycles:

#include <iostream>

using namespace std;

int main() {
 long int c;

 long int ss;

 for(c = 0;c < 10000000;c++) {
  ss += c*c;
 }

 cout<<ss<<endl;

 return 0;
}

I noticed something funny after running it a few times, however:

me@octopus:~/Desktop> ./test
1292030741067648912
me@octopus:~/Desktop> ./test
1292030742538841328
me@octopus:~/Desktop> ./test
1292030742228685600
me@octopus:~/Desktop> ./test
1292030740402651312
me@octopus:~/Desktop> ./test
1292030740207543344
me@octopus:~/Desktop> ./test
1292030740346553856
me@octopus:~/Desktop> ./test
1292030741629275040
me@octopus:~/Desktop> ./test
1292030740397307072
me@octopus:~/Desktop> ./test
1292030742928964784
me@octopus:~/Desktop> ./test
1292030741780094096

Not only did I not get the same number every time, as I would expect, I didn’t get the same number even once. What is going on here?

  • 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-06-12T01:38:59+00:00Added an answer on June 12, 2026 at 1:38 am

    You have not initialized ss to zero therefore its initial value is undefined. You need:

    long int ss = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm trying out MVC after only playing with it some time ago. Need
I spent some time trying to figure out why this query isn't pulling the
I am trying to figure out some way to get actual time via JavaScript,
I'm trying to figure this out on and off for some time now. I
I'm trying to find out the time between certain fields in my tables. However
I'm trying out the zend framework classes for the first time. I am interested
I'm trying out Spring MVC 3.0 for the first time and like to make
So I'm trying out this new TDD thing (about time haha). Anyways I have
I am trying to figure out something - Every time I use AVAudioPlayer I
i m trying to find out how to convert timestamp date and time (

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.