Swapping of numbers in c

C program to swap 2 numbers

This C program is to swap two numbers with and without using third variable. Swapping is used in sorting process to arrange the numbers in particular order. SWAPPING USING TEMPORAL VARIABLE #include<stdio.h> #include<conio.h> main() { int x, y, temp; printf("Enter the value of x and y ");   ..

Addition of n numbers

C program for adding n numbers

This c program add n numbers which will be entered by the user. #include<stdio.h> #include<conio.h> main() { int n, sum = 0, a, var; printf("Enter the number of integers for addition\n"); scanf("%d",&n); printf("Enter %d numbers\n",n); for ( a  ..

To check for vowel

C program to find vowel or not

This code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked. #include<stdio.h> #include<conio.h> main() { char ch; printf("Enter a character\n"); scanf("%c",&ch); if ( ch  ..

String copy in c

C program to copy strings

This program copy string using library function strcpy. #include<stdio.h> #include<string.h> main() { char source[] = "C program"; char destination[50]; strcpy(destination, source); printf("Source string: %s\n", source); printf("Destination string: %s\n", destination); return 0; } output Source string: C program destination: C program   ..

String compare in c

C program to compare strings

This c program compares two strings using strcmp function. #include<stdio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the first string\n"); gets(a); printf("Enter the second string\n"); gets(b); if( strcmp(a,b) == 0 ) printf("Entered strings  ..

String concetenate in c

C program to concatenate strings

This program concatenates strings, for example if the first string is "hello" and second string is "world" then on concatenating these two strings we get the string "helloworld". To concatenate two strings we use strcat function of string.h. #include<stdio.h> #include<conio.h> #include<string.h> main() { char a[100], b[100]; printf("Enter the first  ..

String reverse in c

C program to reverse a string

This program reverses a string entered by the user. For example if a user enters a string "hello" then the reversed string will be "olleh". #include #include main() { char a[100]; printf("Enter a string to reverse\n"); gets(a); strrev(a); printf("Reversed string  ..

Program to find total salary

To find total salary with If Else

This program calculates the total salary of a person with IF-ElSE #include<stdio.h> #include<conio.h> void main () { long int sal,hra,ta,ts; clrscr (); printf ("Enter Salary: "); scanf("%ld",&sal); if (sal>=5000) { hra=sal*.10; ta=sal*.07; } else { hra=sal*.08; ta=sal*.05; } ts=sal+hra+ta; printf ("\n\nTotal Salary is Rs.%ld", ts); getch (); } output: Enter salary 2500 Total salary 2825   ..

Fibonacci series

To generate fibonacci series for a given number

#include "stdio.h" #include "conio.h" void main() { int a,b,c,i,n; clrscr(); a=0; b=1; printf("\n enter n value "); scanf("%d",&n); printf("\n FIBONACCI SERIES\n"); printf("\t%d\t%d",a,b); for(i=0;i<n;i++) { c=a+b; a=b; b=c; printf("\t%d",c); } getch(); } OUTPUT enter n value 5 FIBONACCI SERIES 0 1 1 2 3   ..

Example for enum operator

What is enum data type

What is enum datatype? Enumeration is a data type. We can create our own data type and define values that the variable can take. This can help in making program more readable. enum definition is similar to that of a structure. In the below program we have created a enumerated data type  ..

Test c plus plus cpp on linux

How to write a c plus plus program

Install C++ / gcc compiler on LINUX # yum install gcc gcc-c++ autoconf automake To write or execute a C++ program on linux follow the steps given below. g++ is the compiler the have to be used for executing C++ program. You must use .cpp file extension rather than a .c  ..

Test c program on linux

How to test gcc is working

Install C / gcc compiler on LINUX # yum install gcc gcc-c++ autoconf automake Now lets start write our first C program # vi first.c #include <stdio.h> int main() { printf("Hello, World\n");   ..

Install c cpp compiler linux

How to install C and C++ compiler

To install c or c++ compilers on linux use yum or rpm. In order to compile and use c/c++ under Linux you need following packages 1) auoconf 2) automake 3) gcc [GNU GCC C compiler] 4) gcc-c++ [GNU GCC C++ compiler] autoconf : GNU's Autoconf is a tool for configuring source code and Makefiles. make/automake : A  ..

Installing c on linux os

Gcc install on linux

It was difficult to install C in olden days, but no it has become very easy to install c / c++ compiler. GCC stands for GNU Compiler Collection. And it contains compilers for various languages such as C,C++,Java and so on. It is one of the most efficient free implementation  ..

Implementation of levenshtein distance in c++

Algorithm Levenshtein Distance C++

In C++, the size of an array must be a constant, and this code fragment causes an error at compile time: int sz = 5; int arr[sz]; This limitation makes the following C++ code slightly more complicated than it would be if the matrix could simply be declared as a two-dimensional array,  ..

Previous 1 2 3 4 Next

Tech Bluff