Question

Write a C program that will show the following output: 20 14 8 2 -4 -10...

Write a C program that will show the following output: 20 14 8 2 -4 -10 … …. (n terms, where you can specify n).

Homework Answers

Answer #1

A required C program is as follows,

#include <stdio.h>

int main()

{

//Declare the variables

int n, i;

//Declare and initialize necessary variable

int value=20;

//Prompt the user to enter number of terms

printf("Enter number of terms: ");

//Get number of terms

scanf("%d", &n);

//Execute for n terms

for(i=0;i<n;i++)

{

//Print the value

printf("%d ",value);

//Update the value

value=value-6;

}

return 0;

}

outputs

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Coral,write a program that reads a list of 10 integers and outputs those Integers in...
In Coral,write a program that reads a list of 10 integers and outputs those Integers in Reverse. For coding Simplicity, follow each output integer by a space, including the last one. Then, output a new line. Example if the input is 2 4 6 8 10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 to achieve above first read the integers into an array. Then output the array in reverse
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
Write a program that solves exercises 1.3 or 1.5. If you solve both correctly, 20 extra...
Write a program that solves exercises 1.3 or 1.5. If you solve both correctly, 20 extra points will be given. For Exercise 1.3, you can use only the following C++ function or its Java equivalent to output the results of your program: void printDigit(char c ){     if (c=='-' || c=='+' || c=='.' || c == '\n' || (c>='0' && c<='9')){         cout << c;         return;     }          cout << "Invalid characters." << endl;     return;     ...
using C++ 1) write a program to calculate to avg of N number of subjects. 2)write...
using C++ 1) write a program to calculate to avg of N number of subjects. 2)write a program to find the factorial of 5! 5*4*3*2*1 3)write a program to display the multiplication table for any number please enter number : 3 1*3=3 2*3=6 2*4= 10*3=30 4) find the factorial on n
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++ Note: The letter C in the output must be uppercase. #include <iostream> using namespace std; int main() {   cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";   cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";   return 0; } this is my woek #include <iostream> using namespace std; int main() { cout<<"CCCCCCCCC ++...
Write a Java program to print the result of the following operations. Your program should contain...
Write a Java program to print the result of the following operations. Your program should contain 4 methods (for each of given data sets). Yes, methods here are not structurally necessary, this requirement is only for you to get practice writing methods. Test Data: a. -8 + 4.0 * 6 b. (11+9) % 9 c. 20 + (-3)*3.0 / 8 d. 5 + 14 / 3 * 2 - 7 % 3 Your program:
(C++) Write a program whose input is two characters and a string, and whose output indicates...
(C++) Write a program whose input is two characters and a string, and whose output indicates the number of times each character appears in the string. Ex: If the input is: n M Monday the output is: 1 1 Ex: If the input is: z y Today is Monday the output is: 0 2 Ex: If the input is: n y It's a sunny day the output is: 2 2 Case matters. Ex: If the input is: n N Nobody...
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
Lab 6    -   Program #2   -   Write one number to a text file. Use the write()...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write() and read() functions with binary                                                        data, where the data is not char type.              (Typecasting is required) Fill in the blanks, then enter the code and run the program. Note:   The data is int type, so typecasting is            required in the write() and read() functions. #include <iostream> #include <fstream> using namespace std; int main() {    const int SIZE = 10;   ...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT