> Hello i am facing problem in c programming?

Hello i am facing problem in c programming?

Posted at: 2014-12-18 
How to add all number after square them and print in C programming (For loop case)



Did you write the code that produced the table above? If so, show us the code.

Edit:

Replace sum = sum + number; with:

sum += number; // does the same thing as your statement

sum2 += square;

sum3 += cube;

Note: A picture of code is NOT code. In the future, if someone asks for code, you should supply the actual text so they can run it. You can use a code-posting site such as ideone.com or codepad.org and then paste the link here.

You could also calculate cube with:

cube = square * number;

You can use following code for it

int n,i;

n=10;

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

{

printf("%d %d %d",i,i*i,i*i*i);

}

here is the code



Try:

#include

int main( void ) {

? ? int i, sum, sum2, sum3;

? ? sum= sum2= sum3= 0;

? ? printf( "\tNumber\tSquares\tCube\n" );

? ? for ( i= 1; i <= 10; ++i ) {

? ? ? ? printf( "\t%-6d\t%-6d\t%-6d\n", i, i*i, i*i*i );

? ? ? ? sum += i, sum2 += i*i, sum3 += i*i*i;

? ? }

? ? for ( i= 0; i < 48; ++i ) putchar( '-' );

? ? printf( "\nSum:\t%-6d\t%-6d\t%-6d\n", sum, sum2, sum3 );

? ? return 0;

}

How to add all number after square them and print in C programming (For loop case)