Monday, May 24, 2010

Why this c program is going infinite!!!!!!?

Program is to find no. of days between 2 dates.Logic is to add 1 day to 1 date till it reaches other.


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int a,b,c,d,e,f,flag=0;


printf("Enter first date");


scanf("%d%d%d",%26amp;a,%26amp;b,%26amp;c);


printf("Enter second date");


scanf("%d%d%d",%26amp;d,%26amp;e,%26amp;f);





while(c!=f||b!=e||a!=d) //If I comment c!=f this program works otherwise it goes infinite!





{


a++;


if((b==4)||(b==6)||(b==9)||(b==11))


f=30;


else if(b==2)


{


if(d%4==0)


f=29;


else


f=28;


}


else


f=31;


if(a%26gt;f)


{


b++;


a=1;


}


if(b==13)


{


c++;


b=1;


}


flag++;





}


printf("%d",flag);


getch();


}

Why this c program is going infinite!!!!!!?
Why don't you first calculate the julian value and then just subtract the two dates?





For example, if they enter 2007 01 31 for the first date and


2007 02 10 for the second, the first date would calculate to 2007031 and the second is 2007041. Subtracting, you then get 10 days.





The following hasn't been compiled or checked for complete accuracy, but should give an idea.








int main() {


int date1, date2, daysDiff=0;


/* blah blah blah - get your dates... */





date1 = jetJulian (a,b,c);


date2 = jetJulian (d,e,f);





if (date1%26lt;date2)


daysDiff = date2-date1;


else


daysDiff = date1-date2;





}





int getJulian(int year, int mo, int day) {


int jValue=0;


int moDays[11]={0,31,59,90,120,150,181,212,2...


/* Double-check the values above :) */





/* Add some verifications prior to the following */


jValue = moDays[mo-1]+day;





/* Add one if the mo%26gt;2 and leap year */


if ((year%4 %26amp;%26amp; !year%100) || year%400)


jValue++;





jValue+= year*1000;


return jValue;


}
Reply:i did this program


its to find persons age


%26amp; hw many days he lived


its very simple


first u substracted the old year from recent year


than answer*365


other line


subtract large month to smaller 1


than answer*30


than just add the days


ok that was mine


i wont do ur prob


i might get answer 2moro


when i go to my class


How should I learn C#.net? My background is C/C++?

Hello, I am from the old-school C/C++ generation and have seen the C#.net arrive quite fast. Now it seems like everyone wants a C#.net developper. How did you learn this? Any good resource links? Books? I graduated just before the advent of C# and am quite clueless as how to approach this topic. Thanks in advance. I have MS Visual Studio.net 2003 vers 7.1

How should I learn C#.net? My background is C/C++?
If you are fairly proficent with C++ you should not have any problems getting started on C#.





I havent read any book for learning C#. The language specification and gotdotnet should get you upto speed.
Reply:Basically, changing from C/C++ to .net is easy. Because newer versions usually means easier to use. Besides, the .net help files (MSDN) is a great source of knowledge, tips, and samples.





So don't worry. I suggest you keep a reference book with you all the time, and go right into developing your application. When you face a problem which you don't know how to solve, search first in the .net MSDN, then either in the book or in the net for solution only for that one problem.





Just remember, BE VERY FOCUS. Take one problem at a time. Very soon, in a month or two, you will get used to it. Good luck.
Reply:Just one thing that I find important: C# is _not_ a new version of C or C++ as someone here stated. It is a language of its own, that's very familiar in syntax to C and C++ users.


Microsoft also has C++.NET which basically consists of .NET Framework extensions for C++.


And you can see yet another point here: if you're proficient with C++ there is no need for you to move to C#. The C++ syntax for .NET references and scope notation is somehow funny but easy to understand.

baseball cards

C? what does scanf does? Wich one is used for hardware? c or c++?

what is the difference between c and c++





wich one is easier??





wich one is used more often?

C? what does scanf does? Wich one is used for hardware? c or c++?
First, scanf is used to read value the user types at the command prompt. For example:





int someNumber;


scanf ("%d",%26amp;someNumber);





would wait for the user to type something and press [ENTER]. It would then try to parse the text that was typed into an integer value and place that value in the "someNumber" variable, assuming they typed a valid number.





Either language can be used to interact with hardware, however I myself have never tried to do any sort of embeded systems programing -- I mean all I've worked with is writing relatively simple programs that run on Windows.





C++ adds Object Oriented abilities to the C programming language while still aiming for 100% backwards-compatability with C. And from what I've read it comes pretty close to 100%, however I've never really tried to compile any even remotely complex C program on a C++ compiler.





Anything you learn to do in C will definitely be helpful in learning C++, so if you're looking for what is easiest, you could start by learning C and then moving on to C++.





From what I could find on the Internet, C is more widely used than C++ , but that's probably hard to gauge.
Reply:c++ is object oriented. C can be considered as an earlier version and also a subset of C++. So C is easier. Onhardware C is generaly used.
Reply:In C language (and it can be used in C++) the scanf function is used to accept input from a device, like a keyboard. For example:


char string[80];


scanf("%s", string);


This code will pause the program and wait for the user to enter a series of characters followed by the enter key. In C++ the same thing is usually done using the "cin" function. Like:


cin %26gt;%26gt; string;


The scanf will work in C++ and C. The cin will only work in C++.





C was a language developed for procedural coding, though you can produce something like OO code in C. C++ was designed to be more Object Oriented than C, but it doesn't enforce OO design techniques. Neither one is really better for hardware.





Currently, C++ is preferred over C due to it's OO capacity, but it is not necessarily easier. If you understand OO concepts, C++ would not be more difficult than C. If you don't understand OO, I would probably advise you to learn a little bit about it and use C++.





I'm not a C++ or OO bigot. I'm just expressing my opinion based on my experiences. Good luck!
Reply:Your title doesn't make a lot of sense but I will try to answer your question. scanf() is a function in the stdio.h library that scans input from standard in (usually keyboard).





C is a subset of C++. C++ includes all the libraries of C. The difference is that C++ includes Object Oriented Design (classes), C does not.





Which one is easier is a very subjective question. I learned C before I learned C++, and I personally would recommend C first. The main reason is that in C++ a lot of things are done behind the scenes and you wont have a thorough understanding of C++ without C.





Both C and C++ are used extensively. For anything where speed is key unless you understand C++ well, C is a good choice. Otherwise C++ is usually easier.


C# over C++?

Why do people say C# is better then C++? Also is there still a need for C?





- Cheers, Daniel

C# over C++?
It really depends on what area of application you trying to implement.





For example, I will agree, C# is better, if you are doing development for windows or web based application, as it is truly object oriented and the code is easier to understand. And there is no pointer in C#.





As for C, I think it is still very important and useful in hardware programming, meaning, hardware level kind of work.





If you are a boss, you would invest in C#, rather than C++ as the number of expert in C++ is not growing and you will find more people holding skills in C#, so when come to hiring, you may have a hard time looking for such resource, and it will be higher cost in terms of salary because of the tight supply of C++ programmers.





I suggest, for C++ programmers start to adopt another new modern programming language to ensure a smooth way ahead. Cause, the work for C++ programmers is getting lesser and mostly for hardware programming.





So for those in hardware programing, I think still quite ok to hold on, on C or C++.
Reply:C# is better than C++ because (although it has a minimal performance hit ,of being managed code against native code) it runs in a virtual machine (.Net CLR) and invulnerable to the buffer overflow (root of almost all worms and trojans) and similar attacks. .Net framework provides a very easy access to many APIs using centralized System. and Microsoft. namespaces. ALso the code is write once run everywhere like java, all you need is to port the CLR. (i.e. there is open source MONO, GNU .NET and ROTOR which runs compiled .Net code on linux.





Yes, there is still need for C as most OS kernels (Windows, Linux) are written in C (not C++) thus the drivers written for those OS need to be written in C. Also many lightweight hardware platforms like microcontrollers don't have enough resources to support C++ and OO.





Loren Soth
Reply:As a firmware developer I can state that C/C++ programmers are still VERY much in demand, in fact if anyone knows of a Linux C++ programmer in the Denver area that needs work, contact ADIC out of Englewood! We are looking for good people!





This will probably always be the case since new hardware is constantly being developed and C is the de-facto standard for systems programming. The Linux kernel is written in C and so are most kernels that I can think of. Anyone who thinks that the world revolves around C# is only a application developer and takes for granted all the underlying systems and device drivers that they make use of.





C# is great for Windows application programming, or so I hear. Being strictly a Unix/Linux/VxWorks developer I can tell you that there is no place for C# in my world...only for C++ and C.


What does 'c/c' mean in construction?

Im studying construction technology and have been reading from a book that describes some things as c/c. For example:





100 by 50 ceiling joists at 400 c/c





help much appreciated thanks

What does 'c/c' mean in construction?
it means the measurment from the center of one joist to center of the adjacent joist(s), assumed to be evenly spaced across the space. Also called O.C. sometimes, or On Center. In the US, you might see that as 16" O.C.
Reply:center to center


Prove that the area A ( a, b, c ) of the triangle in the complex plane with corners at a, b, c?

Prove that the area A ( a, b, c ) of the triangle in the complex plane with corners at a, b, c


must be C (Complex), ordered in anti-clockwise fashion, is given by the formula








A ( a, b, c ) = (i/4)( ab` - a`b + b c `- b`c + c a` - c`a ) .


--------------------------------------...





(for the letters a` , b`,c` , it is actually a line on top of these letters)

Prove that the area A ( a, b, c ) of the triangle in the complex plane with corners at a, b, c?
a(a1+ia2), b(b1+ib2), a' denoting the conjugate of a,


then:


ab' = a1b1+a2b2 + i(a2b1-a1b2)


a'b = a1b1+a2b2 + i(a1b2-a2b1)


ab'-ab' = 2i(a2b1-a1b2).





Now from plane geometry you have the formula:


for area of A(a1,a2) B(b1,b2) c(c1,c2)


(ABC ordered clockwise)





Area = ½ (a1b2-a2b1) + ½(b1c2-b2c1) + ½(c1a2-c2a1)





This gives the key I hope

artificial flowers

C-section needed! any advice? please nov15th is the day?

ok well its been a long road for me in my pregnancy i have way way passed my pregnancy time line i was supposed to have a very early delivery but instead god was with us and we hung in there now im 37 weeks pregnant and am having a c-section on November 15th i will be 39 weeks just when i had my son now im needing a c-section for possibal problems so my question is whats a c-section like whats going to happen? my baby is breech and will not turn and is to big to turn and there just alot of other risks right now so a c-section is very needed and i have no clue on what happenes im looking for good or bad problems or experiences im scared and waiting for the day and trying to prepare the best way i can any advice? i also have a 5 year old...how active will i be or not be after this surgery in any ones point of view please let me know!~thanks a million a anxious mommy~

C-section needed! any advice? please nov15th is the day?
Where I work, we have you come in 2 hours before your surgery. We start an IV, begin infusing IV fluids, do lots of paperwork, shave the bottom of your abdomen, and we give preop meds about 30 minutes prior. The anesthiologist should see you ahead of time too. Once we take you to the OR, we have you sit on the side of the stretcher with your back to the anesthiologist for your spinal. They have you sit kind of hunched over, with your spine curved outward, inject some numbing medication to numb the area, then insert the spinal needle. Through that needle they give you the medicine that numbs you from your upper abdomen and below. You lay back, and then we insert the foley catheter. We prep your belly with betadine and you are draped. We then let your significant other in the room. The Dr. will test you before beginning to make sure you are good and numb before starting. Normally they have the baby out within 10 minutes. You'll feel pulling and tugging and pressure but shouldn't be too painful. After nursery checks the baby out and suctions the lungs if needed they'll let you see the baby, then we let the father carry the baby out to the nursery. Once the dr finishes sewing you back up, you go to recovery for an hour or two. You normally get to see the baby while in recovery. You'll stay in the bed for the most part that day. The next morning, we take out your catheter and let you get up to the shower. You are able to walk around some if you feel up to it. We let you go home after 3 days, so you would probably go home on Nov. 18th. You'll become more active over the next few weeks but you shouldn't lift your 5 year old. Instead, sit down and let him/her sit in your lap. Also, no driving for 2 weeks. Most drs will give you a pain pill prescription to take home for the soreness. Hopefully you'll have someone to stay with you for the first few weeks to help you so you'll be able to rest. Good luck. If I left anything out, let me know.
Reply:Unless it is an emergency, you will remain awake for the entire thing.


You need to fast the day before .You will have an IV put in and a catheter in your bladder.You will then have an epidural and then your husband will be able to join you in the OR.


There is a sheet in front of your face so you cannot see what is going on.


It all goes pretty fast , then you will go back to your room.


I suggest resting the rest of that day and keeping your 5 yr old at home.


You should check your insurance [ if in the US ] and find out how long you have in the hospital.


You really should be fine.It takes a while to heal and can be very painful.You will need help the first couple of weeks as you continue to recover.


Congratulations.
Reply:I had one abdominal surgery (with an ectopic) and a c-section 5 years later and at first it is difficult to move at all - even with medication - but the faster you get up and move the better. Walking is difficult but not impossible. After I got home from the hospital I was alone at home and was taking walks (short walks that is) with my baby at two weeks. The first time I recovered faster and was driving at two weeks. My baby was 10 pounds when I brought her home and lifting her was actually easier from a standing position. As far as preparing - make sure you have very comfortable pants or skirts and underwear to wear after you have the surgery and for a while after you go home. The only complication I had was with my c-section because my stomach was so large (from having a 10 pound baby) that my incision got a small infection in it from the sweat and skin hanging over. But other than that I totally enjoyed the birth since I wasn't having labor pains, the pressure of being pregnant was off (as the spinal cut all the feeling to my lower body), and I was calm. Everyone has a different experience but it's what you make it also. Enjoy that new baby and try and remember to take it slow if you need to. Ask a family member or friend to help out for the first couple days at home - that helps! I plan on having more support this time around.
Reply:I had an emergency one because my son was breech too. Only they told me he was ready to go and upside down at the last appointment a day earlier so I was in labor for 6 hours before they realized something wasn't right.





I think having it planned would make me way less nervous then having to sign a waiver in between contractions that they were trying to stop after inducing them. I remember they pull you out of bed the next day and make you walk and I thought I was going to break in half it hurt so bad. They give you this drip of morphine which makes you tired and takes the edge off but it still hurts. I couldn't believe all they send you off with is super size motrin. Taking a shower was also excruciating. I don't ahve a regular birth to compare it too but I imagine it can't be half as bad as this was judging by the recovery time and how people compare it. I was exhausted as it is major surgery. The nurses discouraged breastfeeding because they said I had to heal. I pursued it though for 4 1/2 months. You will need lots of help. My mom and husband took 2 weeks off as I was pretty incompetent minus the feedings laying down in bed. No stairs, lifting or driving. It's a lot to get used to at once. Your hormones are changing, you're recovering from major surgery, you have this baby who wants to eat every couple of hours despite your exhaustion etc. You'll be fine though. My friend just had one in September and wasn't in the agony I was. They say the better shape you're in, the more it hurts because they're cutting through that much more muscle. Needless to say, I am not exercising that much this time around. Good luck!
Reply:Your doctor will do what is best for you and your baby. Try not to worry about it. I know it is a bit of hell to go through but you will have a beautiful baby.





With a c-section, the anaesthetict gives you a spinal epidural on your back, so your lower body is asleep.


The doctors cut your tummy and take the baby out. The cord is cut.


Baby is checked over.


Your tummy is stitched up. You will feel all druggy but really happy your baby is okay.


You will be given drugs to help the pain. The nurses will help you with your baby eg. feeding, changing nappies etc.





Basically you can't drive for 6 weeks, no heavy lifting, no running around with your 5 year old.





A c-section is an operation, your don't want the stitches to come out or get an wound infection.





Ask your family and friends for help and support you will need it.





I feel for you as I have been there. Be strong and good luck!
Reply:I'm Hmong and if you know anyone how is an elder hmong person you can have them turn your baby around so you don't need to have a c- section. I've never had one before but from what I've heard after your c section you can't really do much my best advice to you is if you know any hmong friends or anyone knows one have your baby turn. It really works, hmong people has many ways that people just don't know. like with medicine to many other things but it will cost you money to have them turn your baby.
Reply:Not much happens before the surgery, you just can't have anything to eat or drink for 12 hours before.


When they put you out for the surgery they use as little as they can so as to not harm the baby. They make the cut and have the baby out in like one minute. It is real fast.


As soon as you wake up you get to see or hold the baby. If everyone is doing ok.


If they are doing the bikini cut (which is standard now) you will have a faster recovery than if they do the up and down cut.


Everything is mostly the same as a regular delivery except for the cut. That should he healed in a couple weeks. The first week you are pretty sore and stiff and should have help with your son so he don't jump on you or something.
Reply:mine was emergency so i didnt have time to prepare all tehy did was give me the epidural then lay me right down on the table the dr. came in and i felt some pressure where he was working but other than that nothing i did freak out and try to climb off the table ( obviously i couldnt but still ) due to reaction with valume. After they say you shouldnt want to walk for atleast a day or 2 i was up the next day ( had motivation though my daughter was in another hospital than i was ) you stay in for like 4 days or so you must have a bm and take a shower to leave it is painfull i loved my meds. and usually you carry a pillow or something to keep your stomach in when i came home i had a velcro belt that kept my clothes from catching my scar. I thought it was ok and hopeing i can have another one this time. the only thing i wasnt prepared for was you will have little to no feeling around the scar ( about 3 inches for me ) and that lasts awhile mine was 2 yrs ago and still nothing. dont worry so much youll be fine and relax and take advantage of any help you can get. good luck
Reply:I agree with much of what was said before. However, I found the recovery time to be longer. It was two weeks before I could walk across the house comfortably, and that was with pain medication. After about a month I could walk around well enough to take care of regular household chores.





If you'd like to try to avoid a c-section, there are some things you can try. I had an external version which was unsuccessful. I did not find it to be painful or uncomfortable. Some other people have had success with moxibustion from an acupuncturist or special adjustments from a chiropractor. My baby came early, so I ran out of time to try the last two.