Here is the C program that prints the sum of all elements in an array. Output of this program: This program is good enough solution. If you are interested, you can see few other solutions in the following sections. Recursive Version We can wire a recursive function for the same purpose. Divide and Conquer We … Continue reading “C Program to Calculate the Sum of All Elements in an Array”
Category: Programming
C Program to Print Current Date and Time
Quite often we need to print the current date and time from our program. For example, when we write log messages, we generally attach the timestamp with every message. Here we’ll see how to write a C program to print the current date and time. The time() function returns the number of seconds elapsed since … Continue reading “C Program to Print Current Date and Time”
C Program to Calculate Factorial of a Number
Factorial of a number N, (N!) is 1*2*3*4*5*…..*N. Here we’ll see how to write C program to calculate the factorial value of a number. Here are the C functions that calculate the factorial value of a the input number. Using FOR Loop Using WHILE Loop Using Recursion Complete Program Any one of the above functions … Continue reading “C Program to Calculate Factorial of a Number”
C Program to Find Minimum and Maximum Numbers in an Array
Here we’ll see how to write C program to find the minimum and maximum numbers in an array. Here we assigned the first element of the array to both minimum (min) and maximum (max). Then we traverse the array from the second element to the last element. If any element is smaller than the current … Continue reading “C Program to Find Minimum and Maximum Numbers in an Array”
C Program to Print Fibonacci Series
Fibonacci series is a series of numbers where each number is the summation of two previous numbers. The first two numbers of Fibonacci series are 0 and 1. Here is an example of Fibonacci series: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377. Loop Version The function, print_fibonacci_series(), … Continue reading “C Program to Print Fibonacci Series”