473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Program2

The output of the following program confuses me

void main()
{
int x=10,y=20,z=5,i;
i=x<y<z;
printf("i=%d\n",i);
}

Nov 15 '05 #1
6 1183
Maw
y<z is 0
x<0 is 1
i=x

Nov 15 '05 #2
Maw
*the other way*

Nov 15 '05 #3


Meenu wrote:
The output of the following program confuses me

void main() This is wrong. Use
int main(void)
{
int x=10,y=20,z=5,i;
i=x<y<z;
printf("i=%d\n",i);
}


i=x<y<z is equivalent to
i = ((x<y)<z); <--- x<y is True
i = ( 1 < z) <--- 1<y is True.
i = 1

Nov 15 '05 #4
Maw wrote:

y<z is 0
x<0 is 1
i=x


That's nice. On what do you base that assertion? See below.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 15 '05 #5
Meenu wrote:
The output of the following program confuses me
[1]
void main()
{
int x=10,y=20,z=5,i;
i=x<y<z;
printf("i=%d\n",i);
}

In both this and your other posting

[2]
main()
{
char str[]="part-time musicians are semiconductors";
int a=5;
printf(a>10?"%50s":"%s",str);
}


You are missing needed headers, since printf is a variadic function.
#include <stdio.h>

The 'void' return type for main() in [1] is wrong. main returns an int.
In [2], your main does return an int implicitly in C89 (or C90), where a
function that has no named returned type is assumed to return an int.
However, (a) implicit int is removed from the current standard, so [2]
is wrong under the current standard. Further, in C89 (and C90) in which
implicit int is allowed, main() should explicitly return a value.

In [2], there is no way to predict the output. To have a portable C
program, the last line of output to a stream must end in an end-of-line
('\n') character.

Now tell me that you're a troll and that I took the bait.
Nov 15 '05 #6
"Maw" <ma******@gmail.com> writes:
*the other way*


You've posted twice on this thread without providing any context or
attributions. I have no idea what you mean by "the other way".

The broken groups.google.com interface is partly responsible for this,
but only partly. It *is* possible to use groups.google.com properly.

The following has been posted here hundreds of times. Read it. Pay
attention to it.

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #7

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

Similar topics

0
by: Laguna | last post by:
Hi, With py2exe-0.3.3 for Python 2.2 in Windows XP, how to configure setup.py such that multiple executables can share the dll files (like wx*.dll etc.) as follows: # Source folders...
11
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >>...
2
by: flupke | last post by:
Hi, i have a program with is built like this: startup.py dir1/__init__.py dir1/file1.py dir2/__init__.py dir2/file2.py dir3/__init__.py dir3/file3.py
2
by: Osvaldo Bisignano | last post by:
Program1.exe and Program2.exe reference Library.dll, which only contains a class with static methods and properties. Modifying a value of Library.dll from Program1.exe, will change when I read...
0
Q
by: Giedrius | last post by:
Hello, I was reading about different Message Oriented Middleware vendors and their products, but it is difficult to decide which one is best for my requirements. There are 2 programs (i.e....
13
by: vashwath | last post by:
Hi all, To test the return value of system I wrote 2 programs which are shown below. Program 1: #include <stdio.h> #include <stdlib.h> int main(void)
21
by: Chen Shusheng | last post by:
Hello, I have a small piece of code that I want to directly assign a segment of memory to a pointer. But complier tell me wrong. Pls you help.Codes below: ------------------ int * p;...
5
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I use vb.net 2005 Lets say I have the handle number of a progress bar from program1.exe Can I change the value of the progress bar from program2.exe using this handle number? TIA Guy...
5
by: M.Liang Liu | last post by:
I have a project with the following dirs: --------------------------------------------------------------------------------------- +src |-proj0 |-program1 |-program2 |-proj1 |-program1...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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...
0
isladogs
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...

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.