Aditya 4
Aditya 4
of
BACHELOR OF TECHNOLOGY
In
Session 2023-24
SCHOOL OF COMPUTING
DIT UNIVERSITY, DEHRADUN
(State Private University through State Legislature Act No. 10 of 2013 of Uttarakhand and approved by UGC)
Mussoorie Diversion Road, Dehradun, Uttarakhand - 248009, India.
August-December 2023
INDEX
CONDUCTION INSTRUCTOR’s
S.NO. NAME OF THE EXPERIMENTS
DATE SIGNATURE
WAP to find factorial of a given number using
1
recursion.
WAP to convert decimal numbers into binary
2
numbers using recursion.
WAP to use recursive calls to evaluate F(x)=x-
3
x^3/3!+x^5/5!-x^7/7!+…..+x^n/n!
Define a structure data type called time_struct
containing three members’ integer hours,minutes
4 and seconds.Develop a program that assigns values
to individual members and displays time in the
following format :HH:MM:SS.
WAP to create the book’s structure with
5 title,author name,publication,and price.Read data
of n books and display them.
Define a structure person that would contain the
person’s name,date of joining,and salary using this
6
structure to read this information of 5 people and
print the same on screen.
Using cricket,declare an array player with 50
elements and WAP to read the information about
7 all the 50 players and print a team-wise list
containing players’ names with their batting
average.
#include <stdio.h>
int fact(int x)
{
if(x==0||x==1)return 1;
else
return x*fact(x-1);
}
void main() {
int n;
printf("Enter a number ");
scanf("%i",&n);
printf("Factorial =%i",fact(n));
}
Output:
#include <stdio.h>
int convert(int x)
{
if (x==0)
return 0;
else
return (x%2+10*convert(x/2));
}
void main()
{
int n;
printf("Enter a number ");
scanf("%i",&n);
printf("Binary representative: %i",convert(n));
}
Output:
#include<stdio.h>
int fact(int x)
{
if(x==0||x==1)return 1;
else
return x*fact(x-1);
}
double power(double x, int n) {
if (n == 0) {
return 1.0;
} else {
return x * power(x, n - 1);
}
}
double series(int n, double x) {
if (n == 0)
return 0;
else {
double term=power(-1,n-1)*power(x,2*n-1)/fact(2*n-1);
return term+series(n-1,x);
}
}
double sum(int x, int n)
#include <stdio.h>
struct time_struct {
int hours;
int minutes;
int seconds;
};
void main() {
struct time_struct my_time = {12, 34, 56};
printf("Time: %02d:%02d:%02d\n", my_time.hours, my_time.minutes,
my_time.seconds);
}
Output:
#include <stdio.h>
struct book {
char title[100];
char author[100];
char publication[100];
float price;};
void main() {
int n;
printf("Enter the number of books: ");
scanf("%d", &n);
struct book library[n];
for (int i = 0; i < n; i++) {
printf("\nEnter details for Book %d:\n", i + 1);
printf("Title: ");
scanf("%s", library[i].title);
printf("Author: ");
scanf("%s", library[i].author);
printf("Publication: ");
scanf("%s", library[i].publication);
printf("Price: ");
scanf("%f", &library[i].price);
}
printf("\nDisplaying Information for %d Books:\n", n);
#include <stdio.h>
struct person {
char name[50];
char date_of_joining[20];
float salary;
};
void main() {
int num_persons = 5;
struct person employees[num_persons];
for (int i = 0; i < num_persons; i++) {
printf("\nEnter details for Person %d:\n", i + 1);
printf("Name: ");
scanf("%s", employees[i].name);
printf("Date of Joining: ");
scanf("%s", employees[i].date_of_joining);
printf("Salary: ");
scanf("%f", &employees[i].salary);
}
printf("\nDisplaying Information for %d Persons:\n", num_persons);
for (int i = 0; i < num_persons; i++) {
printf("\nPerson %d:\n", i + 1);
printf("Name: %s\n", employees[i].name);
#include <stdio.h>
struct cricket_player {
char name[50];
float batting_average;
};
void main() {
int num_players = 5;
struct cricket_player players[num_players];
for (int i = 0; i < num_players; i++) {
printf("\nEnter details for Player %d:\n", i + 1);
printf("Name: ");
scanf("%s", players[i].name);
printf("Batting Average: ");
scanf("%f", &players[i].batting_average);
}
printf("\nDisplaying Information for %d Cricket Players:\n", num_players);
for (int i = 0; i < num_players; i++) {
printf("\nPlayer %d:\n", i + 1);
printf("Name: %s\n", players[i].name);
printf("Batting Average: %.2f\n", players[i].batting_average);}
}