[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/23/2009 at 10:01AM PDT, ID: 24838601
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3

Guys can you teach me how to use malloc feature in my code..........

Asked by Sambho in C Programming Language, C++ Programming Language

Guys .....greetings...
         
                       My programme to find the prime number below 10000 is ready to go. But I want to use malloc function in my programme to create memory for 10,000 elements of the array.....So guys can you help me how can I do that........
                    Tons of thanks......
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
/* Finding Prime Numbers Using The Sieve Of Eratosthenes*/
 
#include<stdio.h>
#include <stdlib.h>     /* for the malloc() function and exit() function */
#include <assert.h>     /* for assert macro */
 
int main(int argc, char* argv[])
{
    FILE *fp;
    int num[10000], i, j; 
    
    if (argc != 2) {
 	  printf("Usage: SeiveErat.exe output.txt \n");
 	  exit(1);
    }
               
    fp = fopen(argv[1], "w+");
       
    for(i=1;i<=9999;i++)     
          num[i]=i+1;
     
     for(i=1;i<=9999;i++)
     {
          if(num[i]!=0)
          {
               for(j=(i+1);j<=9999;j++)
               {
                    if(num[j]!=0)
                    {
                         if((num[j]%num[i])==0)     /*check if num[j]*/ 
                         num[j]=0;                    /*is a multiple of num[i]*/
                                                       /*if it is a multiple then set it to 0*/
                    }
               }
          }
     }
 
     for(i=0;i<=9999;i++)
     {
          if(num[i]!=0)                   /*Print all prime numbers*/
               {
               //printf("\n%d",num[i]);
               fprintf(fp, "%d\r\n", num[i]);
               }
     }
      fclose(fp);
}
 
Keywords: Guys can you teach me how to use m…
 
Loading Advertisement...
 
[+][-]10/23/09 10:50 AM, ID: 25646690

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 10:51 AM, ID: 25646694

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 11:43 AM, ID: 25647154

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 11:56 AM, ID: 25647240

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 12:03 PM, ID: 25647307

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 01:14 PM, ID: 25648114

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 01:28 PM, ID: 25648250

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 02:16 PM, ID: 25648731

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 02:19 PM, ID: 25648769

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 03:42 PM, ID: 25649392

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 04:25 PM, ID: 25649739

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 04:31 PM, ID: 25649777

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 05:15 PM, ID: 25650037

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 05:50 PM, ID: 25650157

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 05:53 PM, ID: 25650166

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 06:49 PM, ID: 25650371

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 09:08 PM, ID: 25650740

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 09:28 PM, ID: 25650807

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 09:40 PM, ID: 25650841

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C Programming Language, C++ Programming Language
Sign Up Now!
Solution Provided By: Subrat2009
Participating Experts: 3
Solution Grade: A
 
 
[+][-]10/23/09 09:50 PM, ID: 25650862

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 10:10 PM, ID: 25650890

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/23/09 11:15 PM, ID: 25651035

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/24/09 07:38 PM, ID: 25655299

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625