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 / 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 |
Post New Answer View All Answers
We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character
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 using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20
1+1/2!+1/3!+...+1/n!
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; }
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
Teta-Omeg-Big-Oh Show that f(n) = n2 + 3n3 is ;(n3).
how to diplay a external image of output on winxp by using c & c++,
Code for Method of Handling Factorials of Any Size?
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
how to write a program that opens a file and display in reverse order?
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
write a program that reads a series of strings and prints only those strings begging with letter "b"