How to write a C Program Give me an integer and I will sum it with the previous natural numbers in C Programming Language ?
This C Program Change an Integer Number with Addition of Previous Natural Numbers.Solution:
- #include <stdio.h>
- #include <stdlib.h>
- int geometric_sum (int a);
- int main ()
- {
- int a = 0, sum = 0;
- printf("Give me an integer and I will sum it with the previous natural numbers : ");
- scanf("%d", &a);
- sum = geometric_sum(a);
- printf("Result: %d", sum);
- }
- int geometric_sum (int a)
- {
- if (a == 0)
- {
- printf("Base case!\n");
- return a;
- }
- else
- {
- printf("1: sum (%d)\n", a);
- return a + geometric_sum(a-1);
- }
- }
Learn More :
Sum
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- C Program To Find Sum and Difference Of Two Matrices
- C Program To Print Sum Of n Digit Number
- C Program Finding the sum of Squares using Recursion
- C Program to Sum of The First and Last Digit Of 'n' Digit Number
- C Program to Sum of First and Last Digits of a Four-Digit number
- C Program to Sum of digits of a Five Digit Number
- C Program to Sum Up Digits Of A Number
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
- Input Number and Calculate Sum of it's Digits C Program
given
- C Program To Find Week Day Of A Given Date
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to Check Given String is Palindrome or Not
- C Program That in a Given Natural Number x Insert Figure c at Position p
- Return the number of tokens given a command
- C Program reads in and spews out the attributes of a given .wav file.
- C Program Recursive function that searches for a given file in a given folder
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C program to display the transpose of given 3 X 3 matrix
- C Program to convert given decimal number into binary number
Previous
Integer
- How to Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus.
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- C Program Generates 10 Random Integers Between 0 and 99.
- Lower-Upper Case/Positive-Negative Integer
- Find the union and intersection of two sets of integer store it in two array C Program
- C Program to Detect int Underflow-Overflow using if-else
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program