Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB #2 CPS125 LAB MANUAL Purpose: INTRODUCTION The purpose of this lab is to learn how to use the Geany IDE (Integrated Development Environment), to

image text in transcribed
image text in transcribed
image text in transcribed
LAB #2 CPS125 LAB MANUAL Purpose: INTRODUCTION The purpose of this lab is to learn how to use the Geany IDE (Integrated Development Environment), to know about the basic steps to write a C program, and to understand common compiling and runtime errors. Before the lab: 1. Read the tutorials and watch the videos on Geany (links in the left margin). GLANY USERS GEARTY VOLO TUTORIALS LABLUSER GUIDE DEBUGGING During the lab: PARTI: PROGRAMMING EXERCISES Exercise #1: a. Using Geany, write the program "My first C program" as found on the example programs website (ihypress.net) in the "Overview of C section. b. Compile and build the program. C. Run the program and see that it works properly. d. Can you make the program write this also? This my first program. Exercise #2: a. Write a simple C program that will display the following pattern on the screen: XXO Exercise #3: a. Using Geany, write the following C program as is: included t he state. b. Compile the proaram. Exercise #3: a. Using Geany, write the following C program as CPS 125 LAB MANUAL INTRODUCTION included LATES LABLES LAB 19 GEANY USERS GUIDE GEAN MIDEO TUTORIALS LARUSERGIO b. Compile the program. C. This program contains syntax errors. On a piece of paper, indicate each one of them and make the appropriate corrections. d. Write your answers in a text file. e. Try to correct the errors. Compile and build the program with all the corrections made. f. Once the syntax errors have been corrected, there are two errors that remains when you try to run it (one is called a runtime error because you are trying to do something illegal, the other is a logic error because you made a small mistake in the program). What are they? Tell your TA or ask for hints! 9. Correct the errors and compile and run the program again. What value of d is displayed? DAS Exercise #4: a. Write and run in Geany a C program that does this: Ask the user for a real number (like 316501.6735) and display the rounded number to the nearest hundredth (ex: 316500), and the nearest thousandth (ex: 316000). Can you do it with what you know at this moment? b. Can you display the rounded number to one decimal place? (ex: 316501.7). That one should be easy. Exercise #5: a. Find the formula of the ellipse on the internet and write and run another C program that asks the user for both the long and short radiuses and then calculates and displays the circumference of the ellipse. You should be able to do that one without difficulty. Exercise #6: Answer these 10 questions by reading your notes, Vou tevthank or hu trying with Geanu CPS 125 LAB MANUAL INTRODUCTION UAB LABER LALL GEANY USERS TUTORIALS LAB USER GUIDE Exercise #6: Answer these 10 questions by reading your notes, your textbook or by trying with Geany: 1. What is the difference between char and Char? 2. What is displayed by printf ("d", 3/4); ? 3. Is printf ("of", 50); valid? 4. If you omit the ; at the end of a C statement, is it still working? 5. What is the difference between %f and %lf? 6. What happens when you attempt a division by zero in C? 7. Is the expression 35815.3 valid? 8. Is there a difference between starting your program with main() instead of int main (void)? 9. What happens if you try to display an integer between 0 and 255 with a %c placeholder? 10. Are the expressions 5/3, 5%3, 5.0/3 exactly the same? Show your answers to your TA and write the answers in the same file as exercise #3. PART II: DISCOVERY ACTIVITIES i. Using a text book or an Internet search (do not ask friends or TA!), explain in one or two sentences the difference between the printf and scanf statements in C. ii. Using your text book or an Internet search (do not ask friends or TA!), explain in one sentence or two the difference between integer and double variables in C. iii. Write the answers to the two discovery questions in the same file as programming exercises 3 and 6. DEBUGGING PROGRAMS PART III: LAB REPORT SUBMISSION 1. Submit the .c files for programming exercises 1, 2, 4, and 5. 2. Submit the text file containing the answers to programming exercises 3 and 6 and the discovery activities. 3. Submit on D2L/Brightspace under Lab #2. Submissions are due at the end of the lab session. You must submit your work before leaving the lab. After the lab: LAB #2 CPS125 LAB MANUAL Purpose: INTRODUCTION The purpose of this lab is to learn how to use the Geany IDE (Integrated Development Environment), to know about the basic steps to write a C program, and to understand common compiling and runtime errors. Before the lab: 1. Read the tutorials and watch the videos on Geany (links in the left margin). GLANY USERS GEARTY VOLO TUTORIALS LABLUSER GUIDE DEBUGGING During the lab: PARTI: PROGRAMMING EXERCISES Exercise #1: a. Using Geany, write the program "My first C program" as found on the example programs website (ihypress.net) in the "Overview of C section. b. Compile and build the program. C. Run the program and see that it works properly. d. Can you make the program write this also? This my first program. Exercise #2: a. Write a simple C program that will display the following pattern on the screen: XXO Exercise #3: a. Using Geany, write the following C program as is: included t he state. b. Compile the proaram. Exercise #3: a. Using Geany, write the following C program as CPS 125 LAB MANUAL INTRODUCTION included LATES LABLES LAB 19 GEANY USERS GUIDE GEAN MIDEO TUTORIALS LARUSERGIO b. Compile the program. C. This program contains syntax errors. On a piece of paper, indicate each one of them and make the appropriate corrections. d. Write your answers in a text file. e. Try to correct the errors. Compile and build the program with all the corrections made. f. Once the syntax errors have been corrected, there are two errors that remains when you try to run it (one is called a runtime error because you are trying to do something illegal, the other is a logic error because you made a small mistake in the program). What are they? Tell your TA or ask for hints! 9. Correct the errors and compile and run the program again. What value of d is displayed? DAS Exercise #4: a. Write and run in Geany a C program that does this: Ask the user for a real number (like 316501.6735) and display the rounded number to the nearest hundredth (ex: 316500), and the nearest thousandth (ex: 316000). Can you do it with what you know at this moment? b. Can you display the rounded number to one decimal place? (ex: 316501.7). That one should be easy. Exercise #5: a. Find the formula of the ellipse on the internet and write and run another C program that asks the user for both the long and short radiuses and then calculates and displays the circumference of the ellipse. You should be able to do that one without difficulty. Exercise #6: Answer these 10 questions by reading your notes, Vou tevthank or hu trying with Geanu CPS 125 LAB MANUAL INTRODUCTION UAB LABER LALL GEANY USERS TUTORIALS LAB USER GUIDE Exercise #6: Answer these 10 questions by reading your notes, your textbook or by trying with Geany: 1. What is the difference between char and Char? 2. What is displayed by printf ("d", 3/4); ? 3. Is printf ("of", 50); valid? 4. If you omit the ; at the end of a C statement, is it still working? 5. What is the difference between %f and %lf? 6. What happens when you attempt a division by zero in C? 7. Is the expression 35815.3 valid? 8. Is there a difference between starting your program with main() instead of int main (void)? 9. What happens if you try to display an integer between 0 and 255 with a %c placeholder? 10. Are the expressions 5/3, 5%3, 5.0/3 exactly the same? Show your answers to your TA and write the answers in the same file as exercise #3. PART II: DISCOVERY ACTIVITIES i. Using a text book or an Internet search (do not ask friends or TA!), explain in one or two sentences the difference between the printf and scanf statements in C. ii. Using your text book or an Internet search (do not ask friends or TA!), explain in one sentence or two the difference between integer and double variables in C. iii. Write the answers to the two discovery questions in the same file as programming exercises 3 and 6. DEBUGGING PROGRAMS PART III: LAB REPORT SUBMISSION 1. Submit the .c files for programming exercises 1, 2, 4, and 5. 2. Submit the text file containing the answers to programming exercises 3 and 6 and the discovery activities. 3. Submit on D2L/Brightspace under Lab #2. Submissions are due at the end of the lab session. You must submit your work before leaving the lab. After the lab

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

1. What is the origin of the communication discipline?

Answered: 1 week ago

Question

2. What methods do communication scholars use to conduct research?

Answered: 1 week ago