![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
Help Needed for Visual C++
I was given a task where i must use a 20-element single-subscripted integer array to read in 20 numbers between 10 and 100,inclusive. And as each number is input,print it only if it is not a duplicate of a number previously input.
I already work on this for 2 days but yet i can't get a good answer...can anyone help me out with this?urgent...i am kinda new to Visual C++ and programming...i would like to thank all of u here first...your help will be greatly appreciated. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#3 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 41,787
OS: Windows 7, XP-Pro, Vista, Linux
Blog Entries: 1
|
Well, it won't win any style contests, but I just wacked it out in about 10 minutes.
![]() Code:
#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE !FALSE
void main (void)
{
int numbers[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i,j;
int temp;
int match;
for (i = 0;i < 20;i++)
{
temp = 0;
while ((temp < 10) || (temp > 100))
{
printf("Enter a number (%i to go, 999 to quit: ",20-i);
scanf("%i", &temp);
if (temp > 998)
exit(0);
}
match = FALSE;
for (j=0;j < 20;j++)
{
if ((temp == numbers[j]) && (numbers[j] != 0))
{
match = TRUE;
break;
}
}
if (!match)
{
printf("A new number! : %i\n", temp);
numbers[i] = temp;
}
}
}
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
well john...although the output is not like what i expected...i really appreciate your help...u are great....thanks! I can't really understand the program coz maybe i am too noob...lolz! Anyway...hopefully i can learn more next time from here and from u all guys!
|
|
|
|
|
|
#5 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 41,787
OS: Windows 7, XP-Pro, Vista, Linux
Blog Entries: 1
|
Gee, I thought the program did what you specified.
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|
|
#8 (permalink) |
|
Manager, Networking Forums
Join Date: Sep 2002
Location: S.E. Pennsylvania, US
Posts: 41,787
OS: Windows 7, XP-Pro, Vista, Linux
Blog Entries: 1
|
Well, if you're going to be a professional programmer, my suggestion would be to stick with C/C++, it's the language of choice for major projects.
__________________
If TSF has helped you, Tell us about it! or Donate to help keep the site up! Microsoft MVP - Windows Desktop Experience |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Aug 2005
Posts: 18
OS: XP
|
thanks to u john...i will listen to your words and try to stick with C or C++. But i heard java programmers nowadays are highly demanded...isn't it?
Btw...i have another headache task again john...can u help me out with it?i posted it on a new thread....thanks a lot if u can. |
|
|
|
![]() |
| Thread Tools | |
|
|