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)
--
[m[1m>> [;33;40m¥x[1mÆW¬ì¤j¸ê¤u¨t ²M¬y[;33;40m¯¸[33m [;31;40m#[1m ntust.org [;31;40m#[m
[1m>> [;32;40mAu[1mthor from: 218-162-62-115.HINET-IP.hinet.net [m 8 5059
"Equilibrium" <ke*******@ntust.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
"Equilibrium" <ke*******@ntust.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)
-- [m[1m>> [;33;40m¥x[1mÆW¬ì¤j¸ê¤u¨t ²M¬y[;33;40m¯¸[33m
[;31;40m#[1m ntust.org [;31;40m#[m [1m>> [;32;40mAu[1mthor from: 218-162-62-115.HINET-IP.hinet.net [m
Just what the error message says: you didn't define your variables num1 and
num2. for example:
int num1, num2;
> --------------------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.
> 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.
> 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
On Mon, 13 Oct 2003 14:05:59 -0400, "Fronsac" <fr*************@hotmail.com>
wrote: "Equilibrium" <ke*******@ntust.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/
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:
"Equilibrium" <ke*******@ntust.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
"Fronsac" <fr*************@hotmail.com> wrote in message
news:kS********************@weber.videotron.net... 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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>...
|
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...
|
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...
|
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,...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |