Program to print table of the numbers from 1 to 10

//Program to print table of the numbers from 1 to 10
#include<stdio.h>
#include<conio.h>
int main()
{
  int row, col;
  clrscr();
  printf("Table of 1 to 10 is as\n");
  for(row=1;row<=10;row++)
  {
    for(col=1;col<=10;col++)
    {
      printf("%4d",row*col);
    }
    printf("\n");
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.



Program to print table of given number using for loop

//Program to print table of given number using for loop
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,j,k;
  clrscr();
  printf("Enter a number\n");
  scanf("%d",&n);
  printf("Table of %d is as\n",n);
  for(j=1;j<=10;j++)
  {
    k=n*j;
    printf(" %d \n",k);
  }

  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print table of given number

//Program to print table of given number
#include<stdio.h>
#include<conio.h>
int main()
{
 int n,k=1,m;
 clrscr();
 printf("Enter the number\n");
 scanf("%d",&n);
 while(k<11)
 {
   m=n*k;
   printf("%d*%d=%d\n",n,k,m);
   k++;
 }

  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print sum of digits of the Integer

//Program to print sum of digits of the Integer
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,rem,ans=0;
  clrscr();
  printf("Enter the number\n");
  scanf("%d",&n);
  while(n!=0)
  {
   rem=n%10;
   ans=ans+rem;
   n=n/10;
  }
  printf("The sum of digits is = %d",ans);
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print table between the given range of integers

//Program to print table between the given range
#include<stdio.h>
#include<conio.h>
int main()
{
  int row, col,y,k;
  clrscr();
  printf("Enter the two numbers for getting the table between their range\n");
  scanf("%d%d",&row,&col);
  k=row;
  printf("Table as\n");
  for(y=1;y<=10;y++)
  {
    for(row;row<=col;row++)
    {
      printf("%4d",row*y);
    }
    row=k;
    printf("\n");
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to accept a number and print its prime factors

//Program to accept a number and print its prime factors
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,k=2,j;
  clrscr();
  printf("Enter the number\n");
  scanf("%d",&n);
  while(k<n)
  {
   if(n%k==0)
   {
     n=n/k;
     printf("%4d",k);
       if(n%k==0)
       printf("%4d",k);
   }
   k++;
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display prime numbers between 1 to 100

//Program to display prime numbers between 1 to 100
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,j;
  clrscr();
  printf("Prime numbers between 1 to 100\n");
  for(n=3;n<=100;n++)
  {
    for(j=2;j<=100;j++)
    {
     if(n%j==0)
     break;
    }
    if(j==n)
    printf("%4d",n);
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Progrm to print certain pattern

//Progrm to print following pattern
// * * * * *
// * * * * *
// * * * * *
// * * * * *
// * * * * *
#include<stdio.h>
#include<conio.h>
int main()
{
  int x,y;
  clrscr();
  for(x=1;x<=5;x++)
  {
     for(y=1;y<=5;y++)
     {
     printf(" * ");
     }

     printf("\n");
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print unique pairs of numbers such that multiplication of the pair is given number

//Program to print unique pairs of numbers such that multiplication
//of the pair is given number
#include<stdio.h>
#include<conio.h>
int main()
{
 int n,k=1,j;
 clrscr();
 printf("Enter the number\n");
 scanf("%d",&n);
 while(k<n)
 {
 if(n%k==0)
 {
 if(k<n/k)
 printf("%d * %d = %d\n",k,n/k,n);
 }
   k++;
 }

  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find Gretest common divisor (GCD) using Euclidian algorithm.

//Program to find Gretest common divisor (GCD)
//using Euclidian algorithm.
#include<stdio.h>
#include<conio.h>
int main()
{
  int a,b,c,k,d;
  clrscr();
  printf("Enter two numbers\n");
  scanf("%d%d",&a,&b);
  c=a%b;
  printf("%d  * %d  =  %d\n",a,b,c);
  k=b<a?b:a;
  while(c>0)
   {
      if(d>0)
      {
        d=k%c;
        if(d!=0)
          printf("%d  *  %d  =  %d\n",k,c,d);
        k=c;
        c=d;
      }
   }
   printf("GCD of a and b is=%d",k);
   getch();
   return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print all factors excluding number

//Program to print all factors excluding number
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,k=1;
  clrscr();
  printf("enter the number\n");
  scanf("%d",&n);
  while(k<n)
  {
    if(n%k==0)
       printf("%4d",k);
    k++;
  }

  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find out Factorial of given number

//Program to find out Factorial of given number
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,j,k;
  clrscr();
  printf("Enter a number whose factorial you want to calculate\n");
  scanf("%d",&n);
  k=n;
  for(j=1;j<k;j++)
  {
     n=j*n;

  }
  printf("Factrorial of the %d is = %d",k,n);
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print a user entered character, to user entered number times

//Program to print a user entered character,
//to user entered number times
#include<stdio.h>
#include<conio.h>
int main()
{
  int n;
  char ch;
  clrscr();
  printf("Enter a number\n");
  scanf("%d",&n);
  printf("Enter character");
  fflush(stdin);
  scanf("%c",&ch);
  while(n>0)
  {
    printf("%c",ch);
    n--;
  }

  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to check the Armstrong Number

//Program to check the Armstrong Number
#include<stdio.h>
#include<conio.h>
int main()
{
  int num,sum=0,rem,onum;
  clrscr();
  printf("Enter the number\n");
  scanf("%d",&num);
  onum=num;
  while(num>0)
  {
    rem=num%10;

    num=num/10;
    sum=sum+rem*rem*rem;
  }
  if(sum==onum)
  printf("\nThe number is Armstrong number ");
  else printf("The number is not Armstrong number");
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display Armstrong numbers between 1 to 500

//Program to display Armstrong numbers between 1 to 500
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,num,sum=0,rem,k;
  clrscr();
  printf("Armstrong numbers between 1 to 500 are\n");
  for(n=1;n<500;n++)
  {
     n=k;
     while(n>0)
     {
       rem=n%10;
       sum=sum+rem*rem*rem;
       n/10;
     }
     if(sum==k)
     printf("%d",k);
  }
   getch();
   return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to decide a quadrant of the entered point

//Program to decide a quadrant of the entered point
#include<stdio.h>
#include<conio.h>
int main()
{
float a,b;
clrscr();
printf("Enter the Co-ordinate of the point as x,y\n");
scanf("%f\n%f",&a,&b);
if(a>0&&b>0) printf("The Point lies in First Quadrant");
if(a>0&&b<0) printf("The Point lies in the Forth Quadrant");
if(a<0&&b<0) printf("The Point lies in the Third Quadrant");
if(a<0&&b>0) printf("The Point lies in the Second Quadrant");
if(a==0&&b!=0) printf("The Point lies on the X Axis");
if(a!=0&&b==0) printf("The Point lies on the Y Axis");
if(a==0&&b==0)printf("The Point is an Origin");
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to check whether user entered number is Positive of Negative or zero

//Program to check whether user entered number is Positive of Negative or zero
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
clrscr();
printf("Enter any One Integer Numbers\n");
scanf("%d",&a);
if(a==0)
printf("Entered number is Zero");
else if(a>=1)
       printf("entered Integer is +ve");
       else if(a<0)
        printf("Entered Integer is -ve");

getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to check whether the user entered integer/number is Palindrome

//Program to check whether the user entered integer/number is Palindrome
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e;
long int f,g,h;
clrscr();
printf("Enter a Five Digit number ");
scanf("%d",&a);
h=a;
b=a/10000;a=a%10000;
c=a/1000;a=a%1000;
d=a/100;a=a%100;
e=a/10;a=a%10;
f=a;
f=f*10000;
e=e*1000;
d=d*100;
c=c*10;

g=b+c+d+e+f;
if(h==g)
printf("Number is palindrome",g);
else printf("Number is not palindrome");



getch();
return 0;

}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display maximum of two integers using conditional operator

//Program to display maximum of two integers using conditional operator
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
clrscr();
printf("Enter Two Integer Numbers\n");
scanf("%d%d",&a,&b);
c=a>b?a:b;
printf("%d is Maximum",c);

getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display maximum of three integers using if else

//Program to display maximum of three integers using if else
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
clrscr();
printf("Enter Three Integer Numbers\n");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
    if(a>c) printf("%d is Maximum",a);
    else    printf("%d is Maximum",c);
}
else
{
    if(b>c) printf("%d is Maximum",b);
    else printf("%d is Maximum",c);
}


getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display Largest/Maximum number in 3 integers using conditional operator

//Program to display Largest/Maximum number in 3 integers using conditional operator
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d;
clrscr();
printf("Enter Three Integer Numbers\n");
scanf("%d%d%d",&a,&b,&c);
d=a>b?(a>c?a:c):b>c?b:c;
printf("%d is Maximum",d);

getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display the maximum of two user entered numbers

//Program to display the maximum of two user entered numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
clrscr();
printf("Enter Two Integer Numbers\n");
scanf("%d%d",&a,&b);
if(a>b)
printf("%d is Maximum",a);
else
       printf("%d is Maximum",b);


getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display no. of days in the year while taking care of leap year

//Program to display no. of days in the year while taking care of leap year
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
clrscr();
printf("Enter a Year\n");
scanf("%d",&a);
if(a%4==0&&a%100!=0||a%400==0)

printf("Year has 366 Days");

else printf("Year has 365 Days");


getch();
return 0;

}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to Display whether entered no. is even or odd

//Program to Display whether entered no. is even or odd
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
clrscr();
printf("Enter any One Integer Numbers\n");
scanf("%d",&a);
if(a%2==0)
printf("Entered Integer is Even");
else printf("entered Integer is Odd");

getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to accept two numbers and display their division

//Program to accept two numbers and display their division
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
float c;
clrscr();
printf("Enter two Integer Numbers");
scanf("%d%d",&a,&b);
if(b==0)
printf("Enter Divider other than zero");
else{
c=(float)a/b;
printf("Division is = %f",c);}
getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display no. of days in entered month

//Program to display no. of days in entered month
#include<stdio.h>
#include<conio.h>
int main()
{
int m,y,d;
clrscr();
printf("Enter Month number and Year");
scanf("%d%d",&m,&y);


    if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
    {
    if(y%4==0&&y%100!=0||y%400==0)
         printf("Month days=31, Year days=366");
    else printf("Month days=31, Year days=365");

    }

    if(m==2)
    {
    if(y%4==0&&y%100!=0||y%400==0)
       printf("Month days=29, Year days=366");
    else printf("Month days=28, Year days=365");
    }

    if(m==4||m==6||m==9||m==11)
    {
    if(y%4==0&&y%100!=0||y%400==0)
    printf("Month days=30, Year days=366");
    else printf("Month days=30, Year days=365");
    }
getch();
return 0;     //Return successfuly to calling area

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to display the category of the Character

//Program to display the category of the Character
#include<stdio.h>
#include<conio.h>
int main()
{
char c;
clrscr();
printf("Enter the character\n");
scanf("%c",&c);
if(c>=65&&c<=90)
printf("The character is UPPERCASE alphabet");
else if(c>=97&&c<=122)
printf("The character is lowercase alphabet");
else if(c>=48&&c<=57)
printf("The character is Digit");
else if(c==32)
printf("The character is Space");
else if(c==9)
printf("The character is Tab");
else if(c==13)
printf("The character is Carriage Return");
else if(c==10)
printf("The character is New Line");
else
printf("The character is a special character");
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find the sum of two numbers

//program to find the sum of two numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,sum;
clrscr();
printf("Enter Two Numbers\n");
scanf("\n%d\n%d",&a,&b);
sum=a+b;
printf("\nSum is =%d",sum);
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print number in reverse order

//Program to print four digit number in reverse order
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e,f;
clrscr();
printf("Enter a Four Digit number ");
scanf("%d",&a);
b=a/1000;a=a%1000;
c=a/100;a=a%100;
d=a/10;a=a%10;e=a;e=e*1000;d=d*100;c=c*10;f=b+c+d+e;
printf("Number in reverse order is as %d",f);

getch();
return 0;

}


OR

//Program to print any number any reverse order
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,i,j;
  clrscr();
  printf("Enter the Integer\n");
  scanf("%d",&n);
  for(i=0; n!=0;i++)
  {
     j=n%10;
     n=n/10;
     printf("%d",j);
  }  
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find the Product of two numbers

//program to find the Product of two numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,Product;
clrscr();
printf("Enter Two Numbers\n");
scanf("\n%d\n%d",&a,&b);
Product=a*b;
printf("\nProduct is =%d",Product);
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print Place value

//Program to print Place value
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e;
clrscr();
printf("Enter a Four Digit number ");
scanf("%d",&a);
b=a/1000;a=a%1000;b=b*1000;
c=a/100;a=a%100;c=c*100;
d=a/10;a=a%10;e=a;d=d*10;
printf("Place value of %d is=%d\nPlace value of %d is=%d\nPlace value of %d is=%d\nPlace value of %d is=%d",
b,b,c,c,d,d,e,e);

getch();
return 0;

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print the range of data types in c

//Program to print the range of data types in c
#include<stdio.h>
#include<conio.h>
#include<limits.h>
int main()
{
clrscr();
printf("int %%d %d %d to %d",
sizeof(int),INT_MIN,INT_MAX);
printf("\nchar %%d %d %d to %d",
sizeof(char),CHAR_MIN,CHAR_MAX);
printf("\nlong %%d %d %d to %d",
sizeof(long),LONG_MIN,LONG_MAX);
printf("\nshort char %%d %d %d to %d",
sizeof(short char),SCHAR_MIN,SCHAR_MAX);
printf("\nint %%d %d %d to %d",
sizeof(short),SHRT_MIN,SHRT_MAX);
getch();
return 0;

}

Program to print face value of four digit number

//Program to print face value of four digit number
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e;
clrscr();
printf("Enter a Four Digit number ");
scanf("%d",&a);
b=a/1000;a=a%1000;
c=a/100;a=a%100;
d=a/10;a=a%10;e=a;
printf("face value of %d is=%d\nFace value of %d is=%d\nFace value of %d is=%d\nFace value of %d is=%d",
b,b,c,c,d,d,e,e);

getch();
return 0;

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

program to find the Difference of two numbers

//program to find the Difference of two numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,dif;
clrscr();
printf("Enter Two Numbers\n");
scanf("\n%d\n%d",&a,&b);
dif=a-b;
printf("\nDifference is =%d",dif);
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find out the number of days in entered month

//Program to find out the number of days in entered month
#include<stdio.h>
#include<conio.h>
int main()
{
  int m,y;
  clrscr();
  printf("Enter the Month no. and Year\n");
  scanf("%d%d",&m,&y);
  switch(m)
  {
    case 1:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("January has 31 days and Year has 366 days");
    else printf("January has 31 days and Year has 365 days");
    break;

    case 2:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("February has 29 days and Year has 366 days");
    else printf("February has 28 days and Year has 365 days");
    break;

    case 3:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("March has 31 days and Year has 366 days");
    else printf("March has 31 days and Year has 365 days");
    break;

    case 4:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("April has 30 days and Year has 366 days");
    else printf("April has 30 days and Year has 365 days");
    break;

    case 5:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("May has 31 days and Year has 366 days");
    else printf("May has 31 days and Year has 365 days");
    break;

    case 6:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("June has 30 days and Year has 366 days");
    else printf("June has 30 days and Year has 365 days");
    break;

    case 7:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("July has 31 days and Year has 366 days");
    else printf("July has 31 days and Year has 365 days");
    break;

    case 8:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("August has 31 days and Year has 366 days");
    else printf("January has 31 days and Year has 365 days");
    break;

    case 9:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("September has 30 days and Year has 366 days");
    else printf("September has 30 days and Year has 365 days");
    break;

    case 10:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("October has 31 days and Year has 366 days");
    else printf("October has 31 days and Year has 365 days");
    break;

    case 11:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("November has 30 days and Year has 366 days");
    else printf("November has 30 days and Year has 365 days");
    break;

    case 12:
    if(y%4==0&&y%100!=0||y%400==0)
    printf("December has 31 days and Year has 366 days");
    else printf("December has 31 days and Year has 365 days");
    break;

    }
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Printing Number in Character

//Printing Number in Character
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
clrscr();
printf("Enter a Number\n");
scanf("\n%d",&a);
printf("\nNumber in Character is %c",a);
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find out the average of three numbers

//Program to find out the average of three numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
float d;
clrscr();
printf("Enter Three numbers ");
scanf("%d%d%d",&a,&b,&c);
d=(a+b+c)/3;
printf("Average is = %f",d);

getch();
return 0;

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.




Printing ASCII value in Octal

//Printing ASCII value in Octal
#include<stdio.h>
#include<conio.h>
int main()
{
char a;
clrscr();
printf("Enter a Character\n");
scanf("\n%c",&a);
printf("\nASCII value in Octal is %o",a);
getch();
return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Printing ASCII value in Hex

//Printing ASCII value in Hex
#include<stdio.h>
#include<conio.h>
int main()
{
char a;
clrscr();
printf("Enter a Character\n");
scanf("\n%c",&a);
printf("\nASCII value in Hex is %x",a);
getch();
return 0;
}

Printing ASCII value of character in decimal

//Printing ASCII value of character in decimal
#include<stdio.h>
#include<conio.h>
int main()
{
char a;
clrscr();
printf("Enter a Character\n");
scanf("\n%c",&a);
printf("\nASCII value in decimal %d",a);
getch();
return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find the ASCII values of the \n,\r,\t,\a,and \b

//Program to find the ASCII values of the \n,\r,\t,\a,and \b
#include<stdio.h>
#include<conio.h>
int main()
{

clrscr();
printf("ASCII value of \\n is =%d",'\n');
printf("\nASCII value of \\r is =%d",'\r');
printf("\nASCII value of \\t is =%d",'\t');
printf("\nASCII value of \\a is =%d",'\a');
printf("\nASCII value of \\b is =%d",'\b');
getch();
return 0;

}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to calculate the Area of Circle from co-ordinates of the end points of the Diameter of Circle

//Program to calculate the Area of Circle from
//co-ordinates of the end points of the Diameter of Circle
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.1416
int main()
{
  float x1,x2,y1,y2,d,area;
  clrscr();
  printf("Enter the co-ordinates of the Points of Diameter of the Circle\n");
  scanf("%f%f%f%f",&x1,&x2,&y1,&y2);
  d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/2;//To find out the Radius of Circle
  area=pi*d*d;
  printf("The Area of the Circle is = %f",area);
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to make Simple Arithmetic Calculator

//Program to make Simple Arithmetic Calculator
#include<stdio.h>
#include<conio.h>
int main()
{
  int a,b;
  clrscr();
  printf("Enter the Integers to Calculate the Sum, Difference, Product \nand Division between them\n");
  scanf("%d%d",&a,&b);
  printf("\nThe sum = %d",a+b);
  printf("\nThe Difference = %d",a-b);
  printf("\nThe Product = %d",a*b);
  printf("\nThe Division = %d",a/b);
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to Calculate the Distance between two Co-Ordinates

//Program to Calculate the Distance between two Co-Ordinates
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  float x1,x2,y1,y2,d;
  clrscr();
  printf("Enter the co-ordinates of the two Points\n");
  scanf("%f%f%f%f",&x1,&x2,&y1,&y2);
  d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  printf("The Distance between two Points is = %f",d);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

C Program to calculate the Area of the Triangle by using its three sides

//Program to calculate the Area of the Triangle by using its three sides
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
  float area,s,a,b,c;
  clrscr();
  printf("Enter three sides of the Triangle for calculating Area\n");
  scanf("%f%f%f",&a,&b,&c);
  s=(a+b+c)/2;
  area=sqrt(s*(s-a)*(s-b)*(s-c));
  printf("\nThe Area of the Triangle is = %f",area);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

C Program To convert the temperature between Celcius and Fahrenheit

//To convert the temperature between Celcius and Fahrenheit
#include<stdio.h>
#include<conio.h>
int main()
{
 float c,f;
 int m;
 clrscr();
 printf("Enter your choice"
           "\nPress 1 to convert Temperature from Celcius to Fahrenheit"
           "\nPress 2 to convert Temperature from Fahrenheit to Celcius\n");
 scanf("%d",&m);
 switch(m)
 {
  case 1:
  printf("\nEnter the Temperature in Celcius\n");
  scanf("%f",&c);
  f=9*c/(5)+32;
  printf("\nTemperature in Fahrenheit is = %f",f);
  break;

  case 2:
  printf("\nEnter the Temperature in Fahrenheit\n");
  scanf("%f",&f);
  c=(f-32)*5/9;
  printf("\nTemperature in Celcius is = %f",c);
  break;

  default:
  printf("\nEnter valid Choice");
 }
  getch();
  return 0;
}

Program to Calculate Sum and Difference between Integers

//Program to Calculate Sum and Difference between Integers
#include<stdio.h>
#include<conio.h>
int main()
{
  int a,b;
  clrscr();
  printf("Enter two integers whose sum and difference to be calculated\n");
  scanf("%d%d",&a,&b);
  printf("The sum of two Integers is = %d",sum(a,b));
  printf("\nThe difference of two Integers is = %d",diff(a,b);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to print the multiplication table

//Program to print the multiplication table without using loops
#include<stdio.h>
#include<conio.h>
int main()
{
  int a;
  printf("Enter the integer whose table you want to display\n");
  scanf("%d",&a);
  printf("%d * %d = %d\n%d * %d = %d\n%d * %d = %d\n%d * %d = %d\n"
             "%d * %d = %d\n%d * %d = %d\n%d * %d = %d\n%d * %d = %d\n"
             "%d * %d = %d\n%d * %d = %d\n",a,1,a*1,a,2,a*2,a,3,a*3,a,4,a*4,
             a,5,a*5,a,6,a*6,a,7,a*7,a,8,a*8,a,9,a*9,a,10,a*10);
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to find out the area of circle by using macro

//Program to find out the area of circle by using macro
#include<stdio.h>
#include<conio.h>
#define pi 3.1416//macro
int main()
{
  float area, radius;
  clrscr();
  printf("Enter the radius of circle whose area to be calculated\n");
  scanf("%f",&radius);
  area=pi*radius*radius;
  printf("\nThe Area of the Circle is = %f",area);
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to pring pattern

/*Program to pring following pattern using one printf statement
*
* *
* * *
* * * *
*/

#include<stdio.h>
#include<conio.h>
int main()
{
  clrscr();
  printf("*\n* *\n* * *\n* * * *");
 
  getch();
  return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Program to Accept and Display Address

//Program to Accept and Display Address
#include<stdio.h>
#include<conio.h>
int main()
{
   int a;
   unsigned b;//As your pin code is big integer constant
   char *ch1,*ch2,*ch3;//Strings to accept Street, City and Name
   clrscr();
   printf("Enter the name\n");
   gets(ch1);
   printf("\nEnter Door No and Street");
   printf("\n");
   scanf("%d",&a);
   fflush(stdin);
   gets(ch2);
   printf("\nEnter City and Pin code\n");
   gets(ch3);
   scanf("%d",&b);
   printf("\nName : %s",ch1);
   printf("\nDoor No. : %d    Street : %s",a,ch2);
   printf("\nCity : %s   Pin Code : %u",ch3,b);
   getch();
   return 0;
}

To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

Welcome

Welcome to my Blog.
This blog is about how to right programs in C language efficiently.
Go ahead and be the master in c.
You are always welcome to my blog.
Yours,
C Programmer.