Professional Documents
Culture Documents
Bca Projcet
Bca Projcet
Output
Q. write a program addition the integer ?
/*File Name:addition.c
Author Name:Dheeraj sahu
Date:
Description:A program for doing addition of given number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,a,sum=0;
clrscr();
printf("enter the totel count of number");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("enter the number");
scanf("%d",&a);
sum=sum+a;
}
printf("the result of addition=%d",sum);
getch();
}
Output
Q. write a program printing a reverse number ?
/*File Name:revers.c
Author Name: Dheeraj Sahu
Date:23/02/2014
Description:A program for printing revers number of given
number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a;
clrscr();
printf("enter the number");
scanf("%d",&n);
while(n>0)
{
a=n%10;
printf("%d",a);
n=n/10;
}
getch();
}
Output-
Q. write a program to calculate the factorial?
/*File Name:factorial.c
Author Name:Dheeraj sahu
Date:
Description:A program for calculate factorial of given number*/
#include<stdio.h>
#include<conio.h>
int a,i,b;
int fact(int n);
void main()
{
clrscr();
printf("enter the number");
scanf("%d",&a);
b=fact(a);
printf("factorial=%d",b);
getch();
}
int fact(int n)
{
if(n==0)
return 0;
else if(n==1)
return 1;
else
return n*fact(n-1);
}
Output
Q.write a program printing the fibonocci number?
/*name-dheeraj sahu
date of written-23/01/2014
file name-abc.c
description -fibnoseries */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,i,c;
clrscr();
a=0;
b=1;
printf("enter the digit number");
scanf("%d",& n);
printf("%d", a);
printf("%d", b);
for(i=0;i<=n;i++)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
}
getch();
}
Output
Q. A shpokeeper sells soap cakes at the price of RS 20.The
purchase price is RS 15. Write a program to calculate the
selling price of X soap cakes and the profit he earns on selling
x soap cakes ?
/*
file name: bde.c
author name: Dheeraj sahu
date:23/02/2014
description: calculate the profit
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int x ,y, profit;
clrscr();
printf("enter the purchase prize");
scanf("%d",&x);
printf("enter the selling prize");
scanf("%d",&y);
profit=y-x;
printf("profit=%d”);
getch();
}
Output-
Q.write a program for doing addition of corresponding number of
given ?
/*File Name: totel.c
Author Name: Dheeraj sahu
Date: 09/02/2014
Description: program for doing addition of corresponding number
of given number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,sum=0;
clrscr();
printf("enter the number");
scanf("%d",&n);
while(n>0)
{
a=n%10;
sum=sum+a;
n=n/10;
}
printf("totel=%d",sum);
getch();
}
Output-
Q. Write a program to calculate the income tax?
/*File Name: incometax.c
Author name: Dheeraj sahu
Date: 28/02/2014
Description: A program for calculate income tax */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
float income,yincome,tincome,incometax;
do
{
clrscr();
printf("enter your monthly income\n");
scanf("%f",&income);
yincome=income*12;
if(yincome<=200000)
{
printf("No tax\n");
}
else if(yincome>200000 && yincome<=500000)
{
tincome=yincome-200000;
incometax=tincome*10/100;
printf("Income Tax=%f\n",incometax);
}
else if(yincome>500000 && yincome<=800000)
{
tincome=yincome-200000;
incometax=tincome*20/100;
printf("Income Tax=%f\n",incometax);
}
else
{
tincome=yincome-200000;
incometax=tincome*30/100;
printf("Income Tax=%f\n",incometax);
}
printf("for another calculation press -1 otherwise any other
number\n");
scanf("%d",&i);
}while(i==-1);
getch();
}
Output-
Q. Write a program to input integer length and find whether a
triagle can be formed or not?
/*File Name: triangle.c
Author Name: Dheeraj sahu
Date: 10/03/2014
Description:A program for calculate a triangle formated or not*/
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("enter the length");
scanf("%d",&a);
printf("enter the length");
scanf("%d",&b);
printf("enter the length");
scanf("%d",&c);
if(c>a && c>b)
{
if(c<a+b)
printf("triangle is formed");
else
printf("triangle is not formed");
}
else if(b>c && b>a)
{
if(b<a+c)
printf("triangle is formed");
else
printf("triangle is not formed");
}
else if(a>b && a>c)
{
if(a<c+b)
printf("triangle is formed");
else
printf("triangle is not formed");
}
getch();
}
Output-
Q. Write a program to check whether a character string is a
palindrome or not ?
/*file name - abd.c
date ofwrriten-30/01/2014
author name -dheeraj sahu
description - palindrum */
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20]; int n,i,j=0;
puts("emter the value");
gets(a);
n=strlen(a);
for(i=0;i<n/2;i++)
{if(a[i]!=a[n-1-i])
j=1;
break;
}
if(j==0)
puts("palindrum");
else
puts("not a palindrum");
getch();
}
Output
Q. Write A program for check that number is fibnocci and
positive or negative?
/*File Name:numchack.c
Author:Gourav Tiwari
Date:
Description:A program for check that number is
fibnocci and positive or negative
*/
#include<stdio.h>
#include<conio.h>
main()
{
int a,d=0,c=1,i,b;
clrscr();
printf("enter the number");
scanf("%d",&a);
if(a>=0)
{
printf("this number is positive");
for(i=0;i<100;i++)
{
b=d+c;
if(b==a || a==0)
{
printf(" & fibonacci number");
break;
}
d=c;
c=b;
}
}
else
printf("this number is negative");
getch();
}
Output -
Q. Write a program for identify prime number?
/*File Name:prime.c
Author Name: Dheeraj sahu
Date:
Description:A program for identify prime number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,c,i;
clrscr();
printf("enter the number");
scanf("%d",&a);
for(i=1;i<=a;i++)
{
if(a%i==0)
c=c+1;
}
if(c==2)
printf("%d is prime number",a);
else
printf("%d is not prime number",a);
getch();
}
Output-
Q. write a program for identify even & odd number ?
/*File Name:evenodd.c
Author Name:dheeraj sahu
Date:
description:A program for identify even & odd number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("enter the integer number");
scanf("%d",&a);
if(a%2==0)
{
printf("enter number is even");
}
else
{
printf("enter number is odd");
}
getch();
}
Output-
Q. Write a program for calculate the age?
/*File Name: DOB.c
Author Name:dheeraj sahu
Date:26/02/2014
description:A program for calculate the age*/
#include<stdio.h>
#include<conio.h>
void main()
{
int month=12,year,date=30,mn,nj,kl,d,m,y;
clrscr();
printf("enter the current date");
scanf("%d",&mn);
printf("enter the current month");
scanf("%d",&nj);
printf("enter the current year");
scanf("%d",&kl);
printf("enter the birth date");
scanf("%d",&date);
printf("enter the birth month");
scanf("%d",&month);
printf("enter the birth year");
scanf("%d",&year);
d=mn-date;
m=nj-month;
y=kl-year;
if(m<0)
{
m=m+12;
y=y-1;
printf("day=%d month=%d year=%d",d,m,y);
}
else
printf("%d %d %d",d,m,y);
getch();
}
Output-
Q. Write A program for calculating electricity bill?
/*File Name:Electricity.c
Author Name: Dheeraj Sahu
Date:
Description: A program for calculating electricity bill
*/
#include<stdio.h>
#include<conio.h>
main()
{
float unit,bill;
int another;
do
{
clrscr();
printf("enter the unit of electricity of this month\n");
scanf("%f",&unit);
if(unit<=100)
{
bill=unit*3;
}
else if(unit>100 && unit<=500)
{
bill=unit*5;
}
else if(unit>500 && unit<=1000)
{
bill=unit*8;
}
else
{
bill=unit*10;
}
printf("%f",bill);
printf("\nfor anoher press -1 or for exit press any other
number\n");
scanf("%d",&another);
}while(another==-1);
getch();
}
Output-