Question

10 Question 6 The following program should print out the multiplication tables in reverse, but it is not working correctly. F

in c code please
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CORRECT CODE

#include <stdio.h>

int main()
{
for(int i=9;i>0;i--){
for(int j=9;j>0;j--){
printf("%2d ",i * j);
}
//prints newline after end of each Row
printf("\n");
}

return 0;
}
CODE SNIPPET

1 #include <stdio.h> 2 3 int main() 4 { 5 for(int i=9;i>0;i--){ 6 for(int j=9;j>0;j--){ 7 printf(%d ,i+j); } 9 //prints new

OUTPUT

0 8 7 6 91 72 63 54 45 36 27 18 72 64 56 48 40 32 24 16 53 56 49 42 35 28 21 14 54 48 42 36 30 42 36 30 24 18 12 45 40 35 30

EXPLANATION

Program will give Wrong Output because of Updation Condition of the Outer loop, It should be (i--).

Add a comment
Know the answer?
Add Answer to:
in c code please 10 Question 6 The following program should print out the multiplication tables...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C programming Question1 (a) Write a C program that will print out all command line arguments,...

    C programming Question1 (a) Write a C program that will print out all command line arguments, in reverse order, one per line. Prefix each line with its index. 6 marks] (b) Consider this C code snippet int a- 100 int b- 42; inte p- &a; int q-b; p qi printf ("%d %d\n" ,a,*p); When this code is executed, what numbers will it print? [2 marks] (c) Consider this C program int main(int argc,char argv) char* target- "Apple" char vord[100] printf...

  • Please help in C: with the following code, i am getting a random 127 printed in...

    Please help in C: with the following code, i am getting a random 127 printed in front of my reverse display of the array. The file i am pulling (data.txt) is: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 when the reverse prints, it prints: 127 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 not sure why...please...

  • This is my program in C. I should be able to print out Monday, Tuesday and...

    This is my program in C. I should be able to print out Monday, Tuesday and Wednesday. However, I am not sure what I am doing wrong. Please tell me. So far I get these errors: warning: ‘enum day’ declared inside parameter list will not be visible outside of this definition or declaration const char* DayToString(enum color x)// I guess this is just a warning, nothing wrong error: parameter 1 (‘x’) has incomplete type const char* DayToString(enum color x) //I...

  • Consider the following C codes to compute the gcd of two integers. /// code 1 #include...

    Consider the following C codes to compute the gcd of two integers. /// code 1 #include <stdio.h> int gcd(int a, int b) {     while (a != b) {         if (a > b) a = a - b;         else b = b - a;     }     return a; } /// code 2 #include <stdio.h> int getint() {     int i;     scanf("%d", &i);     return i; } void putint(int i) {     printf("%d\n", i); } int main()...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive...

    Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive integers). • Prompts the user for a starting number: say 'x' • Prompts the user for an ending number: say 'y' • Prints out the multiplication table of 'x' up to the number 'y' SPECIFIC REQUIREMENTS 1. You must use the following method to load the array: public static void loadArray(int table[][], int x, int y) 2. You must use the following method to...

  • Please write the complete code in C. Write a C function that prints the minimum spanning...

    Please write the complete code in C. Write a C function that prints the minimum spanning tree of a graph. At the end, print the weight of the spanning tree. A suggested report format is shown in the following example. Source Vertex To Vertex Weight A B 2 A C 4 B D 3 D E 1 Total weight of spanning tree: 10 Your main program will read a graph from DataIn file to an adjacency table before calling the...

  • Write a complete C program that inputs a paragraph of text and prints out each unique...

    Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...

  • Write a program which: Prints out the Multiplication Table for a range of numbers (positive integers)....

    Write a program which: Prints out the Multiplication Table for a range of numbers (positive integers). Prompts the user for a starting number: say 'x' Prompts the user for an ending number: say 'y' Prints out the multiplication table of 'x' up to the number 'y' Sample outputs include:    SPECIFIC REQUIREMENTS You must use the following method to load the array: public static void loadArray(int table[ ][ ], int x, int y) You must use the following method to...

  • How would I change the following C code to implement the following functions: CODE: #include <stdio.h>...

    How would I change the following C code to implement the following functions: CODE: #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { if (argc != 2) printf("Invalid input!\n"); else { FILE * f = fopen (argv[1], "r"); if (f != NULL) { printf("File opened successfully.\n"); char line[256]; while (fgets(line, sizeof(line), f)) { printf("%s", line); } fclose(f); } else { printf("File cannot be opened!"); } } return 0; } QUESTION: Add a function that uses fscanf like this:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT