0% found this document useful (0 votes)
37 views21 pages

KIMMI

The document contains 15 experiments on various programming concepts conducted by a student. Each experiment contains the date, objective, software used, procedure, output, and conclusion. The experiments cover topics like calculating sum and average of numbers, area of geometric shapes, prime numbers, reversing and summing digits of a number, arrays, pointers, greatest of 3 numbers, percentage calculation, and factorial using recursion. The procedures demonstrate the use of basic programming constructs like loops, functions, conditional statements, and arithmetic operations.

Uploaded by

Sana chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views21 pages

KIMMI

The document contains 15 experiments on various programming concepts conducted by a student. Each experiment contains the date, objective, software used, procedure, output, and conclusion. The experiments cover topics like calculating sum and average of numbers, area of geometric shapes, prime numbers, reversing and summing digits of a number, arrays, pointers, greatest of 3 numbers, percentage calculation, and factorial using recursion. The procedures demonstrate the use of basic programming constructs like loops, functions, conditional statements, and arithmetic operations.

Uploaded by

Sana chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

AMITY INSTITUTE OF NEUROSCIENCES AND

NEUROPSYCHOLOGY

AMITY UNIVERSITY, U.P.

COMPUTER ASSINGMENT
Submitted by
(KARAMJEET KAUR)

Roll no: 25

Enrolment No- A13671916005

B.Sc. (Hons.) Neurosciences

Batch 2016, 1st semester

Submitted to

Faculty Name : Ms. SUDHRITI SEN GUPTA

EXPERIMENT 1
DATE:
OBJECTIVE: Write a program to find the sum of two numbers. Calculate the average of
number.
SOFTWARE USED: Turbo C
PROCEDURE:
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
float a,b;
printf("Enter First number: ");scanf("%f",&a);
printf("Enter Second number : ");scanf("%f",&b);
printf("The sum of the numbers is : %fm",a+b);
printf("\nThe average of numbers is : %f",(a+b)/2);
getch();
}
OUTPUT:

CONCLUSIONS:
The program shows the sum of 2 numbers and their average by using arithmetic operators.

SIGNATURE:

EXPERIMENT 2
DATE:
OBJECTIVE: Write a program to find a area of triangle using hero’s formula.
SOFTWARE USED: Turbo C
PROCEDURE:
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
float e,a,b,c,d,s;
printf("Enter sides of triangle :\n");
printf("Side a = ");scanf("%f",&a);
printf("Side b = ");scanf("%f",&b);
printf("Side c = ");scanf("%f",&c);
s=(a+b+c)/2;
d=s*(s-a)*(s-b)*(s-c);
e=sqrt(d);
printf("\nArea of triangle is %f",e);
getch();

OUTPUT:

CONCLUSION:
The program shows the area of triangle by using arithmetic operators and functions use in maths like
sqrt etc., defined in math.h.

SIGNATURE:

EXPERIMENT 3
DATE:
OBJECTIVE: Write a program to check number is prime or not.
SOFTWARE USED: Turbo C
PROCEDURE:
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a,i,j,k=0;
printf("\nEnter a number to check whether it is prime or composite : ");
scanf("%d",&a);
j=a-1;
for (i=2;i<=j;i++)
{
if(a%i==0)
{
k=1;
}
}
if(k==1)
{
printf("The number is composite");
}
else
{
printf("The number is prime");
}
getch();
}
OUTPUT:

CONCLUSIONS:
The program shows whether the number is prime or not. For loop has been used.

SIGNATURE:
EXPERIMENT 4
DATE:
OBJECTIVE: Write a program to reverse a number and sum of digit of number.
SOFTWARE USED: Turbo C
PROCEDURE:
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a,b,c=0,d=0
printf("Enter a number : ");
scanf("%d",&a);
printf("\nThe reverse of no is : ");
for(a;a!=0;a=a/10)
{
b=a%10;
c=c+b;
printf("%d",b);
}
printf("\nThe sum of digits is : %d",c);
getch();
}
OUTPUT:

CONCLUSION:
The first program shows the reverse of a number and the sum of digits based on arithmetic
operations since / displays only quotient while % displays only remainder.

SIGNATURE:
EXPERIMENT 5
DATE:
OBJECTIVE: Find the factorial of a number using function
SOFTWARE USED: Turbo C
PROCEDURE:
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
void fact();
fact();
getch();
}
void fact()
{
int a,b,c=1;
printf("Enter a number : ");scanf("%d",&a);
for(b=1;b<=a;b++)
{
c=c*b;
}
printf("The factorial of number is: %d",c);
};

OUTPUT

CONCLUSION:
The program shows the factorial of a number and also by defining its arithmetic operation in another
or user define function.

SIGNATURE:
EXPERIMENT 6
DATE:
OBJECTIVE: Write a program to display elements of array
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,num[2][2];
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("Enter a value for %d%d place ",i,j);
scanf("%d",&num[i][j]);
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("You entered %d for %d%d place.\n",num[i][j],i,j);
}
}
getch();
}
OUTPUT:

CONCLUSION:
The program displays the elements of array ussing the function of array and for loop.

SIGNATURE:
EXPERIMENT 7
DATE:
OBJECTIVE: Write a program to calculate area of circle
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>

#include<conio.h>

void main()

float radius,area;

clrscr(); // Clear Screen

printf("Enter the radius of Circle : ");

