help needed in floating point

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 15
Reputation: akshayabc is an unknown quantity at this point 
Solved Threads: 0
akshayabc akshayabc is offline Offline
Newbie Poster

help needed in floating point

 
0
  #1
Jun 27th, 2005
I have 2 problems in C regarding floating point, please help :

Q1
Output of the following code- C.
  1. main()
  2. {
  3. float a=0.7;
  4. if(a<0.7)
  5. printf("C");
  6. else
  7. printf("C++);
  8. }
  9.  
But if we change the if condition from a<0.7 to a<0.7f we get output- C++.

Q2
The following code gives runtime error- Floating point formats not linked. When does this error occur in a program.
  1. main()
  2. {
  3. struct emp
  4. {
  5. char name[20];
  6. float sal;
  7. };
  8. struct emp e[10];
  9. int i;
  10. for(i=0;i<=9;i++)
  11. scanf("%s %f",e[i]name,&e[i].sal);
  12. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: help needed in floating point

 
0
  #2
Jun 27th, 2005
This looks curiously like homework...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: help needed in floating point

 
0
  #3
Jun 27th, 2005
  1. #include <stdio.h>
  2.  
  3. #define BUFSZ 255
  4.  
  5. struct lala
  6. {
  7. char name[BUFSZ];
  8. unsigned age; // for example :-)
  9. } student[10];
  10.  
  11. int main(void)
  12. {
  13. for(int i=0; i < 10; i++)
  14. scanf("%s %d", &student[i].name, &student[i].age);
  15.  
  16. // Using scanf() for reading strings is in general not a good idea.
  17. // Look at fgets(). It is more precise and can prevent overflows.
  18.  
  19. return 0;
  20. }
<< moderator edit: added [code][/code] tags >>
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,387
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 244
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: help needed in floating point

 
0
  #4
Jun 27th, 2005
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 13
Reputation: oboler is an unknown quantity at this point 
Solved Threads: 1
oboler's Avatar
oboler oboler is offline Offline
Newbie Poster

Re: help needed in floating point

 
0
  #5
Jun 27th, 2005
definitly homework then - lol
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 15
Reputation: akshayabc is an unknown quantity at this point 
Solved Threads: 0
akshayabc akshayabc is offline Offline
Newbie Poster

Re: help needed in floating point

 
0
  #6
Jun 28th, 2005
No its not a homework, i found these questions in an indian author book- "Test your C skills" by Yashwant Kanitker. Answers were given but not reasons for that answers.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC