Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	float c,f;
	printf("plesase write a number of degrees celsius:");
	scanf("%f",&c);
	f=c*9/5+32;
	printf("number of degree fahrenheit: %f\n",f);
	system("pause");
	return 0;
}

Output is the number.Its input is the number.
If the input string, the output is not suitable for, say, if the input string, the output of our cout<<"error";
With cin and cout What is it?
Posted
Updated 23-Feb-12 23:47pm
v7
Comments
nagendrathecoder 24-Feb-12 4:23am    
Your question is not clear. Can you explain it more?
Sarvesh Kumar Gupta 24-Feb-12 4:26am    
Pls describe your problem in detail. More clear
sajad abbasi 24-Feb-12 4:31am    
It was good؟
Mohibur Rashid 24-Feb-12 4:43am    
Its nearly impossible to help you
sajad abbasi 24-Feb-12 4:47am    
What you mean?

1 solution

Try this:
C#
int main(int argc, char *argv[])
    {
    float c,f;
    printf("plesase write a number of degrees celsius:");
    if (scanf("%f",&c) != 1)
       {
       printf("Error\n");
       }
    else
       {
       f=c*9/5+32;
       printf("number of degree fahrenheit: %f\n",f);
       }
    system("PAUSE");
    return 0;
    }
 
Share this answer
 
Comments
sajad abbasi 24-Feb-12 5:33am    
With cin and cout What is it?
OriginalGriff 24-Feb-12 6:04am    
float c,f;
cout << "plesase write a number of degrees celsius:";
try
{
cin >> c;
f=c*9/5+32;
cout << "number of degree fahrenheit: " << f << "\n";
}
catch (const char* Str)
{
cout << "Error\n";
}
sajad abbasi 24-Feb-12 6:17am    
Does not work
OriginalGriff 24-Feb-12 7:03am    
Not too helpful - what "doesn't work"?
sajad abbasi 24-Feb-12 7:07am    
float c,f; cout << "plesase write a number of degrees celsius:"; try { cin >> c; f=c*9/5+32; cout << "number of degree fahrenheit: " << f << "\n"; } catch (const char* Str) { cout << "Error\n"; }
It does not work. Does not run the previous program it runs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900