// Basic demonstration of nested for loops.
#include <stdio.h>
int main(int argc, char* argv[])
{
// Outer loop will run until i equals 3
// (three times if starting at 0)
for (int i=0; i<3; ++i)
{
printf("\ti = %d\n", i);
// Nested loop will until j equals 6
// (three times if starting at 9)
for (int j=9; j>6; --j)
printf("\t\tj = %d\n", j);
}
return 0;
}
==150== Memcheck, a memory error detector
==150== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward
et al.
==150== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==150== Command: ./nested
==150==
i = 0
j = 9
j = 8
j = 7
i = 1
j = 9
j = 8
j = 7
i = 2
j = 9
j = 8
j = 7
==150==
==150== HEAP SUMMARY:
==150== in use at exit: 0 bytes in 0 blocks
==150== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==150==
==150== All heap blocks were freed -- no leaks are possible
==150==
==150== For lists of detected and suppressed errors, rerun with:
-s
==150== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The C language is likely to remain with us for the foreseeable future. Here are a few interesting points about the C language that I was able to find while reading some posts on the topic. Links to original posts included. Another useful advantage of the C language: C vs. Assembly In theory, I am a proponent of assembly language. In reality, I have reached a point in my life at which assembly language is a threat to both my financial security and my sanity. Writing firmware in assembly is slow and error-prone, and maintaining an adequate level of organization in long, complex programs is hopelessly difficult. However, I will certainly insist that you cannot really understand high-level languages if you don’t understand assembly. If you’ve never had the opportunity to gain some solid experience with assembly language, you should at least familiarize yourself with some of the basic concepts before you dive into C. The articles listed above in the Supporting Information ...
My lady is more beauteous than a rose, That in the garden sweetly doth unfold; Her radiant face outshines the sun that glows, And makes the stars seem dim and dull and cold. She is more stunning than a lightning bolt, That cleaves the sky with sudden flash and roar; Her eyes can pierce my heart with one swift jolt, And leave me breathless, shaken to the core. She is more gentle than an angel's touch, That soothes the weary soul with grace and love; Her words can heal my wounds and lift me much, And make me feel as if I soar above. She is the fairest creature ever seen, And I am blessed to have her as my queen. Prompt: Write me a sonnet using the style and vocabulary of Shakespeare about how my lady is more beautiful than a rose, more stunning than a lightning bolt, and gentle as the touch of an angel.
https://github.com/pereiradaniel/beginning_c/blob/master/ch3/exercises/3_1/exercise3_1.c // Exercise 3-1 // Write a program that will first allow a user to choose one of two options: // 1. Convert a temperature from degrees Celsius to degrees Fahrenheit. // 2. Convert a temperature from degrees Fahrenheit to degrees Celsius. // The program should then prompt for the temperature value to be entered and output the new value that results // from the conversion. To convert from Celsius to Fahrenheit you can multiply the value by 1.8 and then add 32. #include <stdio.h> #include <ctype.h> #define TOFARENHEIT(a) a*1.8+32.0 #define TOCELSIUS(a) (a-32.0)/1.8 int main(int argc, char* argv[]) { int choice = 0; // Stores user's menu choice. double temp = 0.0; // Stores user's temperature input. char repeat = 'Y'; while (toupper(repeat)=='Y') { choice = 0; while (choice == 0) { printf(...