write a function – oriented program that calculates the sum
of the squares from 1 to n. thus, if the input is 3, the
output is 14
Answers were Sorted based on User's Feedback
Answer / shams
#include<stdio.h>
int main()
{
int n,i,sum=0;
printf("Enter a number");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+(i*i);
printf("Output:- %d",sum);
return 0;
}
Is This Answer Correct ? | 19 Yes | 12 No |
Answer / hedto
int main()
{
int n,i,sum=0;
printf("Enter a number");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+(i*i);
printf("Output:- %d",sum);
return 0;
}
int sum(int x)
{
int sum=0;
while(x>0)
{
sum+=x*x;
x--;
}
return sum;
}
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / sreejesh1987
void main()
{
int sum(int d);int n;
clrscr();
printf("Enter the no: ");
scanf("%d",&n);
printf("\nSum of squares upto %d is %d",n,sum(n));
getch();
}
int sum(int x)
{
int sum=0;
while(x>0)
{
sum+=x*x;
x--;
}
return sum;
}
Is This Answer Correct ? | 5 Yes | 10 No |
Write code for the multiplication of COMPLEX numbers?
readers and writers problem
Write a function- oriented to convert the input dollar(s) into its equivalent peso. Assume that one dollar is equivalent to 51.60
How to swap two ASCII numbers?
A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E
Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.
using repetition structure. Write a c program that will accept five numbers. The program should count and output the total count of even numbers and total count of add numbers.
Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L
how to write a program that opens a file and display in reverse order?
write a function – oriented program that calculates the sum of the squares from 1 to n. thus, if the input is 3, the output is 14