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
Answer Posted / 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 |
Post New Answer View All Answers
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?
write a program to perform generic sort in arrays?
Code for Method of Handling Factorials of Any Size?
how to write a program that opens a file and display in reverse order?
Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37
write a program that reads a series of strings and prints only those strings begging with letter "b"
What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
how to diplay a external image of output on winxp by using c & c++,
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
1+1/2!+1/3!+...+1/n!
A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.