473,786 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I can't find the error

what did I wrong with the program ? (use VC++)

/* Using if statment, relational operators,
and equality operators */
#include<stdio. h>

int main()
{
printf("Enter two integers, and I will tell you\n");
printf("the relationships they satisfy: ");
scanf("%d%d", &num1, &num2);

if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);

if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);

if (num1 < num2)
printf("%d is less than %d\n", num1, num2);

if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);

if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);

if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);

return 0;
}

and there's build massage...
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
D:\C & c++\1\1.cpp(9) : error C2065: 'num1' : undeclared identifier
D:\C & c++\1\1.cpp(9) : error C2065: 'num2' : undeclared identifier
Error executing cl.exe.

1.exe - 2 error(s), 0 warning(s)

--
>> ¥xÆW¬ì¤j¸ê¤u¨t ²M¬y¯¸ # ntust.org #
>> Author from: 218-162-62-115.HINET-IP.hinet.net 
Nov 13 '05 #1
8 5087

"Equilibriu m" <ke*******@ntus t.org> wrote in message
news:48******** @ntust.org...
what did I wrong with the program ? (use VC++)

/* Using if statment, relational operators,
and equality operators */
#include<stdio. h>

int main()
{
int num1, num2;
printf("Enter two integers, and I will tell you\n");
printf("the relationships they satisfy: ");
scanf("%d%d", &num1, &num2);

if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);

if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);

if (num1 < num2)
printf("%d is less than %d\n", num1, num2);

if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);

if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);

if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);

return 0;
}

and there's build massage...
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
D:\C & c++\1\1.cpp(9) : error C2065: 'num1' : undeclared identifier
D:\C & c++\1\1.cpp(9) : error C2065: 'num2' : undeclared identifier
Error executing cl.exe.

1.exe - 2 error(s), 0 warning(s)


You need to declare num1 and num2 as ints where I have above.
HTH
Allan
Nov 13 '05 #2

"Equilibriu m" <ke*******@ntus t.org> wrote in message
news:48******** @ntust.org...
what did I wrong with the program ? (use VC++)

/* Using if statment, relational operators,
and equality operators */
#include<stdio. h>

int main()
{
printf("Enter two integers, and I will tell you\n");
printf("the relationships they satisfy: ");
scanf("%d%d", &num1, &num2);

if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);

if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);

if (num1 < num2)
printf("%d is less than %d\n", num1, num2);

if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);

if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);

if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);

return 0;
}

and there's build massage...
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
D:\C & c++\1\1.cpp(9) : error C2065: 'num1' : undeclared identifier
D:\C & c++\1\1.cpp(9) : error C2065: 'num2' : undeclared identifier
Error executing cl.exe.

1.exe - 2 error(s), 0 warning(s)

--
>> ¥xÆW¬ì¤j¸ê¤u¨t ²M¬y¯¸ # ntust.org # >> Author from: 218-162-62-115.HINET-IP.hinet.net 

Just what the error message says: you didn't define your variables num1 and
num2. for example:

int num1, num2;
Nov 13 '05 #3
> --------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
D:\C & c++\1\1.cpp(9) : error C2065: 'num1' : undeclared identifier
D:\C & c++\1\1.cpp(9) : error C2065: 'num2' : undeclared identifier
Error executing cl.exe.

1.exe - 2 error(s), 0 warning(s)


First, in C, you have to declare your variables. In this case, the first
thing you should put in your main function is this :
double num1, num2;

Considering you are asking this question, I suggest you buy a good book on
Amazon.com or at the local computer book store. You can go to the FAQ of
this forum to find names of good books. You can read it at :
http://www.eskimo.com/~scs/C-faq/top.html In it you'll find a section called
Tools and resource. Go over http://www.eskimo.com/~scs/C-faq/q18.10.html to
see what interresting books you can get.
Nov 13 '05 #4
> if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);
if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);
if (num1 < num2)
printf("%d is less than %d\n", num1, num2);
if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);
if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);
if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);


I almost forgot : Even though the tests you are doing are legitimate,
they're not always going to work. To learn more about this subject, I
suggest you hop over to the FAQ again :
http://www.eskimo.com/~scs/C-faq/s14.html . Floating point comparisons can
be tricky sometimes.
Nov 13 '05 #5
> First, in C, you have to declare your variables. In this case, the first
thing you should put in your main function is this :
double num1, num2;


This is the kind of stupid mistakes I do... The other poster is right, it's
int num1, num2;

As someone pointed out the other day, always make sure everybody agrees on
the subject when reading a newsgroup. :p
Nov 13 '05 #6
On Mon, 13 Oct 2003 14:05:59 -0400, "Fronsac" <fr************ *@hotmail.com>
wrote:
"Equilibriu m" <ke*******@ntus t.org> wrote in message D:\C & c++\1\1.cpp(9) : error C2065: 'num1' : undeclared identifier
D:\C & c++\1\1.cpp(9) : error C2065: 'num2' : undeclared identifier


First, in C, you have to declare your variables. In this case, the first
thing you should put in your main function is this :
double num1, num2;

scanf("%d%d", &num1, &num2);


Take another look at the OP's scanf format string. He's expecting ints,
not doubles.

That should be

int num1, num2;

--
Robert B. Clark (email ROT13'ed)
Visit ClarkWehyr Enterprises On-Line at http://www.3clarks.com/ClarkWehyr/
Nov 13 '05 #7
Fronsac wrote:
if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);
if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);
if (num1 < num2)
printf("%d is less than %d\n", num1, num2);
if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);
if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);
if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);
I almost forgot : Even though the tests you are doing are legitimate,
they're not always going to work. To learn more about this subject, I
suggest you hop over to the FAQ again :
http://www.eskimo.com/~scs/C-faq/s14.html . Floating point comparisons can
be tricky sometimes.


Yes, they *can* be tricky, but he is comparing integers. His tests are
fine.

Read the original post again:

"Equilibriu m" <ke*******@ntus t.org> wrote in message
news:48******** @ntust.org... what did I wrong with the program ? (use VC++)

/* Using if statment, relational operators,
and equality operators */
#include<stdio. h>

int main()
{
printf("Enter two integers, and I will tell you\n"); ^^^^^^^^ printf("the relationships they satisfy: ");
scanf("%d%d", &num1, &num2);

^^^^
[snip]

--
Tim Hagan
Nov 13 '05 #8
"Fronsac" <fr************ *@hotmail.com> wrote in message
news:kS******** ************@we ber.videotron.n et...
if (num1 == num2)
printf("%d is equal to %d\n", num1, num2);
if (num1 != num2)
printf("%d is not equal to %d\n", num1, num2);
if (num1 < num2)
printf("%d is less than %d\n", num1, num2);
if (num1 > num2)
printf("%d is greater than %d\n", num1, num2);
if (num1 <= num2)
printf("%d is less than or equal to %d\n", num1, num2);
if (num1 >= num2)
printf("%d is greater than or equal to %d\n", num1, num2);


I almost forgot : Even though the tests you are doing are legitimate,
they're not always going to work. To learn more about this subject, I
suggest you hop over to the FAQ again :
http://www.eskimo.com/~scs/C-faq/s14.html . Floating point comparisons can
be tricky sometimes.


What are you talking about? I don't see a single line of code that excepcts
any type of floating point value.
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2868
by: Andrei Ivanov | last post by:
Hello, it seems my postgresql data has somehow become corrupted (by a forced shutdown I think): psql template1 -U shadow Password: ERROR: nodeRead: did not find '}' at end of plan node Welcome to psql 7.3.4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms
14
2335
by: Stegano | last post by:
I am learning C Programming after working with Java for 5 years. I want to know where can I find the source files for C language itself. For example strcat is a function, which concatenates two strings. I want to read how this function is implemented in its native form, where can I find its corresponding .c file. I am using gcc version 3.3.1 (Thread model POSIX) on cygwin with Eclipse IDE. A grep on a function name lists many .h and .c...
6
6830
by: Robert Lawson | last post by:
I continue to get the below error message when trying to load a aspx file. Could someone please point me in the right direction for solving this? I'm trying to access an access data base and I'm the only one accessing it at this time. I'm trying to learn this step by step and I'm at the begining of ADO stuff. Server Error in '/' Application. ------------------------------------------------------------------------ --------
7
2861
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
54
3268
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in this NG to the effect that "...when you access a module programatically, there is a lines collection..." Have any of you experimented with your own procedures to aid in numbering lines? Would the lines collection be of some
7
17054
by: tehn.yit.chin | last post by:
I am trying to experiment <algorithm>'s find to search for an item in a vector of struct. My bit of test code is shown below. #include <iostream> #include <vector> #include <algorithm> #include <string> struct abc_struct {
14
7043
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
4
12443
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
1
4286
by: marcnz | last post by:
I have been charged of creating a coldfusion web site for our company. Our database has a ms sql 2005 backend and ms access frontend. Almost all tables are linked tables with the SQL database, except the temp tables needed at runtime that are in the ms access database. It will be easier for us to utilize the ms access queries and temp tables, so I set up a datasource on our web server and within the coldfusion administrator to point to the ms...
2
3877
by: Olumide | last post by:
Hello, I've got this nice inner class that I'm holds a set of "FrontPoint" objects as shown below. Unfortunately, the find and insert methods trigger massive C2784 errors. Would someone please point out what I'm doing wrong? Many thanks, - Olumide
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.