assignment 6 - #include<stdlib.h>#include<time.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 <stdlib.h> #include <time.h> enum week{Mon=1, Tue, Wed, Thu, Fri, Sat, Sun}; int main() { float randValue; int i; srand(time(NULL)); for(i = 1; i <= 7; i++) randValue = rand(); int today = (1 + ((int)rand() % 7)); switch(today) { case Mon: printf("Today is Monday!\n"); printf("Go to work!\n\n"); break; case Tue: printf("Today is Tuesday!\n"); printf("Go to work!\n\n"); break; case Wed: printf("Today is Wednesday!\n"); printf("Go to work!\n\n"); break; case Thu: printf("Today is Thursday!\n"); printf("Go to work!\n\n"); break; case Fri: printf("Today is Friday!\n"); printf("Go to work!\n\n"); break; case Sat: printf("Today is Saturday!\n"); printf("You can rest today!\n\n"); break; case Sun: printf("Today is Sunday!\n"); printf("You can rest today!\n\n"); break; } }...
View Full Document

This document was uploaded on 01/22/2011.

Page1 / 4

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

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