#include
#include
void main()
{
int sum_sqr(int n);
clrscr();
printf("%d",sum_sqr(5));//Sum of first 5 natural numbers' square values
getch();
}
int sum_sqr(int n)
{
int i,sum=0;
for(i=1;i<=n;i++)
{
sum=sum+(i*i);
}
return sum;
}
output:
55
#include<iostream>
#include<random>
#include<time.h>
int main()
{
// pseudo-random number generator (range: 10 to 20, inclusive)
std::default_random_engine generator;
generator.seed ((unsigned) time (NULL));
std::uniform_int_distribution<unsigned> distribution (10, 20);
unsigned sum = 0;
unsigned n = distribution (generator);
for (unsigned i=0; i<n; ++i)
{
unsigned num = distribution (generator);
unsigned sqr = num * num;
std::cout << num << " squared is " << sqr << std::endl;
sum += sqr;
}
std::cout << "Sum of squares is " << sum << std::endl;
}
#include<stdio.h>
main()
{
int i,n,sum = 0;
printf("Program to find sum of n natural number\n");
printf("Enter the value of n ");
scanf("%d",&n);
for (i = 0;i <= n;i++)
{
sum = sum + i * i;
}
printf("The sum is %d",sum);
}
size_t sum_of_squares(size_t n)
{
size_t sum {0};
while (n)
{
sum += (n*n);
--n;
}
return sum;
}
#include
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
Write an. Algorthim. To. Find the. Sum. Of. First15 natural. Numbers
write a lex program to delete space from the program
First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.
#include
No.First of all, you can't write negative numbers as sums of perfect squares at all - since all perfect squares are positive.Second, for natural numbers (1, 2, 3...) you may need up to 4 perfect squares: http://en.wikipedia.org/wiki/Lagrange's_four-square_theoremNo.First of all, you can't write negative numbers as sums of perfect squares at all - since all perfect squares are positive.Second, for natural numbers (1, 2, 3...) you may need up to 4 perfect squares: http://en.wikipedia.org/wiki/Lagrange's_four-square_theoremNo.First of all, you can't write negative numbers as sums of perfect squares at all - since all perfect squares are positive.Second, for natural numbers (1, 2, 3...) you may need up to 4 perfect squares: http://en.wikipedia.org/wiki/Lagrange's_four-square_theoremNo.First of all, you can't write negative numbers as sums of perfect squares at all - since all perfect squares are positive.Second, for natural numbers (1, 2, 3...) you may need up to 4 perfect squares: http://en.wikipedia.org/wiki/Lagrange's_four-square_theorem
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
10 CLS 20 FOR n = 1 to 10 30 PRINT n, n^2, n^3 40 NEXT n 50 PRINT: PRINT: PRINT "Touch 'x' to go again, any other key to end." 60 INPUT a$ 70 IF a$ = "X" or a$ = "x" THEN 10 80 END
Write an. Algorthim. To. Find the. Sum. Of. First15 natural. Numbers
write a lex program to delete space from the program
First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.
write an assembly language program to find sum of N numbers
1. Design an algorithm to compute sum of the squares of n numbers?
write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html
fdsgfhgdfhgdf
How to write a program for mouse in microprocessor?