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 |
how to diplay a external image of output on winxp by using c & c++,
1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.
write a program to perform generic sort in arrays?
output for printf("printf");
what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }
develop a program to calculate and print body mass index for 200 employees
0 Answers Jomo Kenyatta University,
How can I Draw an ellipse in 3d space and color it by using graph3d?
Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
1 Answers Motorola, Qatar University,
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
write a program to calculate the radius for a quadratic equation use modular programming(function abitraction)hint use quadratic function
1 Answers ICAN, Jomo Kenyatta University,
what is the use of using for loop as "for(;;)"?