scanf("%d",&radius);

area = 3.14 * radius * radius;

printf("Area of Circle : %f",area);

getch();

OUTPUT:
Enter the radius of Circle : 2.0

Area of Circle : 12.56

CONCLUSION:
The program calculates the area of a circle

SIGNATURE:
EXPERIMENT 8
DATE:
OBJECTIVE: Write a program to calculate area of rectangle
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>

#include<conio.h>

void main()

int length,breadth,side;

clrscr(); // Clear Screen

printf("Enter the Length of Rectangle : ");

scanf("%d",&length);

printf("Enter the Breadth of Rectangle : ");

scanf("%d",&breadth);

area = length * breadth;

printf("Area of Rectangle : %d",area);

getch();

}
OUTPUT:
Enter the Length of Rectangle : 5

Enter the Breadth of Rectangle : 4

Area of Rectangle : 20

CONCLUSION:
The program calculates the area of a rectangle

SIGNATURE:
EXPERIMENT 9
DATE:
OBJECTIVE: Write a program to calculate area of square
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>

#include<conio.h>

void main()

int side,area;

clrscr(); // Clear Screen

printf("nEnter the Length of Side : ");

scanf("%d",&side);

area = side * side ;

printf("nArea of Square : %d",area);

getch();

OUTPUT:
Enter the Length of Side : 5

Area of Square : 25

CONCLUSION:
The program calculates the area of a square

SIGNATURE:
EXPERIMENT 10
DATE:
OBJECTIVE: Write a program to compute sum of the array elements using pointers
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10];
int i,sum=0;
int *ptr;

printf("Enter 10 elements:n");

for(i=0;i<10;i++)
scanf("%d",&a[i]);

ptr = a; /* a=&a[0] */

for(i=0;i<10;i++)
{
sum = sum + *ptr; //*p=content pointed by 'ptr'
ptr++;
}

printf("The sum of array elements is %d",sum);


}

OUTPUT:

Enter 10 elements : 11 12 13 14 15 16 17 18 19 20

The sum of array elements is 155


CONCLUSION:
The program computes sum of the array elements using pointers

SIGNATURE:
EXPERIMENT 11
DATE:

OBJECTIVE: Write a program to find greatest in 3 numbers


SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c;
clrscr();

printf("nEnter value of a, b & c: ");


scanf("%d %d %d",&a,&b,&c);

if((a>b)&&(a>c))
printf("na is greatest");

if((b>c)&&(b>a))
printf("nb is greatest");

if((c>a)&&(c>b))
printf("nc is greatest");

getch();
}

OUTPUT:
Enter value for a,b & c : 15 17 21
c is greatest
CONCLUSION:
The program computes greatest of 3 numbers

SIGNATURE
EXPERIMENT 12
DATE:
OBJECTIVE: Write a program to reverse a given number

SOFTWARE USED: Turbo C


PROCEDURE:
#include<stdio.h>
#include<conio.h>

void main()
{
int num,rem,rev=0;
clrscr();

printf("nEnter any no to be reversed : ");


scanf("%d",&num);

while(num>=1)
{
rem = num % 10;
rev = rev * 10 + rem;
num = num / 10;
}

printf("nReversed Number : %d",rev);


getch();
}

OUTPUT:
Enter any no to be reversed : 123
Reversed Number : 321

CONCLUSION:
The program reverses a given no.
SIGNATURE:
EXPERIMENT 13
DATE:
OBJECTIVE: Write a program to calculate sum of 5 subjects and find percentage
SOFTWARE USED: Turbo C
PROCEDURE:
#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3,s4,s5,sum,total=500;
float per;

clrscr();

printf("nEnter marks of 5 subjects : ");


scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);

sum = s1 + s2 + s3 + s4 + s5;

printf("nSum : %d",sum);

per = (sum * 100) / total;

printf("nPercentage : %f",per);
getch();
}

OUTPUT:

Enter 10 elements : 11 12 13 14 15 16 17 18 19 20

The sum of array elements is 155

CONCLUSION:The program computes sum of the array elements using pointers


SIGNATURE:
EXPERIMENT 14
DATE:
OBJECTIVE: Write a program to calculate sum of 5 subjects and find percentage

SOFTWARE USED: Turbo C

PROCEDURE:
#include<stdio.h>
#include<conio.h>

void main()
{
int s1,s2,s3,s4,s5,sum,total=500;
float per;

clrscr();

printf("nEnter marks of 5 subjects : ");


scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);

sum = s1 + s2 + s3 + s4 + s5;

printf("nSum : %d",sum);

per = (sum * 100) / total;

printf("nPercentage : %f",per);
getch();
}

OUTPUT:
Enter marks of 5 subjects : 80 70 90 80 80
Sum : 400
Percentage : 80.00

CONCLUSION:
The program calculates sum of 5 subjects and find percentage
SIGNATURE:
EXPERIMENT 15
DATE:
OBJECTIVE: Write a program to find factorial using recursion

SOFTWARE USED: Turbo C


PROCEDURE:
#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int x,n;
printf("nEnter the value of n :");
scanf("%d",&n);
x=fact(n);
printf("n%d",x);
getch();
}
int fact(int n)
{
if(n==0)
return(1);
return(n*fact(n-1));
}

OUTPUT:

CONCLUSION:The program finds factorial using recursion


SIGNATURE:

You might also like