C Program for Linear Search

The below code will perform linear search on an array.Linear search has a time complexity of O(n). Logic: In linear search each element of the array is checked for target element one by one. Code: #include <stdio.h>  #include <conio.h> void...

C Program for Second Maximum and Second Minimun in an One-Dimensional Array

There are two approaches to calculate maximum,minimum,second-maximum and second-minimum. The first one is through sorting.You can sort the array in ascending or descending order and can get the required degree of number i.e max,min,etc. The second approach...

C Program for Maximum and Minimun number in an One-Dimensional Array

The below code will find the maximum and minimum numbers in an array. Logic: Use linear search to search for the max and min numbers. Code: #include <stdio.h> #include <conio.h>   void main() {    int i,size,max,min;  ...

C Program for Sum of Numbers in an One-Dimensional Array

The below code will generate the sum of all the numbers stored in an 1D-Array. Logic: Add all the numbers from index zero to the last index Code: #include <stdio.h> #include <conio.h> void main() {    int i,sum;   ...

C program for swapping of two Variables without using temporary variable

Logic:          To swap two variable we will add the both variables and store in first variable, then we will subtract second from first and store in second so we will get value of first variable in Second Variable. Then from...

C Program to tokenize a string using Strtok

Strtok is the built-in function of <String.h> header file. Code: #include<stdio.h> #include<conio.h> #include<string.h> void main () { char input[100], *tokenptr; int lenth,i=0,j,temp,count=0; printf("Enter string to Tokenize...

C Program to tokenize a string Without using Strtok

Logic :          To tokenize a string without using strtok we will simply use assignment operator '='. The logic is that where the character is found (on basis of which you want to tokenize) place there a '\n' this will...

C program for swapping of two Variables

Logic:            we have two variables of type int say a and b. we want to shift the value of a into b and vice versa. For this purpose we need another temporary variable say temp. we will shift value of a into temp. Then...

C program to Print Triangle

The below code prints a triangle of height 'h' taken from the user.    *    * *    * * *    * * * *    * * * * * Code: #include <stdio.h> #include <conio.h>void main(){   ...

Right Angle Triangle Checker C program

The below code checks whether a triangle is right angled or not by taking input the lengths of all three sides. Logic: By Pythagoras theorem,  (hypotenuse)^2 = (base)^2+(perpendicular)^2 If the input data satisfies the above equation then...

Even-Odd Checker C program

The below code checks whether a number is even or odd using switch structure. Logic:  If a number is divided by 2 and the remainder is zero then that number is an even number. Code: #include <stdio.h>#include <conio.h>void main(){   ...

C program for Simple Calculator using Switch Case Statement

The below code will create a simple calculator with the Switch structure; Logic:  Each case is designed to work with a specific switch, in this case  switches are the   mathematical operators i.e " +, - , * , / , % (for remainder-modulus)...

C program for Sum of digits of a Number

The below code will calculate the sum of digits of an integer number. Logic: An integer number like 54321 can be separated into digits by dividing it by 10.If 54321 is divided by 10 then we get remainder 1,and number becomes 5432,if we repeat this...

Prime Number - Checker C Program

The below code checks whether the entered number is prime or not. Logic: Prime numbers are defined as the numbers which are only divisible by one or itself. This can be checked by dividing the number from 2 to that number.If the number is divisible...

C program for simple Calculator

The below code will create a simple calculator with the use of if-else-if control structure.  Code: #include<stdio.h> #include<conio.h> void main() {     int a,b,mod;     float x,y,sum,sub,mul,div;    ...

C program to Print Right Angle Triangle

The below code prints a right angle triangle of height h taken from the user,         *        **        ***       ****     ***** Logic:...

TEST

this is our test post.....huge load of source codes is on the way...
Newer Posts
© Copyright 2025 Encyclopedia of C | Designed By Code Nirvana
Back To Top