Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 15th, 2003, 12:13 AM
Registered User
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help on C Array

How do I make a program which displays each month of a year in array and let user input a value? and make a bar graph from it? It's actually a Sales Report for the year "user input"!
Can anyone please show me/

Thanks in advance!

Reply With Quote
  #2 (permalink)  
Old December 16th, 2003, 10:30 PM
Authorized User
 
Join Date: Jul 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try asking a specific question about some code you have written.

Reply With Quote
  #3 (permalink)  
Old December 30th, 2003, 03:51 AM
Authorized User
 
Join Date: Oct 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a rough idea of what i pick from your request, hope i'm on point.

char array[]={"Jan","Feb","Mar"......"Dec"};
 main()
 {
  int num;
   printf("Enter any number");
    scanf("%d",&num);
     for(int i=0;i<12;++i)
       {
         if(num=array[i])
            {
              printf("%c",array[i]);
            }
        }
  return 0;
 }

Reply With Quote
  #4 (permalink)  
Old January 2nd, 2004, 06:23 AM
ÕÅÃÍ
Guest
 
Posts: n/a
Default

I have just learned c for one term! hope it is right!

#include<stdio.h>

void main()
{
   int num;
   char season[]={"Jan","Feb","Mar",......"Dec"};

   printf("Input your number:");
   scanf("%d",&num);

   for(int i=1;i<=12;i++)
       if(num==i) {
         printf("%c",season[i-1]);
         break;
        }
}


Reply With Quote
  #5 (permalink)  
Old January 30th, 2004, 07:37 AM
Authorized User
 
Join Date: Jan 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ankur_vachhani
Default

Quote:
quote:
for string array you have to take two dimensional char array the above code will not work.

        Follow this , it will work.


#include<stdio.h>

void main()
{
   int num;
   char season[][]={"Jan","Feb","Mar",......"Dec"};

   printf("Input your number:");
   scanf("%d",&num);

   for(int i=1;i<=12;i++)
       if(num==i) {
         printf("%s",season[i-1]);
         break;
        }
}




Reply With Quote
  #6 (permalink)  
Old September 1st, 2006, 02:02 AM
Authorized User
 
Join Date: Mar 2006
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Char gred[2][2]

if ((total >= 0) && (total <= 5))
gred[i] = "A";
printf(" Gred = %s", gred[i]);
else
if ((total >= 6) && (total <= 10))
gred[i] = "A-"
printf("Gred = %s", gred[i]);
else
if ((total >= 11) && (total <= 15))
gred[i] = "B+"
printf("Gred = %s", gred[i]);

Did my coding correct......can somebody show me....how to put a char value in my array using nested if.

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Array to Array comparison pavel Pro VB 6 0 March 24th, 2004 06:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.