LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-20-2004, 09:55 AM   #1
huno
Member
 
Registered: May 2002
Distribution: Slackware 9.1
Posts: 161

Rep: Reputation: 30
so much errors (if statment )


hi people i have so much error with if statment
when i compile the following source
Code:
# include <stdio.h>
int main ()
{
    int c; 
    int d;
    printf (" enter the number do you like \n ");
    scanf ("%d%d",&c,&d);
    if ( c == d ) {
	printf (" equal");
    }
    If ( c < d ) {
	printf (" not the same numbers \n");
    }
    if ( c > d) {
	printf (" not the same numbers \n");
    }
    if ( c! = d) {
	printf (" huh what are you typing \n");
    }
return 0;
}
it show this errors

if.cpp: In function `int main()':
if.cpp:5: error: syntax error before `int'
if.cpp:7: error: `d' undeclared (first use this function)
if.cpp:7: error: (Each undeclared identifier is reported only once for each function it appears in.)
if.cpp:11: error: `If' undeclared (first use this function)
if.cpp:11: error: syntax error before `{' token

what should do i ?
 
Old 07-20-2004, 09:59 AM   #2
alitrix
Member
 
Registered: Jun 2003
Location: Netherlands, The
Distribution: Ubuntu, Kernel 2.6.7
Posts: 169

Rep: Reputation: 30
Re: so much errors (if statment )

Try to use this:

Code:
# include <stdio.h>
int main ()
{
    int c,d; 
    printf (" enter the number do you like \n ");
    scanf ("%d %d",&c,&d);
    if ( c == d ) {
	printf (" equal");
    }
    if ( c < d || c > d ) {
	printf (" not the same numbers \n");
    }
    if ( c != d) {
	printf (" huh what are you typing \n");
    }
return 0;
}
 
Old 07-20-2004, 10:11 AM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Try using gcc instead of g++ to compile it. Also, one of your if() statements starts with a capital i.
 
Old 07-20-2004, 10:12 AM   #4
huno
Member
 
Registered: May 2002
Distribution: Slackware 9.1
Posts: 161

Original Poster
Rep: Reputation: 30
what's the mistakes i did ?

thanks
 
Old 07-20-2004, 10:18 AM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
First you need to rename the file to .c (mv if.cpp if.c) and then to compile it type: gcc -Wall foo.c -o foo

But before that will succeed you need to change that If to if.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using 'echo' in a system statment in php evilchild Programming 3 09-23-2004 02:27 PM
PHP If statment agallant Programming 3 07-04-2004 09:02 AM
not able to run mysql statment Robin01 Linux - General 1 03-19-2004 07:03 PM
Errors during filesystem check with one kernel while no errors with other kernel Potentials Linux - General 11 12-30-2003 04:24 AM
QMAIL errors errors.. YourForum Linux - Software 0 11-27-2003 12:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration