Thread: what loop use here?

  1. #1
    Registered User
    Join Date
    May 2010

    what loop use here?

    converts Fahrenheit to Celsius temperature in increment of 5 degrees. The

    initial value of Fahrenheit temperature and total conversion are to be made are requested

    as user input.

    and code is

    #include "iostream"
    using namespace std;
    void main()
    	int inp;
    	cout<<"Enter how many time you want to convert temperature: ";
    	for(int i=1;i<=inp;i++)
    		float temp;
    		cout<<"enter fahrenheit value: ";
    		float cels=(5.0/9.0)*(temp-32.0);
    		cout<<temp<<" Fahrenheit converted to "<<cels<<" Celcius"<<endl;
    i know this is not what it require but i am not understanding what that 5 degree increment means please guide me.

  2. #2
    Join Date
    Dec 2007
    Cross-posted here. Obviously just wants to be spoon-fed the answer.

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    London, United Kingdom
    Yes, he also seems to need a map to figure out he is on the wrong forum.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  4. #4
    Registered User
    Join Date
    Sep 2009
    you can use for loop or while loop or do/while loop. Any will be fine. Read in your book how to use those and then write the code for it. Shouldn't be difficult.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Poll event loop
    By rogster001 in forum C++ Programming
    Replies: 2
    Last Post: 09-17-2009, 04:28 AM
  2. need help with a loop
    By Darkw1sh in forum C Programming
    Replies: 19
    Last Post: 09-13-2009, 09:46 PM
  3. funny-looking while loop
    By Aisthesis in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2009, 11:54 PM
  4. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM