Matrix Multiplication in C

Matrix Multiplication in C

Matrix multiplication in C

In this program, I have discussed about how to multiply two matrices using C programming language.
#include<stdio.h>
int main()
{
 int ar1[50][50],ar2[50][50],mul[20][20],i1,i2,j2,j1,k,l,row1,col1,row2,col2,z,m,n,w;
printf("Enter the number of rows of 1st array: \n");
scanf("%d",&row1);
printf("Enter the number of columns in 1st  array: \n");
scanf("%d",&col1);
for(i1=0;i1<row1;i1++)
{
for(j1=0;j1<col1;j1++)
{
printf("\nEnter an element for %dth row and %dth column of 1st array: ",i1,j1);
scanf("%d",&ar1[i1][j1]);
}
}
printf("\nEnter the number of rows of 2nd array: \n");
scanf("%d",&row2);
printf("\nEnter the number of columns in 2nd  array: \n");
scanf("%d",&col2);
for(i2=0;i2<row2;i2++)
{
for(j2=0;j2<col2;j2++)
{
printf("\nEnter an element for %dth row and %dth column of 2nd array: ",i2,j2);
scanf("%d",&ar2[i2][j2]);
}
}
printf("\n");
if(col1!=row2)
{ printf("Matrix multiplication is not possible !!");
}
else
{ for(k=0;k<col1;k++)
{
for(l=0;l<col1;++l)
{ mul[k][l]=0;
for(w=0;w<col1;w++)
{
mul[k][l]+=ar1[k][w]*ar2[w][l];
}

}
}

for(m=0;m<row1;m++)
{
for(n=0;n<col2;n++)
{ printf("%d  ",mul[m][n]);
}
printf("\n");
}
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.
Now you can do Matrix multiplication in C.
,

C program to find GCD of two or three numbers using function

 C program to find GCD of two or three numbers using function

GCD of two or three numbers using function


 In this program, I have discussed about how to find the GCD of two or three number using function in the C programming language.


The full form of GCD is greatest common divisor. If we consider three number 10,15,20 then the GCD of these three number will be 5.


int hcf2(int,int);
int hcf3(int,int,int);
 int main()
{ int a,b,c,d,hc1,hc2,n;
printf("Enter the number of numbers whose HCF you want to calculate (2<=number<=3) \n");
scanf("%d",&n);
switch(n)
{ case 2:
printf("Enter two numbers \n");
scanf("%d%d",&a,&b);
hc1=hcf2(a,b);
printf("The HCF of %d and %d is %d \n",a,b,hc1);
break;
case 3:
printf("Enter three numbers \n");
scanf("%d%d%d",&a,&b,&c);
hc2=hcf3(a,b,c);
printf("The HCF of %d, %d and %d is %d \n",a,b,c,hc2);
break;
}
}
int hcf2( int k1,int k2)
{
int i,h1=0;
 for(i=1;i<=k1;i++)
{
if(k1%i==0&&k2%i==0)
{
if(i>h1)
{h1=i;
}
}
}
return h1;
}
int hcf3( int k1,int k2,int k3)
{int i,h2=0;
 for(i=1;i<=k1;i++)
{
if(k1%i==0&&k2%i==0&&k3%i==0)
{
if(i>h2)
{h2=i;
}
}
}
return h2;
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

Program to find GCD of two or three numbers in C

Program to find the GCD of three numbers in C

GCD of three numbers in C

 In this program, I have discussed about how to find the GCD of three numbers in C.

#include<stdio.h>
int main()
{ int a,b,c,d,hcf=0,i;
printf("Enter three numbers: \n");
scanf("%d%d%d",&a,&b,&c);
for(i=1;i<=a;i++)
{
if(a%i==0&&b%i==0&c%i==0)
{
if(i>hcf)
{hcf=i;
}
}
}
printf("HCF is %d ",hcf);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.




Enjoy programming in C.

,

C program to check strong number

C program to check strong number

C program to check strong number

 In this program, I have discussed about how to check strong number.

145 is called a strong number because the sum of factorial of its digits is equal to that number, i.e., 1!+4!+5!=145.
Strong numbers are also called as special numbers.


#include<stdio.h>
int fact(int);
int main()
{ int n,i,j,sum=0,k,num;
printf("Enter a number :");
scanf("%d",&n);
num=n;
while(n!=0)
{ k=n%10;
j=fact(k);
sum+=j;
n=n/10;
}
if(sum==num)
{ printf("Strong Number");
}
else
{ printf("Not a strong number");
}
}
int fact( int g)
{ int l=1,i;
for(i=1;i<=g;i++)
{ l*=i;
}
return l;
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.



Enjoy programming in C.













,

C Program to Find Factorial of a Number Using Recursion

C Program to Find Factorial of a Number Using Recursion

C program to find factorial of a number using recursion


In this program, I have discussed about the C program to find factorial of a number using recursion.

The formula which we will use is stated below.-
(n)!/(r!*(n-r)!)

#include<stdio.h>
int fact(int);
int main()
{ int a,b,c,n,r,res;
printf("Enter the value of n and r :\n");
scanf("%d%d",&n,&r);
a=fact(n);
b=fact(r);
c=fact(n-r);
res=a/(b*c);
printf("The value is %d \n",res);
}
int fact(int s)
{ int k=1,i;
for(i=1;i<=s;i++)
{ k*=i;
}
return k;
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


,

C Program to Calculate the Sum of cos(x) Series.

C program to calculate the sum of cos(x)

C Program to Calculate the Sum of cos(x) Series

In this program, I have discussed about the C Program to Calculate the Sum of cos(x) Series.

The value from 0° to 180 ° in steps of 30 °  is tabulated in the main program..

#include<stdio.h>
#include<math.h>
double func(long);
double fact(int);
int main()
{ int i,k;long j;
for(i=0;i<=180;i+=30)
{ k=func(i);
printf("The value of the series when X is %d is %d \n",i,k);
}
}
double func(long as)
{ float p=0,r; int l,e=0;
r=((3.14/180)*as);  //angle is converted into radians.
for(l=1;l<=10;l++,e+=2)
{p=p+pow(-1,l+1)*(pow(r,e)/fact(e));
}
return p;
}
double fact(int i)
{ int u=1,y;
for(y=1;y<=i;y++)
{ u*=y;
}
return u;
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


C Program To Search An Element In An Array.

C program to search an element in an array.

C Program To Search An Element In An Array.

In this program, I have discussed about the C program to search an element in an array.

This method is also known as linear search.
#include<stdio.h>
int main()
{ int ar[20],i,j,key,n,pos,fl=0;;
printf("Enter the size of the array \n");
scanf("%d",&n);
for(i=0;i<n;i++)
{ printf("Enter an element :\n");
scanf("%d",&ar[i]);
}
printf("Enter the key value to search :\n");
scanf("%d",&key);
for(j=0;j<n;j++)
{ if(ar[j]==key)
{
printf("Search Successfull\n");
printf("Element %d is found in %d position of the array\n",key,j);
fl=1;
break;
}
}
if(fl!=1)
{ printf("Not found !!!");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


C program to print the pattern

 C program to print the pattern

C program to print the pattern

In this program, I have discussed about the C program to print the pattern shown above.


#include<stdio.h>
int main()
{ int i,j,k,l,m,p=1,q=3,z;
for(i=4;i>=1;i--)
{ for(j=1;j<i;j++)
{ printf(" ");
}
for(k=p;k>=1;k--)
{ printf("%d",k);
}
p++;
printf("\n");
}
for(l=1;l<=3;l++)
{ for(z=1;z<=l;z++)
{printf(" ");
}
for(m=q;m>=1;m--)
{ printf("%d",m);
}
q--;
printf("\n");
}

}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to Check whether a given Number is Perfect Number

C program to check whether a given number is perfect number


 C Program to Check whether a given Number is Perfect  Number

In this program, I have discussed about the C program to check whether a given number is perfect number

A number is called a perfect number if the sum of all the divisors of that number is equal to that number.
For example:- 6,,,,,,,, 1+2+3=6.

 
#include<stdio.h>
int main()
{ int n,sum=0,k,i;
printf("Enter the number:");
scanf("%d",&n);
k=n/2;
for(i=1;i<=k;i++)
{ if(n%i==0)
{ sum=sum+i;
}
}
if(n==sum)
{printf("Perfect Number !!");
}
else
printf("Not a perfect number !!");
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.
,

C Program to Check Whether a Character is a Vowel or Consonant

C Program to Check Whether a Character is a Vowel or Consonant

C Program to Check Whether a Character is a Vowel or Consonant


In this program, I have discussed about the C program to check whether a character is a vowel or consonant.

#include<stdio.h>
int main()
{ char a;

printf("Enter an alphabet:");
scanf("%c",&a);
switch(a)
{
case 'a': printf("Vowel");
break;
case 'e': printf("Vowel");
break;
case 'i': printf("Vowel");
break;
case 'o': printf("Vowel");
break;
case 'u': printf("Vowel");
break;
case 'A': printf("Vowel");
break;
case 'E': printf("Vowel");
break;
case 'O': printf("Vowel");
break;
case 'I': printf("Vowel");
break;
case 'U': printf("Vowel");
break;
default: printf("Consonant");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C program to reverse a number.

C program to reverse a number

C program to reverse a number

 In this program, I have discussed about the C program to reverse a number


#include<stdio.h>
#include<math.h>
int main()
{ int n,k,a=0,rev=0;
printf("Enter the number");
scanf("%d",&n);
while(n>0)
{k=n%10;
n=n/10;
rev=(rev*10)+k;
}
printf("%d",rev);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

Sum of digits program in C

Sum of digits in C

Sum of digits program in C

 In this program, I have discussed about Sum of digits program in C.


#include<stdio.h>
int main()
{int sum=0,n,k;
printf("Enter the number:");
scanf("%d",&n);
while(n>0)
{k=n%10;
n=n/10;
sum=sum+k;
}
printf("\nThe sum is %d", sum);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C program to print the pattern.

C program to print the pattern

C program to print the pattern.

 In this program, I have discussed about the C program to print the pattern shown above.


#include<stdio.h>
int main()
{ int i,j,k,p=1,l,q=2,r=1,c=0,m=1,z=1,y=1;
for(i=1;i<=5;i++)
{
for(j=5;j>i;j--)
{ printf("  ");
}
k=z;
while(k<=y)
{printf("%d ",k);
k++;
}
y+=2,z++;
if(c!=0)
{
l=q,p=r;
while(l>p)
{printf("%d ",l);
l--;}
q+=2,r++;
}
c++;
printf("\n");
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.



,

C Program to Print Prime Numbers upto a given Number

C Program to Print Prime Numbers upto a given Number

C Program to Print Prime Numbers upto a given Number

 In this program, I have discussed about the C program to print prime numbers upto a given number or range.


#include<stdio.h>
int main()
{ int a,i,j,b,sum;
printf("Enter a number:");
scanf("%d",&a);
for(i=2;i<=a;i++)
{
sum=0;
b=i/2;
for(j=2;j<=b;j++)
{
if(i%j==0)
{
sum++;
}
}
if(sum==0)
printf("%d ",i);
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.
,

C program to print fibonacci series upto n terms

C program to print fibonacci series upto n terms

C program to print fibonacci series upto n terms


In this program, I have discussed about C program to print fibonacci series upto n terms.


#include<stdio.h>
int main()
{
int n,n1,n2,n3,count;
printf("Enter the no. of terms:");
scanf("%d",&n);
n1=0;n2=1;
printf("%d %d ",n1,n2);
count=2.5;
while(count<n)
{ n3= n1+n2;
count++;
printf("%d ",n3);
n1=n2;
n2=n3;
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C program to print the pattern


C program to print the pattern

C program to print the pattern

 In this program, I have discussed about the c program to print the pattern

#include<stdio.h>
int main()
{
int i,j,k,l,m;char a;
for(i=1;i<=7;i++)
{a='A';
for(j=0;j<=7-i;j++,a++)
printf("%c ",a);
for(k=2;k<(2*i)-1;k++)
printf("  ");
if(i==1)
{
a=a-2;
for(l=1;l<=7-i;l++,a--)
printf("%c ",a);
}
else
{a=a-1;
for(m=0;m<=7-i;m++,a--)
printf("%c ",a);
}
printf("\n");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C Program to Convert a Decimal Number to Binary & Count the Number of 1s

C Program to Convert a Decimal Number to Binary & Count the Number of 1s

C Program to Convert a Decimal Number to Binary

 In this program, I have discussed about the C Program to Convert a Decimal Number to Binary & Count the Number of 1s



#include<stdio.h>
int main()
{
long num,binary=0,decimal,base=1,rem,n1=0;
printf("Enter a decimal number:");
scanf("%d",&num);
decimal=num;
while(num>0)
{
rem=num%2;
if(rem==1)
{n1++;
}
binary=binary+rem*base;
num=num/2;
base=base*10;
}
printf("The decimal number is %d\n",decimal);
printf("The binary number is %d\n",binary);
printf("No. of 1's in the binary number is %d\n",n1);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.
,

C program to convert binary number to decimal number.

C program to convert binary number to decimal number.

C program to convert binary number to decimal number.

In this program, I have discussed about the C program to convert binary number to decimal number


#include<stdio.h>
int main()
{
int num,binary,decimal=0,base=1,rem;
printf("Enter a binary number:");
scanf("%d",&num);
binary=num;
while(num>0)
{
rem=num%10;
decimal=decimal+rem*base;
num=num/10;
base=base*2;
}
printf("The binary number is %d\n",binary);
printf("The decimal number is %d\n",decimal);
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C program to print Pascal Triangle

C program to print Pascal Triangle

C program to print Pascal Triangle

 In this program, I have discussed about the C program to print Pascal triangle.


#include<stdio.h>
int main()
{
int row,coef=1,sp,i,j;
printf("Enter the number:");
scanf("%d",&row);
for(i=0;i<row;i++)
{
for(sp=1;sp<=row-i;sp++)
printf(" ");
for(j=0;j<=i;j++)
{
if(j==0||i==0)
coef=1;
else
coef=coef*(i-j+1)/j;
printf("%d ",coef);
}
printf("\n");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C Program to Check Armstrong Number


C Program to Check Armstrong Number

C Program to Check Armstrong Number

 In this program, I have discussed about the C program to check armstrong number. this program is solely made for 3 digit armstrong numbers.

#include<stdio.h>
{int main()
    {int s=0;k,n,r;
printf("Enter a number");
scanf("%d",&n);
k=n;
        while(n>0)
        { r=n%10;
            s=s+r*r*r;
            n=n/10;}
            if(k==s)
            {printf("Armstrong Number");}
            else
            {printf("Not Armstrong Number");
            }
        }
    }

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to Find Factorial of a Number

C Program to Find Factorial of a Number


C Program to Find Factorial of a Number

 In this program, I have discussed about the C Program to Find Factorial of a Number.

Example of factorial of a number : 5: 1*2*3*4*5= 120 (answer)

#include<stdio.h>
int main()
{ int n,k=1,i;
printf("Enter a number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{ k+*i;
}
printf("The factorial is %d",k);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C program to print the series (1/2)+(3/4)+(5/6)

C program to print the series (1/2)+(3/4)+(5/6)+ (7/8) +  (9/10)


C program to print the series (1/2)+(3/4)+(5/6)

 In this program, I have discussed about the C program to find the sum of the series which I have shown above. 
Series programs is very important for your academic exams. Terms in the brackets will be solved first and then "+" terms are solved.

#include<stdio.h>
int main()
{float n,i,j,k=0;
for(i=1,j=2;i,j<=10;i+=2,j+=2)
{k=k+(i/j);
}
printf("%f",k);
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.

printf("%d",printf("%d",printf("%d",printf("Program"))));

What will be the output of printf("%d",printf("%d",printf("%d",printf("Program"))));


--------------------------------------------------------------------------
#include<stdio.h>
int main()
{
printf("%d",printf("%d",printf("%d",printf("Program"))));
}

----------------------------------------------------------------------------

Output;- Program711

C Program to print Floyd's triangle


C Program to print Floyd's triangle

https://en.wikipedia.org/wiki/C_(programming_language)


 In this program, I have discussed about C Program to print Floyd's triangle.

The pattern is shown below---
1
2 3
4 5 6
7 8 9 10


#include<stdio.h>
void main()
{int i,j,c=1,n;
printf("Enter the value of n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{for(j=1;j<=i;j++)
{printf("%d ",c);
c++;}
printf("\n");
}

}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


,

C program to find the value of y using the equation


 C program to find the value of y using the equation


 C program to find the value of y using the equation


 In this program, I have discussed about the  C program to find the value of y using the equation.


#include<stdio.h>
void main()
{
      float n,x,y;
      printf("Enter the value of n");
      scanf("%f",&n);
      printf("Enter the value of x");
      scanf("%f",&x);
      if(n==1)
         {y=1+(x*x);
         printf("Y=%f",y);}
      else if (n==2)
         {y=1+(x/n);
         printf("Y=%f",y);}
      else if(n==3)
         {y=1+(2*x);
         printf("Y=%f",y);}
      if(n<1||n>3)
        { y=1+(n*x);
         printf("Y=%f",y);}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C Program to Find the Roots of a Quadratic Equation

C Program to Find the Roots of a Quadratic Equation



C Program to Find the Roots of a Quadratic Equation

We will discuss about the C Program to Find the Roots of a Quadratic Equation ax2+bx+c=0, for all  possible combination of a, b and c. A quadratic equation will have two roots which are obtained using the expressions shown above:



#include<stdio.h>
#include<math.h>
      void main()
{
      float a,b,c,rt1,rt2,r;
      printf("Enter the value of a,b,c ");
      scanf("%f%f%f",&a,&b,&c);
      r=(b*b)-(4*a*c);
     if(r>0)
        {rt1=(-b+sqrt(r))/(2*a);
         rt2=(-b-sqrt(r))/(2*a);
         printf("The roots are real and unequal \n");
         printf("The roots are %f %f \n",rt1,rt2);}
     else if(r==0)
        {rt1=-(b/(2*a));
        printf("The roots are real and equal\n");
        printf("The root is %f ",rt1);}
   else if(r<0)
       {rt1=-(b/(2*a));
       printf("The roots are imaginary\n");}
    else
        {printf("Wrong input");}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


,

C program to find grade of a student




C program to find grade of a student 



 A student's grade is calculated in a subject according to the understated rules. Write  a  program  which  accepts  a  student's  number  as  input  and then  determine the grade  of the students in that subject.

C program to find grade of a student

C program to find grade of a student 

---------------------------------------------------------------------------------------

#include<stdio.h>
void main()
{int m;
printf("Enter your marks");
scanf("%d",&m);
if(m>=90&&m<=100)
printf("Your grade is O");
else if(m>=80&&m<90)
printf("Your grade is E");
else if(m>=70&&m<80)
printf("Your grade is A");
else if(m>=50&&m<60)
printf("Your grade is C");
else if(m>=40&&m<50)
printf("Your grade is D");
else if(m<40&&m>=0)
printf("Your grade is F. YOU FAILED!!");
else
printf("Invalid Input");
}

------------------------------------------------------------------------------------


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to Check Whether a Number is Even or Odd

 C Program to Check Whether a Number is Even or Odd


C Program to Check Whether a Number is Even or Odd

A number is said to an odd number if it is not divisible by 2 i.e., the remainder of that division will not be equal to 0.

 C Program to Check Whether a Number is Even or Odd

------------------------------------------------------------------------------------------------------
#include<stdio.h>
void main()
{int a;
printf("Enter a number:");
scanf("%d",&a);
if(a%2==0)
{printf("The number is even");}
else
{printf("The number is odd");
}
}

-----------------------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.
,

C program to perform addition, subtraction, multiplication and division using switch case

C program to perform addition, subtraction, multiplication and division using switch case


C program to perform addition, subtraction, multiplication and division using switch case


 In this program, I have discussed about the  program to perform addition, subtraction, multiplication and division using switch case

-----------------------------------------------------------------------------------

#include<stdio.h>
void main()
{
 char ch;
 int a,b,r;
 printf("Enter + or - or * or /");
scanf("%c",&ch);
printf("Enter two numbers");
scanf("%d%d",&a,&b);
switch (ch)
{
case '+':
r=a+b;
break;
case '-':
r=a-b;
break;
case '*':
r=a*b;
break;
case '/':
r=a/b;
break;
default:
printf("Invalid Input");
}
printf("Result= %d",r);
}


-------------------------------------------------------------------------------


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.
,

An electric bill distribution company arranges its domestic consumers as follows


An electric bill distribution company arranges its domestic consumers as follows


An electric bill distribution company arranges its domestic consumers as follows


#include<stdio.h>
void main()

    float ut,cost,p;
    printf("Enter the unit consumed");
   scanf("%f",&ut);
   if(ut>=0&&ut<201)
      {
       cost=(0.5*ut);
       printf("Your bill is %f \n",cost);}
  else if(ut>200&&ut<401)
      {p=ut-200;
      cost=100+(0.65*p);
       printf("Your bill is %f \n",cost);}
  else if(ut>400&&ut<601)
      {p=ut-400;
       cost=250+(0.80*p);
      printf("Your bill is %f \n",cost);}
  else if(ut>600)
      {p=ut-600;
      cost=425+(1.25*p);
     printf("Your bill is %f \n",cost);}
}


-----------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


Area of Triangle using Heron's Formula in C

Area of Triangle using Heron's Formula in C

Area of Triangle using Heron's Formula in C

 In this program, I have discussed about the Area of Triangle using Heron's Formula in C.

Heron's formula states that if a, b,c are the three sides of a triangle then the area of that triangle will be equal to [ area=sqrt(s*(s-a)*(s-b)*(s-c))] , where s=(a+b+c)/2.

--------------------------------------------------------------------------------


#include<stdio.h>
#include<math.h>
void main()
{
 float a,b,c,area,s;
printf("Enter the value of a,b,c");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of the triangle is %f \n",area);
}




---------------------------------------------------------------------
Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.



C Program to Calculate Gross Salary of an Employee


C Program to Calculate Gross Salary of an Employee

C Program to Calculate Gross Salary of an Employee


C program to calculate gross salary of a person. 

D.A= 74%of salary.
H.R.A=15%of salary.
Salary=D.A+H.R.A.

-----------------------------------------------------------------------------------------
#include<stdio.h>
void main()
{float salary,da,hra,income;
printf("Enter the salary:\n");
scanf("%f",&salary);
da=.74*salary;
hra=.15*salary;
income=salary+da+hra;
printf("The income is:%f \n",income);
}



------------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.




C Program to calculate electric bill of a consumer- BASIC WAY

C Program to calculate electric bill of a consumer- BASIC WAY



C Program to calculate electric bill of a consumer

In this program I have discussed about the basic C Program to calculate electric bill of a consumer.

Here I have assumed that the the rate of per unit of current consumed is fixed at Rs 3.75. If the rate is made to be variable then the program will change.

--------------------------------------------------------------------

#include<stdio.h>
void main()
{ float prev,curr,net,bill;
printf("Enter the previous reading and the current reading:\n");
scanf("%f%f",&prev,&curr);
net=curr-prev;
bill=net*3.75;
printf("Your bill is: %f \n",bill);
}


---------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.

C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of Circle

C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle



C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle


In this program I have discussed about the C Program to Calculate Area and Perimeter of Rectangle And Area and Circumference of  Circle.


Area of a rectangle= Length * Breadth
Perimeter of a rectangle= 2*(length+breadth)

Area of a circle= 3.14* (Radius)^2
Perimeter of a circle= 2* 3.14*radius
-------------------------------------------------------------------------------------------


#include<stdio.h>
void main()
{float rad,length,breadth,area1,area2,peri,circu;
printf("Enter the length and breadth of the rectangle:");
scanf("%f%f",&length,&breadth);
area1=length*breadth;
peri=2*(length+breadth);
printf("The area of the rectangle is %f \n",area1);
printf("THe perimeter of the rectangle is %f \n",peri);
printf("Enter the radius of the circle:");
scanf("%f",&rad);
area2=3.14*(rad*rad);
circu=2*3.14*rad;
printf("The area of the circle is %f \n",area2);
printf("THe circumference of the circle is %f \n",circu);
}

---------------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


C Program to Find the Largest Number Among Three Numbers

C Program to Find the Largest Number Among Three Numbers


C Program to Find the Largest Number Among Three Numbers

In this program I have discussed about the C Program to Find the Largest Number Among Three Numbers..

Here I have used the ternary operator (?) to solve the program.

---------------------------------------------------------------------

#include<stdio.h>
void main()
{ int a,b,c;
printf("Enter three numbers: ");
scanf("%d%d%d",&a,&b,&b);
int p=a>b?a:b;
int q=c>p?c:p;
printf("The large number is %d \n",q);
}

------------------------------------------------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to convert Celsius to Fahrenheit


C Program to convert Celsius to Fahrenheit



C Program to convert Celsius to Fahrenheit

In this case, I have discussed about the C Program to convert Celsius to Fahrenheit.

The relation between Celsius and Fahrenheit is,,
C/5= (F-32)/9
where C = Temperature in degree celsius  and
           F = Temperature in degree fahrenheit.

----------------------------------------------------------------------------------


#include<stdio.h>
void main()

float fah,cen;
printf("Enter the fahrenheit temerature:");
scanf("%f",&fah);
cen=(5*fah-160)/9;
printf("The celcius temperature is %f",cen);
}

---------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.

C program to swap two numbers without using a third variable

C program to swap two numbers without using a third variable


C program to swap two numbers without using a third variable


 In this program, I have discussed about the C program to swap two numbers without using a third variable.

Swap means to interchange the values of two variables.

Here I have not used a third variable to swap the two numbers.

----------------------------------------------------------------------------------------------------------------

#include<stdio.h>
void main()
{ int a,b;
printf("Enter two numbers: ");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("the two numbers are: \n");
printf("%d \n",a);
printf("%d \n",b);
}

-----------------------------------------------------------------------------------------------------

If you want the C program to swap two numbers using a third variable then click here.

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.


C Program to Swap Two Numbers


C Program to Swap Two Numbers


C Program to Swap Two Numbers

In this program I have discussed about the C Program to Swap Two Numbers .

We have used a third variable here to swap the two numbers.

Swap means to interchange the values of two variables.



---------------------------------------------------------------------------------------------

#include<stdio.h>
void main()
{ int a,b,c;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("The first number %d \n",a);
printf(" The second number %d ",b);
}

----------------------------------------------------------------------------------------------

If you want the C program to swap two numbers without using third variable then click here.


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

C Program to calculate Area and Circumference of Circle


C Program to calculate Area and Circumference of Circle


C Program to calculate Area and Circumference of Circle


 In this program, I have discussed about the C Program to calculate Area and Circumference of Circle

Area of a circle= 3.14*(radius)^2
Perimeter of a circle= 2*3.14*(radius)

----------------------------------------------------
#include<stdio.h>
void main()
{float r,p,a;
printf("Enter the radius of the circle:");
scanf("%f",&r);
p=2*3.14*r;
a=3.14*r*r;
printf("The perimeter is : %.2f \n",p);
printf("The area is : %.2f \n",a);
}


-------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.


C program to perform addition, subtraction, multiplication and division

C program to perform addition, subtraction, multiplication and division


C program to perform addition, subtraction, multiplication and division


 In this program, I have discussed about C program to perform addition, subtraction, multiplication and division of two numbers.

----------------------------------------------------------------------------------------------------

#include<stdio.h>
void main()
{ int a,b,i,j; float m,d;
printf("Enter two numbers:");
scanf("%d",&a,&b);
i=a+b;
j=a-b;
m=a*b;
d=a/b;
printf(" The sum is %d",i);
printf("The subtracted value is %d",j);
printf("The multilied result is %d",m);
printf("The divided result is %d", d);
}


-----------------------------------------------------------------------

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.


Enjoy programming in C.


 

Copyright 2020 Programming in C All Right Reserved