Showing posts with label Simple C Programs. Show all posts
Showing posts with label Simple C Programs. Show all posts

Monday, January 27, 2014

Simple C program to calculate area of circle r1 and r2

Simple C program to calculate area of circle r1 and r2

C Program to calculate area of circle r1 and r2

#include<stdio.h>
int main()
{
float r1,r2,area;
printf("Enter r1 of circle:");
scanf("%f",&r1);
printf("Enter r2 of circle:");
scanf("%f",&r2);
area=3.146*(r1*r2);
printf("\nr1=%f",r1);
printf("\nr2=%f",r2);
printf("\n\narea=3.146*(%f*%f)",r1,r2);
printf("\n\nArea of circle=%f",area);
return 0;
}


The output of above program is:


Sunday, January 26, 2014

Simple C Program to convert the Celsius value to Fahrenheight value

Simple C Program to convert the Celsius value to Fahrenheight value
#include<stdio.h>
int main()
{
    float celsius,fahrenheit;
    printf("Please enter the celsius temperature:");
    scanf("%f",&celsius);
    fahrenheit=(1.8*celsius)+32;
    printf("\nC=%f",celsius);
    printf("\nF=(1.8*C)+32\n");
    printf("\n(1.8*%f)+32=%f",celsius,fahrenheit);
    printf("\n\nFahrenheit=%f",fahrenheit);
    return 0;
}


Note

Formula is :
F=(9/2*C)+32
For convenience i have written , 9/2= 1.8
F=(1.8*C)+32
The output of above program:

Thursday, January 23, 2014

Program to find Hotness and Coldness of temperature using If statements

#include<stdio.h>
int main()
{
int temp;
printf("\nEnter temperature :");
scanf("%d,&temp");
if(temp>30)
printf("\nHot\n");
if(temp>20)
printf("\nMild\n");
if("temperature>10")
printf("\nCold\n") ;
return 0;
}

Simple Program to add three integers

#include<stdio.h>
#include<conio.h>

void main()
{
    int x,y,z,result;
    printf("Enter x:\n");
    scanf("%d",&x);
    printf("Enter y:\n");
    scanf("%d",&y);
    printf("Enter z:\n");
    scanf("%d",&z);
    result=x+y+z;
    printf("Result=%d",result);
   
}

Tuesday, January 7, 2014

Your first C Program

#include<stdio.h>
int main()
{
printf("Angry Bird");
return 0;
}