473,406 Members | 2,404 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,406 software developers and data experts.

give me explanation for this statement

i am beginner and i am currently learing c and can u please help my explaing the meaning how it will execute of the following statement
printf ("%d\n",'-'-'-'-'/'/'/');
as the number of hi phens and slashes are changing the output is changing
Aug 30 '06 #1
1 1654
Banfa
9,065 Expert Mod 8TB
I trust you understand

printf ("%d\n", 5);

This is an instruction to output to stdout a string that will be made up of an interger (%d) and a new line (\n). The supplied integer value is 5.

in your code the supplied integer value is '-'-'-'-'/'/'/'

This looks confusing (and is probably meant to) but remember that 'x' is a character constant of type int where x can be and printable character or 1 of several special character code sequences (like '\n' for instance is a new line character).

So if we add some spaces to this

'-'-'-'-'/'/'/'

and then high light the character constants to make it easier to read it becomes

'-' - '-' - '/' / '/'

since division has a higher precedence it is evaluated first

'/' / '/'

this is equivilent to x / x, any non-zero thing divided by itself is 1 so the expression now is

'-' - '-' - 1

taking the first part

'-' - '-'

this is equivilent to x - x, anything subtracted from itself is 0 so the whole epression becomes

0 - 1

This is the value -1

This code will print -1 followed by a new line.
Aug 30 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

70
by: rahul8143 | last post by:
hello, 1) First how following program get executed i mean how output is printed and also why following program gives different output in Turbo C++ compiler and Visual c++ 6 compiler? void main()...
3
by: Minh Khoa | last post by:
Please give me more information about delegate and its usage? Why do i use it and when?
16
by: Jon Berraondo | last post by:
I've found something in access I can't explain..... I have two tables: CLIENTS_COMPANY_A: CodA Int. NameA Text(40) NIFA TEXT(15) CLIENTS_COMPANY_B:
0
by: kamig | last post by:
Hi! Scenario: Consuming my webService in a windows application give denied acces! Explanation: I have to say a moveTo fn. which move one file/dir from one drive to another, <authorization>
7
by: s99999999s2003 | last post by:
hi my friend has written a loop like this cnt = 0 files = while cnt < len(files) : do_something(files) i told him using for fi in files: do_something(fi)
13
by: groupy | last post by:
input: 1.5 million records table consisting users with 4 nvchar fields:A,B,C,D the problem: there are many records with dublicates A's or duplicates B's or duplicates A+B's or duplicates B+C+D's &...
5
by: angelcd | last post by:
hi guys, good day to you all, can someone try to explain to me whats the meaning of this , ill try to interpret it by myself but i need others side of explanation so i can really prove it to myself,...
12
by: jacob navia | last post by:
Hi I am writing this tutorial stuff again in the holidays and I came across this problem: The "width" field in printf is a minimum width. Printf will not truncate a field. for instance:...
5
by: sivadhanekula | last post by:
Hi everyone.. I want to insert a combobox with the list of test names of a database, but the testname contains 15000+ data, and I cant type all the data. so can any one help me in writing an SQL...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.