 |
| 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
|
|
|

December 15th, 2003, 12:13 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|

December 16th, 2003, 10:30 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try asking a specific question about some code you have written.
|

December 30th, 2003, 03:51 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
|

January 2nd, 2004, 06:23 AM
|
|
|
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;
}
}
|

January 30th, 2004, 07:37 AM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
}
|
|

September 1st, 2006, 02:02 AM
|
|
Authorized User
|
|
Join Date: Mar 2006
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |