tyronv's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
13 (0.03 per day)
Joined:
25-November 12
Profile Views:
136
Last Active:
User is offline Jan 27 2013 02:55 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   tyronv has not set their status

Posts I've Made

  1. In Topic: Lottery winner

    Posted 15 Dec 2012

    Thanks for all the help, however I just noticed that when I enter another winning number other than 77777 it returns sorry you are not a winner. Any suggestions why this is happening?
  2. In Topic: Dynamically allocate an array and find the mode.

    Posted 2 Dec 2012

    I tried this so far and am getting an error,

     
    #include <stdio.h>
    #include <stdlib.h>
    #include <malloc.h>
    int * getIntegers(int *);
    void displayIntegers(int *,int);
    void sortIntegers(int *integers, int size);
    int modeIntegers(int *integers, int size);
    int main()
    {
    	int i;
    	int *testIntegers = NULL;
    	int numberIntegers = 0;
    	int mode;
    	testIntegers = getIntegers(&numberIntegers);
    	sortIntegers(testIntegers, numberIntegers);
    	displayIntegers(testIntegers,numberIntegers);
    	printf("The average is: %d\n",mode);
    	fflush(stdout);
    	free (testIntegers);
    	system("pause");
    	return 0;
    }
    int *getIntegers(int *sizep)
    {
    	int i;
    	int *myArray;
    	int *iptr;
    	printf("How many Integers do you want? ");
    	fflush(stdout);
    	scanf(" %d",sizep);
    	myArray = calloc(*sizep , sizeof(int));
    	/* using array notation*/
    	for (i = 0; i < *sizep; i++)
    	{
    		printf("\tIntegers %d: ",i+1);
    		fflush(stdout);
    		scanf(" %d",&myArray[i]);
    	}
    	return myArray;
    }
    void displayIntegers(int *integers, int size)
    {
    	/* array */
    	int i;
    	for (i = 0; i < size; i++)
    		printf("%d\n",integers[i]);
    		fflush(stdout);
    	}
    void sortIntegers(int *integers, int size)
    {
    	/* Selection sort as an array */
    	int inner, outer, hold;
    	for (outer = 0; outer < size -1; outer++)
    		for (inner = outer + 1; inner < size; inner++)
    		{
    			if (integers[outer] > integers[inner])
    			{ // swap them
    				hold = integers[outer];
    				integers[outer] = integers[inner];
    				integers[inner] = hold;
    			}
    		}
    }
    int modeIntegers(int *integers, int size)
    
    {
    	 int run = 0;
    	 int run = 0;
    		int runTotal;
    		int mode;
    		int mode;
    	if (integers[i] == integers)
    		runTotal++;
    	if (run > runTotal)
    		return mode;
    }
    
    
    
  3. In Topic: Dynamically allocate an array and find the mode.

    Posted 2 Dec 2012

    but where will you loop it, can you proide a smaple code. Sorry I am totally lost om this
  4. In Topic: Dynamically allocate an array and find the mode.

    Posted 2 Dec 2012

    but where will you loop it, can you proide a smaple code. Sorry I am totally lost om this
  5. In Topic: Dynamically allocate an array and find the mode.

    Posted 2 Dec 2012

    View PostMomerath, on 02 December 2012 - 12:40 PM, said:

    That's C code, not C# code, wrong forum.

    And your problem statement isn't complete, what's the mode of:
    5 5 5 5 5 9 9 9 9 9?


    in that case it should list both numbers.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

tyronv hasn't added any friends yet.

Comments

tyronv has no profile comments yet. Why not say hello?