CS1050_Quiz1_A - CS1050 C Programming Quiz 1 Fall 2013 There are 10 questions on this quiz DO NOT PUT YOUR ANSWERS ON THIS SHEET RECORD THEM ON THE

CS1050_Quiz1_A - CS1050 C Programming Quiz 1 Fall 2013...

This preview shows page 1 - 2 out of 2 pages.

CS1050 – C Programming Quiz 1 Fall 2013 There are 10 questions on this quiz. DO NOT PUT YOUR ANSWERS ON THIS SHEET – RECORD THEM ON THE ANSWER SHEET ONLY.Use the following code to answer the next several questions.a.#include <stdio.h>b.int main ( void )c.{d.int miles; /* total miles driven per day */e.int gasCost; /* cost per gallon of gasoline */f.int mpg; /* average miles per gallon */g.int parkFee; /* parking fees per day */h.int tolls; /* tolls per day */i.int total; /* total cost */j.printf("Please enter the total miles driven per day: ")k.scanf("%d", &miles);l.printf("Please enter the cost per gallon of gasoline: ");m.scanf("%d", gasCost); n.printf("Please enter average miles per gallon: ");o.scanf("%d", &mpg);p.printf("Please enter the parking fees per day: ");q.scanf("%d", &parkFee);r.printf("Please enter the tolls per day: ");s.scanf("%d", &tolls); t.total = tolls + parkFee + (miles/mpg)*gasCost;u.printf("Your daily cost of driving to work is $%d\n", total);v.return 0; w. } 1)Which line of code (a-w) will cause this program to “segmentation fault” ?2)Which line of code (a-w) has a compile error?
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture