Tuesday, 17 February 2015

Find the Area Of Circle

#include<stdio.h>
 
int main() {
   float radius, area;
 
   printf("\nEnter the radius of Circle : ");
   scanf("%d", &radius);
 
   area = 3.14 * radius * radius;\\ Formula of Area of Circle: Π * r * r
   printf("\nArea of Circle : %f", area);
 
   return (0);
}
 
 
Output :
Enter the radius of Circle : 2.0
Area of Circle : 6.14

Find given number is Armstrong Number or not

Armstrong Number

 void main()
 {
     int n,b=0,t;
     clrscr();
     printf("Enter the no");
     scanf("%d",&n);
     t=n;
     while(n>0)
     {
             a=n%10;
             b=b+a*a*a;
             n=n/10;
     }
     if(b==t)
     {
             printf("Armstrong no");
     }
      else
     {
             printf("Not an armstrong no");
     }
     getch();
 }

Thursday, 5 February 2015

Multiplication of Two Integer Number in C

/*C program to multiply and display the product of two integer numbers entered by user. */

#include <stdio.h>
int main( )
{
    int num1, num2, product;
    printf("Enter two numbers: ");
    scanf("%d %d",&num1,&num2);        /* Stores the two integer numbers entered by user in variable num1 and num2 respectively */
    product = num1*num2;  /* Performs multiplication and stores it */
    printf("Product: %f",product);
    return 0;
}
 
 
Output
Enter two numbers: 2
2
Product: 4

Addition of Two Integer In C

#include <stdio.h>
int main( )
{
    int num1, num2, sum;
    printf("Enter two integers: ");
    scanf("%d %d",&num1,&num2); /* Stores the two integer entered by user in variable num1 and num2 */

    sum=num1+num2;      /* Performs addition and stores it in variable sum */
    printf("Sum: %d",sum);  /* Displays sum */
    return 0;
}
 
 
Output
Enter two integers: 
12
11
Sum: 23 
 
 

First Simple C Program

#include <stdio.h>

int main()
{
   /* my first program in C */
   printf("Hello, World! \n");
   
   return 0;
}