-
Notifications
You must be signed in to change notification settings - Fork 0
/
tute01.cpp
44 lines (34 loc) · 912 Bytes
/
tute01.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*Exercise 1 - Calculations
Convert the C program given below which converts a length given in cm to inches to a C++ program.
Please Note that the input command in C++ is std::cin. This is a representation of the Keyboard.
e.g.
float data1;
int data2;
scanf("%f", &data1); --> std::cin >> data1;
scanf("%d", &data2); --> std::cin >> data2;
You already know that printf() in C is std::cout in C++ e.g.
printf("Hello World") --> std::cout << "Hello World";
2.54cm = 1 inch
*/
/*
#include <stdio.h>
int main()
{
float cm, inches;
printf("Enter a length in cm : ");
scanf("%f",&cm);
inches = cm / 2.54;
printf("Length in inches is %f \n", inches);
return 0;
} */
#include <iostream>
int main()
{
float cm;
float inches;
std::cout << "Enter a length in cm :" << '\n';
std::cin >> cm;
inches = cm / 2.54;
std::cout << "Length in iches is : " << inches ;
return 0;
}