Wednesday, 10 September 2014

C Language Program for Finding the Cube values of a Number with Example

Write a C program for finding the addition of the cube values of “n” digits using for loop statement.

//Header files
# include <stdio.h>
# include <conio.h>
# include <math.h>
 
void main()
{
    //Program variables
    int j,num,su=0;
 
    clrscr(); //function to clear previous output
    printf("Enter the value:"); //Display function
    scanf("%d",&num); //Getting input function
    for(j=1;j<=num;j++) //looping statement
    {
        su+=pow(j,3);
    }
    printf("Sum of square = %d",su);
    getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.