Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/** * Author(s): * Date: * * This is a series of exercises to introduce loop * control structures. * */ #include #include #include int
/** * Author(s): * Date: * * This is a series of exercises to introduce loop * control structures. * */ #includeGenerate Multiplication Tables Write a program to generate a multiplication table. We have provided starter code in multTable.c that reads in an integer n as a command line argument. Write code to produce an n xn multiplication table for values 1 thru n. For example, if n is 5 , it should produce a table that looks like something like the following. Be sure to print the first row and column correctly! Your code should work for any value of n; if n were 10 , it would produce the following larger table. Generate Multiplication Tables Write a program to generate a multiplication table. We have provided starter code in multTable.c that reads in an integer n as a command line argument. Write code to produce an n xn multiplication table for values 1 thru n. For example, if n is 5 , it should produce a table that looks like something like the following. Be sure to print the first row and column correctly! Your code should work for any value of n; if n were 10 , it would produce the following larger table#include #include int main(int argc, char **argv) { if(argc != 2) { fprintf(stderr, "Usage: %s n ", argv[0]); exit(1); } int n = atoi(argv[1]); // A simple for loop that prints 0 thru 9 for(int i=0; i -4) { printf("%d ", k); k--; } printf(" "); //3. Print numbers 1 thru n separated by a comma except for // the last one; example: 1, 2, 3, 4, 5 //4. Print squares of numbers 1 thru n separated by a comma // except for the last one; example: 1, 4, 9, 16, 25 //5. Compute the summation of numbers 1 thru n and print // the result; example: 1 + 2 + 3 + 4 + 5 = 15 //6. Compute the summation of squares of numbers 1 thru n // and print the result; example: 1^2 + 2^2 + 3^2 + 4^2 + 5^2 = 55 //7. Compute the summation of even numbers 1 thru n and print // the result; example (n=5): 2 + 4 = 6 //8. Write a solution to the following variation of the FizzBuzz // problem. Pring out integers 1 thru n, one to a line, except // that if the integer is divisible by 7 print "Foo" instead. // If the integer is divisible by 11 print "Bar" instead. If // the integer is divisible by both 7 and 11, print "FooBar" // instead. return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started