473,791 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some confusions need your help(c)

2 New Member
I am preparing c for entrance examinations..I am reading Ritchie and Deitel and practising questions from Yashwant Kanetkar...Here are some of the confusions i am having..your help is required....


Q1)

#include<stdio. h>
int main()
{
printf("%d \n",-5%-4);
printf("%d\n",-5%4);
printf("%d\n",5 %-4);
getch();
return 0;
}


o/p

-1
-1
1

So this implies that sign of % operator wil always be sign of the numerator??Am i correct??



Q2)

#include<stdio. h>
int main()
{
int x=3;
float y=3.0f;
double z=3.0;
if(x==y)
printf("x and y are equal\n\n");
else
printf("x and y are not equal");
if(y==z)
printf("y and z are equal\n\n");
else
printf("y and z are not equal");
if(y<3.0)
printf("I am satisfied");
getch();
return 0;
}

O/p

x and y are equal
y and z are equal


So confusion here is floating point numbers aren't stored by approximations? ?So why int =float=double here??For third case
if(y<3.0)

In yashwant kanetkar it assume it to be true as it says 3.0 is double and bigger than a float value so it would be true.....But when i run i didn't turn to be true.....


Q3)

int x=5
int y= x++ + ++x;
printf("%d %d",y,x);

pls explain.....

Similarly int x=7,y;
y=x/++x;

pls explain the o/p

The explanation given there was that ++x because of greater precedence would be evaluated first then ++x....

but in
i=1
a=++i;

If this reasoning is followed then [] has higher precedence so a=a[1] and increamenting should be done afterwards..... ..??But i hav red in Richie that it is
undefined situation.....


I am very much confused in these.....your valuable help is required


Pls also suggest a good book for practicing o/p questions....
Jan 3 '09 #1
0 1094

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

Similar topics

9
1438
by: Worker | last post by:
Hi , i`ve been wondering how many days do you guys need to read an average asp.net programming book, answer honestly please, for example 800 pages big, how many pages a day? I just wanna see if i m reading too slow... :) Next question, i have a simple function from my latest book here and the authors of "Wrox Beginning Asp.net with c#" were not to eager to explain the meanings of the theory of code they used in their example so i...
23
3650
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a so-called pre-fix notation or algebraic notation. Algebraic notations have the concept of operators, meaning, symbols placed around arguments. In algebraic in-fix notation, different
30
5501
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”. Likewise, they write “(if test this that)” to mean “if (test) {this} else {that}”. LISP codes are all of the form “(a b c ...)”, where the
2
1202
by: KanchanG | last post by:
Hi, I'm new here and relatively new to c++ as well. I'm trying to write a function which will solve a quadratic equation. The progran needs to distinguish which coefficient is a, b and c. The quadratic is on the command line at argv. So I decided to split the string (quadratic) up to the x e.g. 4x^2 + 3x + 5 I want the code to read up to x^2 and place the value into a vector. It will then ignore everything until the +/- and then read...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9515
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
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
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
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
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
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
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.