Thread: Array help
View Single Post
Old 10-26-2005, 07:07 AM   #1 (permalink)
SweetOne
Registered User
 
Join Date: Oct 2005
Posts: 6
SweetOne is on a distinguished road
Array help

Hey guys,

I need help with 2 programs. The first one compiles and runs but doesn't print the results. The code is below.
Code:
#include <stdio.h>

main()
{
  
  char month[12][4];
  int product[12];
  float sales[12];
  short i;

  
  for (i = 1; i <= 12; i++) {
    printf("\nEnter the month: ");
    scanf("%s",month[i-1]);

    printf("\nEnter number of products sold: ");
    scanf("%d", &product[i - 1]);
    printf("\nEnter sales: ");
    scanf("%.2f", &sales[i - 1]);
  } 

  return(0);
}
The second one I need a user to input 10 numbers and then show them a menu with 2 options, to sort in ascending or descending order. I really need help.

Code:
#include <stdio.h>
 
 int Number[10];
  int count;
 
main()
{


 for(count=1;count<11;count++)
{
   printf("Please enter a number: ");
   scanf("%d", &Number[count]);
   
}

  for (count=1;count<11;count++)
 {
thanks a bunch
SweetOne

Last edited by redhead; 10-26-2005 at 07:14 AM. Reason: added code tags
SweetOne is offline   Reply With Quote