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

Saturday, 14 January 2012

Program for Leap year Checking


#include
#include
#include
void main()
{
int year;
clrscr();
printf("enter the year=");
scanf("%d",&year);
if(year%4==0)
{
printf("Leap Year");
}
else
{
printf("not a Leap Year");
}
getch();
}
 

Write a Program to check an integer for perfect square


#include
#include
#include
void main()
{
int num,root;
clrscr();
printf("enter the number=");
scanf("%d",&num);
root=sqrt(num);
if(num==root*root)
{
printf("Perfect Square");
}
else
{
printf("not a perfect Square");
}
getch();
}
 

Conversion of Centigrade temperature to fahrenheit


 #include
#include
void main()
{
float fahr,cent;
clrscr();
printf("Enter the temperature in centigrade=");
scanf("%f",¢);
fahr=1.8*cent+32.0;
printf("%f centigrade is equals to the %f fahrenheit",cent,fahr);
getch();
}
 

Write a Program to Convert KiloMeter into Meter,Centimeter,Inch


 #include
#include
void main()
{
long int kilometer,meter,centimeter;
double inch,feet;
printf("Enter the Value in kilometer=");
scanf("%ld",&kilometer);
meter=kilometer*1000;
centimeter=meter*100;
inch=centimeter/2.5;
//feet=
printf("%ld Kilometer is Equals to %ld meter\n",kilometer,meter);
printf("%ld kilometer is Equals to %ld centimeter\n",kilometer,centimeter);
printf("%ld kilometer is Equals to %lf inch",kilometer,inch);
getch();
}

 

Tuesday, 22 November 2011

Interchange Values of Two numbers Without using third variable

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter First number=");
scanf("%d",&a);
printf("Enter Second number=");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}
Earn upto Rs. 9,000 pm checking Emails. Join now!

Interchange Values of Two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter First number=");
scanf("%d",&a);
printf("Enter Second number=");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}

 
Earn upto Rs. 9,000 pm checking Emails. Join now!

Monday, 21 November 2011

Write a Program to calculate area of a Rectangle

#include<conio.h>
#include<stdio.h>
void main()
{
int length,breadth,area_of_rectangle;
clrscr();
printf("Enter the Length=");
scanf("%d",&length);
printf("Enter the Breadth=");
scanf("%d",&breadth);
area_of_rectangle=length*breadth;
printf("Area of rectnagle is=%d",area_of_rectangle);
getch();
}

 

Write a Program to calculate area of a circle

#include<conio.h>
#include<stdio.h>
void main()
{
double radius,area_of_circle;
clrscr();
printf("Enter the radius=");
scanf("%lf",&radius);
area_of_circle=3.14*radius*radius;
printf("Area of Circle is=%lf",area_of_circle);
getch();
}

Sunday, 13 November 2011

If a five-digit number is input through the keyboard,write a program to reverse the number?

/*Reverse a Number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int number,reverse_number;
clrscr();
printf("Enter the Number you want to reverse:");
scanf("%d",&number);
/*we use while loop and '%' to seprate a number*/
printf("Reverse number is:");
while(number>0)
{
reverse_number=number%10;
number=number/10;//update number
printf("%d",reverse_number);
}
getch();
}

If a five-digit number is input through the keyboard ,write a program to calculate the sum of its digit?

/*Sum of  Digit of  a Number*/
#include
#include
void main()
{
int number,sum=0;
clrscr();
printf("Enter the Number you want to Sum its digit:");
scanf("%d",&number);
/*we use while loop and '%' to separate a number*/
printf("Sum of its digit is:");
while(number>0)
{
sum=sum+(number%10);
number=number/10;//update number
}
printf("%d",sum);
getch();
}