Write a C program to find the sum of squares of first n natural numbers.
int main() {
int num, square, sum = 0, i = 1;
/* get the input value for n from user */
printf("Enter the value for n:");
scanf("%d", &num);
/* calculate the square of 1st n natural numbers */
while (i <= num) {
square = i * i;
sum = sum + square;
i++;
}
/* print the sum of square of first n natural nos */
printf("Sum of squares of first %d natural"
" numbers is %d\n", num, sum);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Enter the value for n:10
Sum of squares of first 10 natural numbers is 385
Enter the value for n:10
Sum of squares of first 10 natural numbers is 385
ReplyDeleteNonton Bokep Terbaru Jav
Nonton Bokep Full HD
Nonton Bokep Indonesia Artis
Nonton Bokep JAV HD
Cewek SMA DiSodokMemek Nya Berdarah
Nonton Bokep Terbaru
Agen Poker Online No 1
Royalflush88 Agen Poker Terbaik
Agen Poker Royalflush88 Daftar Disini
Agen Bola Online No 1 Terbaik