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

why 'x' is taking always 1.

amarniit
#include<stdio.h>
void main ()
{
int x=4,y=78;
if(x=8 && y>65)
printf("x=%d");
else
printf("Bywe");
getch();
}


here i am always geting the value of x is one........... its never change
Dec 2 '09 #1
6 1470
Dheeraj Joshi
1,123 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. if(x=8 && y>65)
  2.  
x=8 is assignment not condition checking.

It must be :

Expand|Select|Wrap|Line Numbers
  1. if(x==8 && y>65)
  2.  
Regards
Dheeraj Joshi


Note: Please use code tags during posting the code
Dec 2 '09 #2
Markus
6,050 Expert 4TB
You don't provide an argument to the printf() function. It should look like: printf("x=%d", x).
Dec 2 '09 #3
whodgson
542 512MB
In fact neither of your printf statements are correct.
e.g.
printf("i=%d and x=%f\n",i,x);//Here there are two format specifiers in the format string and two data-field arguements. The number of format specifiers require matching with the data-field arguements.
Dec 6 '09 #4
ya in printf()it is
printf("x=%d",x);
Dec 17 '09 #5
sidooh
9
you should use printf("x=%d",x);
Dec 17 '09 #6
Banfa
9,065 Expert Mod 8TB
Strictly speaking if you wish to see your output immediately it should be

printf("x=%d\n",x);

without the newline the system is free to buffer the output until a later time.
Dec 17 '09 #7

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

Similar topics

13
by: Ideasman | last post by:
Hi I have a made a script that process normals for a flat shaded 3D mesh's. It compares every vert with every other vert to look for verts that can share normals and It takes ages. I'm not...
2
by: Brent | last post by:
Hello all.. I have a recordset that has 12 records in it, and about 25 columns. Unfortunately, I have to write the records out as columns in an ASP page, and the columns as rows. So, what I have done...
4
by: djc | last post by:
the aspnet_wp.exe process in taking up lots of memory. Right now just the one main page loads and imediately goes to the top of the memory usage list with around 32MB of memory usage. The page only...
1
by: thomson | last post by:
Hi all, I have created a Web Application in my system, This application is accessed only in the local network. I have observed that in some machine When there is a post back it will be taking...
3
by: Jim Langston | last post by:
I really am not sure if this question belongs in this newsgroup, but not sure where else to ask it. There is someone working on a game that I tested, and it was taking >30 seconds to load. He...
3
by: daniell | last post by:
/* Triangle.cpp */ // Use a pure virtual function. #include <iostream> #include <cstring> using namespace std;
15
by: jamesallen74 | last post by:
I am a college student getting ready to take a Javascript class. From what I hear it is pretty lame and I want to learn more about javascript than what the class offers. While I am taking the...
1
by: mofthegame | last post by:
how do i fix xp's start up it takes 4 and a half mins to boot and then my cpu is maxing out and is always in the red zone. not only that but it seems my computer is always doing something in the...
3
by: tshad | last post by:
Using asp.net 2.0, I am finding that at times, the old javascript will still be there. I was working with it for a couple of hours and the changes seem to happen. But at the end of the day, I...
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
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: 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
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,...
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...

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.