C Language: Paras Goyal Bca Semester-1 (2-SHIFT) Enroll. No. (02624002016)
C Language: Paras Goyal Bca Semester-1 (2-SHIFT) Enroll. No. (02624002016)
PARAS GOYAL
BCA SEMESTER-1
(2-SHIFT)
ENROLL. NO.
(02624002016)
1
1. Write a program to perform addition, subtraction,
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,c,add,sub,mul,div;
clrscr();
printf("\n enter the value of a=");
scanf("%f",&a);
printf("\n enter the value of b=");
scanf("%f",&b);
printf("\n enter the value of c=");
scanf("%f",&c);
add=a+b+c;
printf("\n addition of a,b and c= %f",add);
sub=a-b-c;
printf("\n substraction of a,b and c= %f",sub);
mul=a*b*c;
printf("\n multiplication of a,b and c= %f",mul);
div=a/b/c;
printf("\n division of a,b and c= %f",div);
getch();
}
2
OUTPUT
3
2. Write a program to calculate simple interest.
#include<stdio.h>
#include<conio.h>
void main()
float t,rt,p,si;
clrscr();
printf("enter years:");
scanf("%f",&t);
printf("\nenter rate:");
scanf("%f",&rt);
printf("\nenter principal:");
scanf("%f",&p);
si=(t*rt*p)/100;
printf("\nsimple interest:%f",si);
getch();
4
OUTPUT
5
3. Write a program to find whether the number entered is even
or odd.
#include<stdio.h>
int main()
{
int n;
clrscr();
printf("\n enter an integer=");
scanf("%d",&n);
if(n%2==0)
printf("\n its a even number");
else
printf("\n its a odd number");
return 0;
}
OUTPUT
6
4. Write a program to calculate Area & Circumference of circle
and Area & Perimeter of rectangle.
#include<stdio.h>
#include<conio.h>
void main()
{
int r,l,b,area1,area2,circumference,perimeter;
clrscr();
printf("\n enter the value of radius=");
scanf("%d",&r);
printf("\n enter the value of length=");
scanf("%d",&l);
printf("\n enter the value of breadth=");
scanf("%d",&b);
circumference= 2*22/7*r;
area1= 22/7*r*r;
perimeter=2*(l+b);
area2= l*b;
printf("\n circumference of circle= %d",circumference);
printf("\n area of circle= %d",area1);
printf("\n perimeter of rectangle= %d",perimeter);
printf("\n area of rectangle= %d",area2);
getch();
}
7
OUTPUT
8
5. Write a program interchange/swap values of two integers
9
OUTPUT
OUTPUT
11
6. Write a program to calculate the sum of all digits of a five
digit number and the sum of the first and last digit of the
entered number.
12
(2) sum of first and last digit of a five digit number
#include<stdio.h>
int main()
{
int no,first,last;
int sum=0;
clrscr();
printf("\n enter the number:");
scanf("%d",&no);
first=no%10;
last=no/10000;
sum=first+last;
printf("\n the sum of fist and last digit of %d is %d",no,sum);
return 0;
}
OUTPUT
13
7. Write a program to calculate aggregate percentage of a
OUTPUT
14
8. Write a program to add two numbers using for loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,sum;
clrscr();
for(x=0;x<=3;x++)
{
for(y=0;y<=3;y++)
{
sum=x+y;
printf("\n addition of two number is: %d",sum);
}
}
getch();
}
OUTUPUT
15
9. Write a program to calculate simple interest for 3 instances
16
OUTPUT
17
}
getch();
}
OUTPUT
18
10. Write a program to calculate sum of two numberts using call
OUTPUT
19
(2) Using call by value
#include<stdio.h>
#include<conio.h>
int add(int i,int j);
void main()
{
int i,j,sum;
clrscr();
printf(" enter the value of i and j");
scanf("%d\t%d",&i,&j);
sum=add(i,j);
printf("\n sum of %d and %d is: %d",i,j,sum);
getch();
}
int add(int i,int j)
{
return i+j;
}
OUTPUT
20
11. Write a program to calculate factorial of a number using
recursion.
#include<stdio.h>
#include<conio.h>
int factorial(int i);
void main()
{
int n,result;
clrscr();
printf("enter factorial:");
scanf("%d",&n);
result=factorial(n);
printf("\n %d",result);
getch();
}
int factorial(int i)
{
printf("%d*",i);
if(i<=1)
{
return 1;
}
else
return i*factorial(i-1);
}
OUTPUT
21
12. Write a program to print fibonnacci series using recursion.
#include<stdio.h>
int fibonnacci(int i)
{
if(i==0)
{
return 0;
}
if(i==1)
{
return 1;
}
return fibonnacci(i-1)+fibonnacci(i-2);
}
int main()
{
int i;
clrscr();
for(i=0;i<9;i++)
{
printf("\t %d",fibonnacci(i));
}
OUTPUT
22
13. For an integer i=3 having pointer int *j and int **k. Write a
23
OUTPUT
24
25
26