473,387 Members | 1,844 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,387 software developers and data experts.

if then else trinary operator

Hello

please explain the following:-

Say if
int i,sign;
double atof(char s[ ]);
has been declared and then there is statement
sign=(s[i]=='-' ) ? -1:1;
[/u]

Thanks in advance..........
Apr 10 '07 #1
3 2123
gpraghuram
1,275 Expert 1GB
Hi,
the code u have put is a ternary operator.
sign=(s[i]=='-' ) ? -1:1;
If user has entered a negative value the the value of sign will be -1 or else 1

Thanks
Raghuram
Apr 10 '07 #2
sicarie
4,677 Expert Mod 4TB
Did you try putting that into a compiler?
Apr 10 '07 #3
RedSon
5,000 Expert 4TB
In the future please follow the following rules from the FAQ:

Using a good, clear thread title is important. The reasons for this are:

* We want this site to grow, many of our new members find the site using a search engine, by using a good thread title you will help us grow the site by helping us get better search engine rankings.
* Using a good title will benefit you too because other members of the forum will be less likely to skip over your thread and it allows the experts to quickly scan through the forum for questions they know the answer to.
* If the threads are well titled it allows other users to easily see if there have been any threads that could be relevant to their own current problem.
* It is in everybody's best interests to post properly titled threads as the more time the moderators have to spend on managing titles the less time they have available to give answers to the questions posed.
Apr 10 '07 #4

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

Similar topics

13
by: lucanos | last post by:
Hey All, Just wondering whether there is an abbreviated "If - Then - Else" format in PHP, much like that possible in JavaScript. JavaScript allows an abbreviated version in the following...
6
by: TuPLaD | last post by:
Hi, i got the following script: name = raw_input("Please enter your name: ") print "Your name is", name but i want it that way: if name = Stickie then
24
by: gupta.keshav | last post by:
HI, Is there any situation which can be handled by ternary operator but not with if else blocks? Thanks Keshav
2
by: GS | last post by:
Can somebody explain why first part works and second part does not? Second operator throws error below Error 52 Type of conditional expression cannot be determined because there is no implicit...
25
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example...
3
by: Naha | last post by:
The if else statement inside my jsp is not working, it gives me the following error: type Exception report message description The server encountered an internal error () that prevented...
4
by: Alchemist | last post by:
What is Python's version for the trinary if..then..else operator? I want a one-liner such as a?b:c for the if..then..else control structure if a then b else c Does Python 2.4 support it?
5
by: PerlPhi | last post by:
hi,,, while ago i was wondering why do some programmers rarely uses the ternary operator. wherein it is less typing indeed. i believe in the classic virtue of Perl which is laziness. well let me show...
1
by: Jeffy | last post by:
I'm trying to create an if/else case in a stored procedure where if te record is not found, it returns blank values, and if it is found I get the real values. But when I try to execute the SP update...
3
MrPickle
by: MrPickle | last post by:
I'm not sure if I am using the right term but by conditional operator I mean ?: e.g.; statement ? value if true : value if false What are the differences between if-then-else and ?: Is it...
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: 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$) { } ...
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: 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...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.