Hello everyone,
Am stuck with a small C program question. Heres the question :
Write a program to generate and display a table of n and n2, for integer values of n
ranging from 1 to 10.Be certain to print appropriate column headings.
And this is what I've done till now :
I think most probably the part in bold is my mistake but I cant figure out a solution.Code:#include <stdio.h> int main () { int n, n2 = 0; printf ("Enter the integer values:\n\n") ; printf ("n n2\n\n") ; printf ("-- ---\n\n") ; for (n = 1; n <= 10; ++n) { n2 += n ; printf ("%i %i\n\n", n, n2) ; } getchar () ; return 0 ; }
Please help



LinkBack URL
About LinkBacks


