An application takes inputs in various ways. It can ask for input from user while it is running. It can read something from file or socket. Another way is, we can give inputs in time of starting the application in the form of command line arguments. For example, when we run Linux commands we give … Continue reading “Command Line Arguments in C Programming”
Category: C
C Program to Calculate the Sum of All Elements in an Array
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”
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”