assignment 6 - #include <stdlib.h>...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Assignment 6, Part A, Question 1 */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define NAMLIM 13 int main() { char line[8], namefile[NAMLIM]; FILE *inFile; int i; printf("Enter a filename to be opened.\n"); printf("If not in this directory, enter path.\n\n"); inFile = fopen(gets(namefile), "r"); if(inFile == NULL) { printf("\nFailed to open the file.\n"); exit(1); } printf("\nThe file '%s' has been successfully opened.\n", namefile); printf("\n\nThe following data is contained in the file:\n\n"); fgets(line, 81, inFile);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
printf("\nBefore uppercase conversion:\n"); printf("%s", line); for(i = 0; line[i] != '\0'; i++) line[i] = toupper(line[i]); printf("\n\nAfter uppercase conversion:\n"); printf("%s", line); fclose(inFile); printf("\n\n Ta-Da!\n\n"); } /* Assignment 6, Part B, Question 1 */ #include <stdio.h>
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include &lt;stdlib.h&gt; #include &lt;time.h&gt; enum week{Mon=1, Tue, Wed, Thu, Fri, Sat, Sun}; int main() { float randValue; int i; srand(time(NULL)); for(i = 1; i &lt;= 7; i++) randValue = rand(); int today = (1 + ((int)rand() % 7)); switch(today) { case Mon: printf(&quot;Today is Monday!\n&quot;); printf(&quot;Go to work!\n\n&quot;); break; case Tue: printf(&quot;Today is Tuesday!\n&quot;); printf(&quot;Go to work!\n\n&quot;); break; case Wed: printf(&quot;Today is Wednesday!\n&quot;); printf(&quot;Go to work!\n\n&quot;); break; case Thu: printf(&quot;Today is Thursday!\n&quot;); printf(&quot;Go to work!\n\n&quot;); break; case Fri: printf(&quot;Today is Friday!\n&quot;); printf(&quot;Go to work!\n\n&quot;); break; case Sat: printf(&quot;Today is Saturday!\n&quot;); printf(&quot;You can rest today!\n\n&quot;); break; case Sun: printf(&quot;Today is Sunday!\n&quot;); printf(&quot;You can rest today!\n\n&quot;); break; } }...
View Full Document

Page1 / 4

assignment 6 - #include &amp;amp;lt;stdlib.h&amp;amp;gt;...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online