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 8838277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:57:02+00:00 2026-06-14T09:57:02+00:00

I need to use the ‘long long’ c type, to store data in a

  • 0

I need to use the ‘long long’ c type, to store data in a very large array. Since my code is large, I made up this fairly simple code which has the same problem. So, it iterates 222 times in the loop, and prints out when the loop reaches 50% (of storing values in the array) and 100% (when it’s finished).

But it always gives me errors, for example in this case 50 % of the array should print the index 222/2 = 111 and 100% should print out index 222. However it always prints 100 and 200.

This is the simple code I’m using a below are the results.

#include<stdio.h>
#define S 222
int main(void){
    char *text = calloc(S, sizeof(char));   
     unsigned long long i;
    for(i=0; i<=S; i++){
    text[i] = 'a';

    if(i == (S/100)*50)) {printf("50percent\t and index : %llud index should be 111" ,i );}
    if(i == ((S/100)*100)){printf("100percent\t and index : %llud index should be 222", i);}        
}
return 0;
}

So I was wondering, if I was doing something wrong or if there is a logic explanation to that problem.

Thank you.

  • 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-14T09:57:04+00:00Added an answer on June 14, 2026 at 9:57 am

    In integer arithmetic, 222/100 == 2.

    You could rework your comparisons to:

    if (i == S/2) /* 50% */
    if (i == S-1) /* 100% */
    

    instead.

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

Sidebar

Related Questions

I need use this code: <%= button_tag :class => btn btn-primary do %> <%=
I need use this method with three distinct classes: Orders, Customers, Suppliers public void
So, I need use this event so I can navigate trought blog posts. I
I need use join 2 table show all data. Exam Table Contact numCode |
I need use a progress bar with the pbstMarquee style, I read this question
I need use web services from a Samsung Smart TV app, but this services
I need to replace last word from input value Im using this code, Get_value
I have this code! <div class=time\54> <div class=time\98> <div class=time\69> <div id=result>{INFO}</div> I need
HI guys, There is an abc.jar under /tomcat_lib. I need use this in my
I need use this framework with IOS 4.3 Scheme, How can i do this?

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.