473,472 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Create 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 1074

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

Similar topics

9
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...
23
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...
30
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”....
2
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...
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
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,...
1
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.