[Courses] C Programming For Absolute Beginners, Lesson 4: Getting Looped
Damián
detaras at gmail.com
Tue Mar 6 23:47:25 UTC 2012
On 03/05/2012 11:34 PM, Carla Schroder wrote:
> HOMEWORK
>
> Modify the last example to display two columns of output that use the 'a' and
> 'total' variables. Play around with spacing and line breaks.
>
> Make a box around your program, like
>
> +++++++++++++++++++++++++++++
> +This is my awesome loopy program +
> + +
> + See the value of a in each +
> + loop in a nice table +
> +________ +
> + 12 +
> + 16 +
> + 20 +
> + 24 +
> + 28 +
> ++++++++++++++++++++++++++++++
>
>
> Next week we shall take a deep dive into functions. We've been using them all
> along, so it's high time to start understanding them in more depth.
Hi all, I made all the homework in one single program. I don't know if
it will look good in every terminal, but at least, it looks good in mine :P
========================
//loopysample
#include <stdio.h>
int main() {
int a = 0;
int total = 0;
printf("*****************************************\n");
printf("* This is my awesome loopy sample\t*\n");
printf("*\t\t\t\t\t*\n");
printf("* See the value of a and total\t*\n");
printf("* in each loop in a nice table\t*\n");
printf("* _______________________________\t*\n");
for(a = 1; a <= 15; a = a + 1) {
total = total + a;
printf("*\t\t%i\t%i\t\t*\n", a, total);
}
printf("*****************************************\n");
return 0;
}
=====================
More information about the Courses
mailing list