C Program to Display Sum of Some Series
There are different types of series in mathematics which can be solved easily in C programming. This section deals with finding sum of following types of series in C program.
There are different types of series in mathematics which can be solved easily in C programming. This section deals with finding sum of following types of series in C program.
A prime number is the number which can be exactly divided by only 1 and the number itself. For example, 11 can only be exactly divided by 1 and the number itself, so 11 is a prime number. But 14 can be divided by 1, 2, 7 and 14 so it is not a prime number but a composite number. C program to check whether a number is prime or composite is shown below.
A factorial of a number can be defined as the multiplication of the number itself and its descending natural numbers. Factorial is denoted by ‘!’ symbol. e.g. the factorial of 5 is 5! = 5 x 4 x 3 x 2 x 1 = 120 The factorial of 1 is 1! = 1 C program to find the factorial of a number is shown below.
C program to find the largest and smallest number among N numbers entered by the user is shown below
Constructors are the member functions that are executed automatically when an object is created. That means no explicit call is necessary to call a constructor. The name constructor is given because it constructs the value of the data member of class. Constructors are mainly used or initializing data.
Fibonacci series is the series of numbers which is found by adding the two numbers before it. For example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 … C program to display Fibonacci series is as follows.
Prime numbers are those natural numbers which has exactly two factors : 1 and itself. If a number has factors more than two, they are composite. 1 and 0 are neither prime nor composite. C program to determine if a given number is prime or not is shown below:
foreach loop is extension of For Loop. This loop executes block of statements for each member of an array. Indexes of elements are not needed for this loop, just the current element of array is available inside the loop.
A method is a block of codes that contains some statements and perform particular task. Using method increases the quality of our program a lot. Some of them are listed below:
Encapsulation is the process of collecting functions and data in one unit called class. Encapsulation is also known as process of hiding data in object oriented programming languages. Encapsulation allows specify access level of a class or its members. This protects data from being corrupted and codes will be less complex, maintainable and flexible.