Monday 9 December 2013

Basic c programming

                                       Find the interest i using i=p*r*n/100
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,n,i;
clrscr():
printf("enter the value of p,r and n");
scanf("%d %d %d",&p,&r,&n);
i=p*r*n/100;
printf("ans i=%d\n",i);
getch();
}
=======================================================================================================================================================================
                                                   Find the number is even or odd
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("enter the value of a is:");
scanf("%d",&a);
if(a%2==0)
{
printf("a is even);
}
else if(a%2!=o)
{
printf("a is odd");
}
else
{
printf("a is zero);
}
getch();
}
========================================================================================================================================================================
                                          Interchange of two number(swapping)
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();
printf("enter the value of a and b before swapping");
scanf("%d %d",&a,&b);
temp=a;
a=b;
b=temp;
printf("after swapping value of a and b is=%d %d\n",a,b);
getch();
}
============================================================================================================================================================================
#include<stdio.h>
#include<conio.h>
void main()
{
int fahr,cent;
clrscr();
printf("enter the value of temperature in fahrenheat");
scanf("%d",&fahr);
cent=5*(fahr-32)/9;
printf("value of centigrade temperature=%d\n",cent);
getch();
}
=============================================================================================================================================================================
                                                Find velocity of substance using v=u+at^2/2
#include<stdio.h>
#include<conio.h>
void main()
{
int u,t,a;
float d;
printf("enter the value of u,t and a");
scanf("%d %d %d",&u,&t,&a);
d=u*t+a*t^2;
printf("distance d=%f\n",d);
getch();
}
===========================================================================================================================================================================
                                                 Find the area of  circle
#include<stdio.h>
#include<conio.h>
#define pi=3.1415
void main()
{
int r;
float a;
printf("enter the value of radious");
scanf("%d",&r);
a=pi*r*r;
printf("enter the value of area=%f\n",a);
getch();
}