Preview

Lab_6_solution

Good Essays
Open Document
Open Document
1259 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Lab_6_solution
By the end of this lab session, you will be able to - declare an integer and character array - assign values to array during compilation and during execution - print contents of an array using repetition structure SAMPLE PROGRAM 1 /1. A program reads a series of numbers and print it reversed / include stdio.h void main (void) int i, Num, numbers10 printf(You may enter up to 10 integersn) printf(How many integers would you like to enter ) scanf (d, Num) if (Num 10) Num 10 printf(nEnter your numbers ) for (i 0 i Num i) scanf(d, numbersi) printf(nYour numbers reversed are ) for (i Num - 1 i 0 --i) printf(d , numbersi) printf(nn) SAMPLE PROGRAM 2 /2. Program that demonstrates the use of for loop to accept 8 numbers from user and displays certain numbers from the array / includestdio.h void main() int num, numbers8 printf(You need to enter 8 numbers ... n) for(num 0 num 7 num) scanf(i,numbersnum) printf(nn) printf(Your 1st element is dn,numbers0) printf(Your 2nd element is dn,numbers1) printf(Your 3rd element is dn,numbers2) printf(Your 8th element is dn,numbers7) printf(nn) printf(nnAll together your numbers aren) for(num 0 num 7 num) printf(d ,numbersnum) printf(nn) SAMPLE PROGRAM 3 /3. Program declares an array called charArray and assigns a single character to each of the array element using the initialize braces. Finally, the program prints the content of the array. / includestdio.h void main() char charArray8 F,r,i,e,n,d,s int i for(i 0 i 7 i) printf(charArrayd has a value of cn,i, charArrayi) printf(nMy favourite comedy sitcom is snn, charArray) SAMPLE PROGRAM 4 /4. Program consists of arrays (i.e. integer array and character array). It uses loops to sort the integer array elements in ascending and descending order. Then it displays the contents of the array elements respectively. / includestdio.h void main(void) int array10 0,1,2,3,4,5,6,7,8,9, i char string20 This is a string for(i

You May Also Find These Documents Helpful

  • Good Essays

    Lab for Chemistry 221

    • 612 Words
    • 3 Pages

    Abstract: A 50mL (we used 100mL) volumetric flask was used to determine the amount of sugar in a can of Coke per mL in 5 different solutions. Using the calibration curve we determine the amount of sugar per mL in a can of coke. This experiment concluded that there is 43.83g of sugar in a 12oz can of Coke.…

    • 612 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    LAB 6

    • 5674 Words
    • 23 Pages

    CHM130 Lab 6 Exploring Density Name A. Data Tables Place your completed Data Tables here Part IIIa (3 points) Volume of water in graduated cylinder (mL)10 mlMass of rubber stopper (g)11.15Volume of water and rubber stopper (mL)16.5 Part IIIb (6 points) Volume of water in graduated cylinder (mL)20Mass of iron nail (g)3.66Volume of water and iron nail (mL)20.5 Part IV (20 points) Type of Aluminum FoilMass (g)Length (cm)Width (cm)Volume (cm3)Thickness (cm)Regular.63g15 cm 10.02 cm.21 cm3.0014 cm Heavy Duty.97g15 cm10.01 cm .36 cm3.0024 cm B. Follow Up Questions Show all work for questions involving calculations. Part I Use the concepts/vocabulary of density to explain why the liquids formed layers in Part I of the procedure. (8 pts) The liquids formed layers because they all had different densities. The liquids with light density were towards the top of the layers. What was the control used during the liquid portion of Part I of this experiment (8 pts) (Hint What did you do the same with each liquid to ensure a fair comparison) The control used during the portion of part I was the amount of liquid used. Rank the following in terms of relative density (9 pts) Isopropyl alcohol (rubbing alcohol) lowest relative density Liquid dishwashing detergent- intermediate relative density Dark corn syrup-high relative density Vegetable oil-second lowest relative density (intermediate) Glycerin-second highest relative density Rubber stopper- second highest relative density Cork stopper- low relative density (ended up with the alcohol Wood- low relative density (ended at the top with the rubber alchohol. Lead- highest relative density Part II (7 pts each) In Part II, what happened to the cans of soda when you placed them in water Use the concepts/vocabulary of volume and mass to explain the final positions of the cans in the sink full of water. The diet soda floated in the water while the regular soda sank. The regular soda had a higher relative…

    • 5674 Words
    • 23 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 6

    • 690 Words
    • 3 Pages

    1. Run your model. Compare the queue statistics of the 3 processes with those obtained for Part C in the previous Lab. How have they changed and what conclusions can you draw? (Note the sums of all capacities for both cases are equivalent – 12 in each).…

    • 690 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    Organic Lab 7

    • 1806 Words
    • 8 Pages

    Alkyl halides are compounds in which a halogen atom replaces a hydrogen atom of an alkane. Alkyl halides are classified as primary, secondary or tertiary depending on the number of alkyl substituents directly attached to the carbon attached to the halogen atom. The purpose of this lab was to properly prepare t-butyl chloride from t-butyl-alcohol in a concentrated hydrochloric acid. The reaction occurs through a nucleophilic substitution, which is when a nucleophile replaces the leaving group in the substrate. In this lab, the hydroxyl group of t-butyl alcohol is replaced by a chlorine atom. The reaction proceeds through an SN1 mechanism (Weldegirma 38-41).…

    • 1806 Words
    • 8 Pages
    Better Essays
  • Good Essays

    Lab 3 no name

    • 1348 Words
    • 5 Pages

    Abstract: The purpose of the lab, Stoichiometry of a Precipitation Reaction, is to be able to calculate the amount of a second reactant we need to react with the reactant one. You must calculate the amount of the second reactant using stoichiometry to figure out what amount is needed. After the amount is calculated, you then can add it to the first reactant and it will give you a full reaction. To figure out what you need you have to use stoichiometry. My calculation for the second reactant was: 1.0g CaCl2*2H2O(1mol CaCl2*2H­2O/147g CaCl2*2H2O)(1mol Na2CO3/1mol CaCl2*2H2O)(106g Na2CO3/1mol Na2CO3) = 0.72g Na2CO3. The final, when its dried in the paper filtered weighed at 1.6 grams.…

    • 1348 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Lab 7 & 8

    • 1094 Words
    • 5 Pages

    4. What is a recommended best practice when implementing a Remote Access Policy server user authentication service?…

    • 1094 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Lab6 7 8 9

    • 425 Words
    • 2 Pages

    2. Because if something were to happen to the computer the backups wouldn’t be gone with the computer.…

    • 425 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Lab 7

    • 995 Words
    • 4 Pages

    d. How well does each flip (or half-life) actually eliminate half of the remaining parent isotopes?…

    • 995 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    lab 1

    • 636 Words
    • 3 Pages

    Are there any safety concerns associated with this exercise? If so, list what they are and what precautions should be taken.…

    • 636 Words
    • 3 Pages
    Powerful Essays
  • Satisfactory Essays

    lab 6

    • 252 Words
    • 2 Pages

    4. Through command window determine the cause of the network connection loss using the IP configuration. Next renew the connection lost.…

    • 252 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 1

    • 567 Words
    • 3 Pages

    Attacker would avoid detection by covering tracks step of the hacking process where they cover up their tracks in the system they hacked into.…

    • 567 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    lab 1 assignment

    • 395 Words
    • 2 Pages

    Dissolved oxygen is oxygen that is trapped in a fluid, such as water. Since virtually every living organism requires oxygen to survive, it is a necessary component of water systems such as streams, lakes and rivers in order to support aquatic life. The dissolved oxygen is measure in units of ppm—or parts per million. Examine the data in Table 2 showing the amount of dissolved oxygen present and the number of fish observed in the body of water the sample was taken from; finally, answer the questions below.…

    • 395 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Lab 7

    • 928 Words
    • 3 Pages

    1. What are some common risks, threats, and vulnerabilities commonly found in the LAN-to-WAN Domain that must be mitigated through a layered security strategy?…

    • 928 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Lab 1

    • 414 Words
    • 2 Pages

    4. Why would you use a tool like DevManView while performing a computer forensic investigation?…

    • 414 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Module 5 Lab (5.09)

    • 487 Words
    • 2 Pages

    Your first lab link can be found at Temper Tantrums. A written transcript is also available for this lab.…

    • 487 Words
    • 2 Pages
    Satisfactory Essays

Related Topics