Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or 2013. 2.Create a new “project” and add.

Similar presentations


Presentation on theme: "Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or 2013. 2.Create a new “project” and add."— Presentation transcript:

1 Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or 2013. 2.Create a new “project” and add a new C file to the project. 3.Write following simple C code 4.Build 5.Execute

2 1(a). Write a program that will obtain the length and width of a rectangle from the user and compute its area and perimeter. (Use float type for all variables.) Output Example : 1.4 2.1 (  ------- keyboard user input) 2.940000, 7.000000

3 1(b). Write a program that reads in the radius(반지름) of a circle and prints the circle’s diameter(지름), circumference(둘레), and area(면적). Use the constant value 3.14159 for PI. #include int main() { float radius, diameter, circumference, area; // put your code here // use scanf to get the value of radius // use printf to display the result of calculation. } Output Example : Get radius? 3.5 (  ------- keyboard user input) diameter = 7.000000, circumference = 21.991130, area = 38.484477

4 2. Write a program to convert a temperature in degrees Fahrenheit to degrees Celsius. Celsius = 5.0 / 9.0 * (fahrenheit – 32) Input and Output Example : 105.3 (  ------- keyboard user input) 40.722225

5 3. Write a program that predicts the score needed on a final exam to achieve a desired grade in a course. The program should interact with the user as follows: Input and Output Example : Enter desired grade> B Enter minimum average required> 79.5 Enter current average in course> 74.6 Enter how much the final counts as a percentage of the course grade> 25 You need a score of 94.20 on the final to get a B.

6 4. Write a program that converts meter-type height into [feet(integer),inch(float)]-type height. Your program should get one float typed height value as a keyboard input and prints integer typed feet value and the rest of the height is represented as inch type. (1m=3.2808ft=39.37inch) (input and output format example) 1.80meter -> 5feet 10.9inch use automatic type conversion 1/2 = 0 (?), 3/2 = 1 (?) (ex) int a; float b; b = 3.6/2.0; a=b; printf(“a=%d, b=%f\n”,a,b);


Download ppt "Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or 2013. 2.Create a new “project” and add."

Similar presentations


Ads by Google