top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a program for following output in C

+1 vote
469 views
1*8+1= 9
12*8+2=98
123*8+3=987
1234*8+4=9876
12345*8+5=98765
123456*8+6=987654
1234567*8+7=9876543
12345678*8+8=9876543 2
123456789*8+9=987654 321
posted Jan 11, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Here is the code for above (Tested):

#include <stdio.h>

int main()
{
    int n, i, j;
    int sum;

    printf("Enter the number of itration : ");
    scanf("%d", &n);

    for (i = 1, j = 1; i <= n; i++, j = j * 10 + i) {
        sum = j * 8 + i;
        printf("%d * 8 + %d = %d\n", j, i, sum);
    }

    return 0;
}

Sample output:

Enter the number of itration : 9
1 * 8 + 1 = 9
12 * 8 + 2 = 98
123 * 8 + 3 = 987
1234 * 8 + 4 = 9876
12345 * 8 + 5 = 98765
123456 * 8 + 6 = 987654
1234567 * 8 + 7 = 9876543
12345678 * 8 + 8 = 98765432
123456789 * 8 + 9 = 987654321
answer Jan 12, 2015 by Arshad Khan
Similar Questions
+2 votes

Hello friends I am searching the Program to print source code as program output in C programming

+3 votes

input: 1 2 3 4 5
output: 5 4 1 2 3 or 1 2 3 5 4

Can any one tell?

...