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();
}
# 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.