C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 29th, 2012, 07:46 AM
feeltheburn feeltheburn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 feeltheburn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 10 sec
Reputation Power: 0
All input appreciated

Hello, I've been studying C language for a week and it is my 1st language - so I'm a total newbee. Anyhow, I went through some of the basic commands and deicded to make a little program that is going to help me in my work. Here is the gist of the program:

I would want to put 2 arreys of values, have them compare each other and then have the program printf the values that don't match- eg if one of the arreys has a value that the other one doesn't contain.

(I have also read somewhere how to make a .txt file in which the values can be written, but I guess there is no need to over-complicate things at first, just having a functional program is enough)


#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main()
{

int base1[]= {1,2,3,4};

int base2[]= {1,2,3,4,5,6,7,8,9};

int x;
int y;

x = 0;
y = 0;

(x = 0, x <4 , x++);

if ( base1[x]!= base2[y])
{(y < 9, y++);}

if ( base1[x] = base2[y])
{printf("\n.\n");}

if (y = 9)
{printf ("the number "base1[x]" has no match");}

return 0;

system("PAUSE");

}

Beside several warnings, the debbuger pops out this error as well
'expected ')' before base1' on line 31.

All help appreciated, thank you

Reply With Quote
  #2  
Old December 29th, 2012, 09:07 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,390 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 15 h 35 sec
Reputation Power: 383
In other words, you want the union of the two sets "minus" the intersection of the sets. (set difference of the union and intersection).

Your printf function needs a format specifier, like this:

printf ("the number %d has no match",base1[x]);


You have another construct that looks as if you intended a for statement but forgot to write `for'.

(x = 0, x <4 , x++);

You'll need to replace the semi-colon at the end of the line with brace to make a block statement including the code you want in the for loop.


Perhaps you'd rather learn executable Iverson notation rather than c?
Code:
   1 2 3 4 (union less intersect) 1 2 3 4 5 6 7 8 9
5 6 7 8 9
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old December 30th, 2012, 05:08 AM
feeltheburn feeltheburn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 feeltheburn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 10 sec
Reputation Power: 0
Hello and thank you for your time.

I have made the changes you suggested and it has eliminated all but 1 error. I will try and figure it out on my own and if I can't, it just means I'm not ready to make the project at this point and time.

As for looking into other languages, my current focus is more on getting a solid understanding of C, then on making any one specific program.


Once again, thank you for the input and the suggestions.

Cheers

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > All input appreciated

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap