Here we have given you all the code of C Programming Lnaguage, which are best for BCA and IT Students. To view and copy the code just double tap on the programs topic given below.

Hello World Program in C.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
printf ("Hello World");
// For printing the statement
getch();
// For holding the console window
}
Program to add two number in C.

StudyMuch

#include <stdio.h>  
#include <conio.h>  
void main()
{
int a= 10, b= 10, c;
//Declaring and Initialising integer type variables

c = a + b;
// Addition of a & b and storing it to c

printf ("The sum of %d and %d is : %d", a, b, c);
//%d is used for printing integer type values
getch();
}
Program to print Factors of given number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, num;
clrscr();

printf ("Enter a number to find it's Factors: ");
scanf ("%d", &num);

printf ("Factors of the %d are: \n", num);
for (a = 1; a <= num; a++)
{
if (num%a == 0)
{
printf ("%d\t", a);
}
}
getch();
}
Program to calculate simple interest in C.

StudyMuch

#include <stdio.h>  
#include <conio.h>  
int main()
{
int amount, rate, time, si;
//Initialising Amount, Rate, Time and Standard Interest for storing Integer Values

printf ("Enter Principal Amount : ");
scanf ("%d", &amount);
//Asking user to input Amount

printf ("Enter Rate of Interest : ");
scanf ("%d", &rate);
//Asking user to input Rate of Interest

printf ("Enter Period of Time : ");
scanf ("%d", &time);
//Asking user to input Time Period

si = (amount * rate * time) / 100;
//Assigning the method of calculation for S.I. to si

printf ("Simple Interest : %d", si);
//The Result

getch();
}
Program to find the length of a string.

StudyMuch

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char a= 0, length, str[50];
clrscr();
printf ("Enter the string: ");
gets (str);

while (str[a] != '\0')
{
a++;
}
length = a;

printf ("The length of the string is: %d", length);
getch();
}
Add two number by using 'scanf' function.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, c;
printf ("Enter two numbers to add");
scanf ("%d%d",&a,&b);
// 'scanf ' is used to take input from the user after running the program

c = a + b;
// c will store the addition of a and b

printf ("Sum of entered numbers = %d", c);
getch();
}
Find out number is Even or Odd by taking value.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int number;
printf ("Enter an integer: ");
scanf ("%d", &number);

if (number % 2 == 0)
//If number is divisible by 2v {
printf ("%d is even.", number);
}

else
//If number is not divisible by 2
{
printf ("%d is odd.", number);
}

getch();
}
Program to convert Celsius to Fahrenheit.

StudyMuch

#include <stdio.h>
void main()
{
float c, f;
clrscr();
printf("Enter temp in Celsius: ");
scanf("%f", &c);

f=(1.8*c)+32;

printf("The Fahrenheit is %f", f);
getch();
}
Program to Display n amout of numbers.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{ int arr[20], n, i;
clrscr();

printf("Enter the number the elements: ");
scanf("%d", &n);
printf("Enter the elements: \n");
for(i=0; i< amp;n; i++)
{
printf("Arr [%d] = ",i);
scanf("%d", &arr[i]);
}

printf("\The array elements are: \n");
for (i=0; i< n; i++)
printf("Arr[%d] = %d\n", i, arr[i]);

getch();
}
Program to find the Factorial of a number.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{ int n, i, factorial = 1;
clrscr();

printf("Enter a number: ");
scanf("%d", &n);

if(n>0)
{
fo(i=1; i<=n; ++i)
{
factorial *= i;
}
printf("The factorial of %d! is: %d", n, factorial);
}

else
{
printf("Error! Number can't be negative."); }

getch();
}
Program to find out year is leap year or not.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int year;
printf ("Enter a year: ");
scanf ("%d", &year);
if( year%4==0)
{
if ( year%100 == 0)
{
if ( year%400 == 0)
{
printf ("%d is a Leap Year.", year);
}
else
{
printf ("%d is not a Leap Year.", year);
}
}
else
{
printf ("%d is a Leap Year.", year );
}
}
else
{
printf ("%d is not a Leap Year.", year);
}
getch();
}
Program to find 5 subject marks and calculate persentage.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, c, d, e, sum, total = 100;
float perc;
clrscr();
printf ("Enter marks of 5 subjects: ");
scanf ("%d%d%d%d%d", &a, &b, &c, &d, &e);

sum = a + b + c + d + e ;

perc = ((sum*100)/total);

if (perc < 40) printf ("You are FAIL!"); else { if (perc>= 60)
printf ("You have got 1st Division.");
else
{
if (perc >= 50)
printf ("You have got 2nd Division.");
else
printf ("You have got 3rd Division.");
}
}
getch();
}
Program to calculate Compound Interest.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
#include <math.h0>   //header file
void main()
{
int p,t;
float r,amt,ci;
clrscr();

printf ("Enter Principal Amount: ");
scanf ("%d",&p);

printf ("Enter Time: ");
scanf ("%d",&t);

printf ("Enter Rate of interest: ");
scanf ("%f",&r);

amt= p*pow((1+r/100),t);
ci = amt-p;

printf ("Simple interest: %7.2f ",ci);
printf ("Total amount: %7.2f ",amt);

getch();
}
Program to print Multiplication Table of 5.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int num=5, r;
clrscr();
printf ("The Table Of Number Two");

for (r=1;r<=10;r++)
{
printf ("%d * %d=%d", num, r, num*r);
}
getch();
}
Program to reverse a number using do-while loop.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int i, b=0, a=0;
clrscr();

printf ("Enter a number: ");
scanf ("%d", &i);

printf ("The reverse is: ");

do
{
a = i%10;
b = i/10;
i = b;
printf ("%d", a);
}

while (i>0);
getch();
}
Program to print Multiplication Table of any Number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int i, no, table=1;
clrscr();

printf ("Enter any number : ");
scanf ("%d", &no);

printf ("Table of %d", no);

for ( i=1;i<=10;i++ )

{
table=no * i
; printf ("%d", table);
printf ("\n");
}

getch();
}
Program to return a value from user-defined function.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
int sum ();
void main()
{
int a, b, c;
clrscr();

printf ("Enter two integer values to add: ");
scanf ("%d%d", &a, &b);

c = sum (a, b);

printf ("The addition is: %d", c);
getch();
}

int sum (int x, int y)
{
int add;
add = x + y;
return add;
}
Program to print multiple table from 11 to 20.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b;
clrscr();

for ( a=11; a<=20; a++)
{
printf ("The multiplication table of %d is: \n", a);

for ( b=1; b<=10; b++)
{
printf ("%d * %d = %d\n", a, b, a*b);
}
}
getch();
}
Program to find square of any number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b;
clrscr();

printf ("Enter any number to find its square: ");
scanf ("%d", &a);

b = a * a;

printf ("Square of %d is %d", a, b);
getch();
}
Program to find the Area of Circle.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
float r, area, pi= 3.14;
clrscr();

printf ("Enter radius of the Circle: ");
scanf ("%f", &r);

area = pi * r * r;

printf ("Area of Circle: %f", area);
getch();
}
Program to find the Cube of any Number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b;
clrscr();

printf ("Enter any number to find its cube: ");
scanf ("%d", &a);
b = a * a * a;

printf ("Cube of %d is %d", a, b);
getch();

}
Program to find a number is positive or negative.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a;
clrscr();
printf ("Enter a number to find whether it is a positive or negative: ");
scanf ("%d", &a);
if (a>0)
{
printf ("%d is a positive number.", a);
}

else
{
printf ("%d is a negative number.", a);
}
getch();
}
Program to find the Average of 5 Number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, c, d, e, avg;
clrscr();
printf ("Enter five numbers to find the average: ");
scanf ("%d%d%d%d%d", &a, &b, &c, &d, &e);

avg = ( a + b + c + d + e ) / 5;

printf ("Average = %d",avg);
getch();

}
Program to find a character is a voel or a consonant.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
char c;
clrscr();
printf ("Enter any character: ");
scanf ("%c", &c);
if (c == 'A' || c == 'a' || c == 'E' || c == 'e' || c == 'I' || c == 'i' || c == 'O' || c == 'o' || c == 'U' || c == 'u')
{
printf ("%c is a vowel.", c);
}

else
{
printf ("%c is a consonant.", c);
}

getch();
}
Program to swap two numbers without function.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, c;
clrscr();

printf ("Enter two numbers to swap: ");
scanf ("%d%d", &a, &b);

c = a + b;

b = c - b;
// Subtracting the value of b from c, then we'll get value of a

a = c - a;
// Subtracting the value of a from c, then we'll get value of b

printf ("The values after swapping are: %d and %d", a, b);
getch();
}
Program to reverse the given numbers using while loop.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, number = 0, remainder;
clrscr();

printf ("Enter an integer: ");
scanf ("%d", &a);

while (a!=0)
{
remainder = a%10;
number = number*10 + remainder;
a/= 10;
}

printf ("Reversed Number is %d.", number);

getch();
}
Program to print Fibonacci Series up to n numbers.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, x=0, y=1, z;
clrscr();

printf ("Enter the number of terms for Fibonacci Series: ");
scanf ("%d", &a);

printf ("\nFibonacci Series is: ");

for (b = 1; b <= a; ++b)

{
printf ("%d\t", x);
z = x + y;
x = y;
y = z;
}
getch();
}
Program to showing use of static variable.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
int data()
{
static int count = 100;
count++;
return count;
}

int main()
{
clrscr();
printf ("Increment by 1 is %d.\n", data());
getch();
return 0;
}
Program to find predcessor and successor of a number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, c;
clrscr();

printf ("Enter a number to find it's predecessor & successor: \n");
scanf (%d, &a);
b = a + 1;
printf ("The successor of %d is: %d\n", a, b);

c = a - 1;
printf ("The predecessor of %d is: %d\n", a, c);

getch();
}
Program to calculate factorial of a number with function.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
long factorial(int);
int main()
{
int number;
clrscr();

printf ("Enter a number to calculate it's factorial: ");
scanf ("%d", &number);

printf ("%d! is %ld\n", number, factorial(number));

getch();
return 0;
}

long factorial(int n)
{
int a;
long result = 1;

for (a = 1; a <= n; a++)
result = result * a;

return result;
}
Program ot calculate factorial of a number using recursion.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
int rec (int);
void main()
{
int a, fact;
clrscr();

printf ("Enter a number to calculate it's Factorial: ");
scanf ("%d", &a);

fact = rec (a);
printf ("\nFactorial of %d is %d.", a, fact);
getch();
}
int rec (int x)
{
int f;

if (x==1)
return 1;

else
f = x * rec(x-1);

return (f);
}
Program to find the Armstrong Number.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int a, b, sum=0, temp;
clrscr();

printf ("Enter a number: ");
scanf ("%d", &a);

temp = a;
while (a>0)
{
b = a%10;
sum = sum+(b*b*b);
a = a/10;
}
if (temp==sum)
printf ("The number is an Armstrong Number.");
else
printf ("The number is not an Armstrong Number.");
getch();
}
Program for swapping using call by reference.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void swap (int *, int *);
void main()
{
int a, b;
clrscr();

printf ("Enter two values: \n");
scanf ("%d%d", &a, &b);
printf ("Values of a and b before swapping is %d and %d respectively\n", a, b);

swap(&a, &b);
printf ("Values of a and b after swapping are %d and %d respectively\n", a, b);

getch();
}

void swap (int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
Program for swapping using call by value.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void swap (int, int);
void main()
{
int a, b;
clrscr();

printf ("Enter two values: ");
scanf ("%d%d", &a, &b);

printf ("\nValues before swapping are %d and %d.", a, b);
swap (a, b);
getch(); }

void swap (int x, int y)
{
int temp;
temp = x;
x = y;
y = temp;

printf ("\nValues after swapping are %d and %d.", x, y);
}
Program to implement break statement.

StudyMuch

#include <stdio.h>   //header file
#include <conio.h>   //header file
void main()
{
int i;
double number, sum = 0.0;

for (i=1; i <= 10; ++i)
{
printf ("Enter a n%d: ", i);
scanf ("%lf", &number);

// If user enters negative number, loop is terminated
if (number < 0.0)
{
break;
}
sum += number;   // sum = sum + number;
}

printf ("Sum = %.2lf", sum);

return 0;
}
Program to access and print an array of 5 elements.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{
int num[5], a;
clrscr();

printf ("Enter the elements: \n");
for ( a=0;a< 5;a++ )
{
scanf ("%d", &num[a]);
}
printf ("The elements are: \n");
for (a=0;a< 5;a++)
{
printf ("%d\t", numb[a]);
}
getch();
}
Program to swap two numbers using call by reference.

StudyMuch

#include <stdio.h>
#include <conio.h>
void swap(int *a, int *b);
// Declaring the function
void main()
{
int x, y;
clrscr();
printf("Enter two numbers: ");
scanf("%d%d", &x, &y);

printf("Before swapping, First value is %d and Second value is %d", x, y);
swap(&x, &y);
// Calling the function

printf("\nAfter swapping, First value is %d and Second value is %d", x, y);
getch();
}

void swap(int *a, int*b)
// Defining the function
{
int z;
z = *a;
*a= *b;
*b= z;
}
Program to find the sum of elements of an array.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{
int a, sum= 0, arr[5];
clrscr();

printf ("Enter 5 elements to find sum: \n");

for ( a=0; a<5; a++)
{
scanf ("%d", &arr[a]);
sum += arr[a];
}
printf ("The sum of array is: %d", sum);
getch();
}
Program to find the length of the String entered by user.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{
int i= 0;
char ch, str[20];
clrscr();

printf ("Enter the string: ");
gets(str);
ch=str[0];
while (ch!='0')
{
i++;
ch= str[i];
}

printf ("Length is %d", i);
getch();
}
Program to find the largest and smallest element of a 1D Array.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{
int arr[10], i, max, min, a;
clrscr();

printf ("Enter the number of the elements of an array: ");
scanf ("%d", &a);
printf ("Enter %d elements of the array: ", a);
for ( i=0; i<a; i++ )
{
scanf ("%d", &arr[i]);
}

max = arr[0];
min = arr[0];

for ( i=1; i<a; i++ )
{
if ( arr[i]>max )
{
max = arr[i];
}

if ( arr[i]<min )
{
min = arr[i];
}
}

printf ("Largest element is %d\n", max);
printf ("Smallest element is %d", min);

getch();
}
Program to declare a user defined array and print the sum of odd and even numbers.

StudyMuch

#include <stdio.h>
#include <conio.h>
void main()
{
int a[10], i, sume=0, sumo= 0, n;
clrscr();

printf ("Enter the size of an array: ");
scanf ("%d", &n);

if (n<=10)
{
printf ("Enter the array data: ");
for (i=0;i<n;i++)
{
scanf ("%d", &a[i]);
}
for (i=0;i<n;i++)
{
if (a[i]%2==0)
sume = sume + a[i];
else
sumo = sumo + a[i];
}

printf ("Sum of odd number = %d and sum of even number = %d", sumo, sume);
}
else

printf ("\nSize is too large.");
getch();
}
www.000webhost.com