Professional Documents
Culture Documents
NEUROPSYCHOLOGY
COMPUTER ASSINGMENT
Submitted by
(KARAMJEET KAUR)
Roll no: 25
Submitted to
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;
scanf("%d",&radius);
getch();
OUTPUT:
Enter the radius of Circle : 2.0
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;
scanf("%d",&length);
scanf("%d",&breadth);
getch();
}
OUTPUT:
Enter the Length of Rectangle : 5
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;
scanf("%d",&side);
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++;
}
OUTPUT:
Enter 10 elements : 11 12 13 14 15 16 17 18 19 20
SIGNATURE:
EXPERIMENT 11
DATE:
void main()
{
int a,b,c;
clrscr();
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
void main()
{
int num,rem,rev=0;
clrscr();
while(num>=1)
{
rem = num % 10;
rev = rev * 10 + rem;
num = num / 10;
}
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();
sum = s1 + s2 + s3 + s4 + s5;
printf("nSum : %d",sum);
printf("nPercentage : %f",per);
getch();
}
OUTPUT:
Enter 10 elements : 11 12 13 14 15 16 17 18 19 20
PROCEDURE:
#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3,s4,s5,sum,total=500;
float per;
clrscr();
sum = s1 + s2 + s3 + s4 + s5;
printf("nSum : %d",sum);
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
OUTPUT: