Difference between revisions of "CSC231 Homework 7 2017"
(→Problem #1: Programming in C) |
(→Your Assignment) |
||
Line 69: | Line 69: | ||
==Your Assignment== | ==Your Assignment== | ||
<br /> | <br /> | ||
− | * Modify '''hw7_1.c''' so that it creates a logo with the | + | * Modify '''hw7_1.c''' so that it creates a '''logo''' with the sentence entered by the user on the command line, as illustrated in the examples below. |
− | + | * Here are some examples of what your program should emulate ''exactly'': | |
− | * Here are some examples of what your program should emulate: | ||
<br /> | <br /> | ||
− | 231b@aurora ~/hw/hw7 $ ./hw7_1 hello | + | 231b@aurora ~/hw/hw7 $ '''./hw7_1 hello''' |
* | * | ||
** | ** | ||
Line 92: | Line 91: | ||
** | ** | ||
* | * | ||
− | 231b@aurora ~/hw/hw7 $ ./hw7_1 my hat | + | 231b@aurora ~/hw/hw7 $ '''./hw7_1 my hat''' |
* | * | ||
** | ** | ||
Line 112: | Line 111: | ||
** | ** | ||
* | * | ||
− | 231b@aurora ~/hw/hw7 $ ./hw7_1 A | + | 231b@aurora ~/hw/hw7 $ '''./hw7_1 A''' |
* | * | ||
** | ** | ||
Line 122: | Line 121: | ||
** | ** | ||
* | * | ||
− | 231b@aurora ~/hw/hw7 $ ./hw7_1 this works well | + | 231b@aurora ~/hw/hw7 $ '''./hw7_1 this works well''' |
* | * | ||
** | ** | ||
Line 162: | Line 161: | ||
<br /> | <br /> | ||
+ | ==Submission== | ||
<br /> | <br /> | ||
+ | * Submit your program in the Homework 7 section on Moodle. | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
+ | =Problem 2= | ||
<br /> | <br /> | ||
+ | ...to be announced soon... | ||
<br /> | <br /> | ||
+ | =Problem 3= | ||
<br /> | <br /> | ||
+ | ...to be announced soon... | ||
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 07:43, 8 April 2017
--D. Thiebaut (talk) 08:28, 8 April 2017 (EDT)
Page under construction!
Problem #1: Programming in C
- Create the C program below, and run it. Name it hw7_1.c. It will serve as the seed for your solution program for Problem 1.
/* hw7_1.c D. Thiebaut This program gets a sstring from the command line and prints it on the screen. */ #include <stdio.h> #include <stdlib.h> #include <string.h> //-------------------------------------------------------------------- // MAIN PROGRAM //-------------------------------------------------------------------- void main( int argc, char *argv[] ) { //--- variables --- int n, i, name; char sentence[100]; char stars[100]; //--- see if use entered arguments on the command line --- if ( argc < 2 ) { //--- No, didn't. Print syntax information and quit --- printf( "Syntax: %s string [string...]\n", argv[0] ); exit( 1 ); } //--- print the arguments back to the user, with a dash in between --- for ( i = 1; i < argc; i++ ) { if ( i > 1 ) printf( "-" ); printf( "%s", argv[i] ); } printf( "\n" ); //--- Done! --- }
- Here are different ways of using it...
231b@aurora ~/hw/hw7 $ gcc -o hw7_1 hw7_1.c 231b@aurora ~/hw/hw7 $ ./hw7_1 hello hello 231b@aurora ~/hw/hw7 $ ./hw7_1 hello there hello-there 231b@aurora ~/hw/hw7 $ ./hw7_1 hello there CSC231! hello-there-CSC231!
Your Assignment
- Modify hw7_1.c so that it creates a logo with the sentence entered by the user on the command line, as illustrated in the examples below.
- Here are some examples of what your program should emulate exactly:
231b@aurora ~/hw/hw7 $ ./hw7_1 hello * ** *** **** ***** ****** ******* ******** * hello * ******** ******* ****** ***** **** *** ** * 231b@aurora ~/hw/hw7 $ ./hw7_1 my hat * ** *** **** ***** ****** ******* ******** ********* * my hat * ********* ******** ******* ****** ***** **** *** ** * 231b@aurora ~/hw/hw7 $ ./hw7_1 A * ** *** **** * A * **** *** ** * 231b@aurora ~/hw/hw7 $ ./hw7_1 this works well * ** *** **** ***** ****** ******* ******** ********* ********** *********** ************ ************* ************** *************** **************** ***************** ****************** * this works well * ****************** ***************** **************** *************** ************** ************* ************ *********** ********** ********* ******** ******* ****** ***** **** *** ** *
Submission
- Submit your program in the Homework 7 section on Moodle.
Problem 2
...to be announced soon...
Problem 3
...to be announced soon...