Documente Academic
Documente Profesional
Documente Cultură
No: 8
Date:
AIM:
ALGORITHM:
Step3: Compare the a,b,c and find the greatest of three numbers.
#include<stdio.h>
#include<conio.h>
Void main()
int a, b,c;
int great;
clrscr();
printf(“Enter a,b,c:”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
if(a>c) great=a;
else great=c;
else
if(b>c) great=b;
else great=c;
getch();
}
OUTPUT:
Enter a,b,c: 10 20 30
RESULT:
Thus the greatest among three numbers was executed and the result verified.
Ex. No: 9
Date:
PRIME OR NOT
AIM:
ALGORITHM:
Step 3: If any number between 2 to n-1 divides the number n then print ‘not a prime number’,
else print ‘prime number’.
#include<stdio.h>
#include<conio.h>
Void main()
int n,i;
int i.sprime=1;
clrscr();
Scanf(“%d”,&n)
for(i=2;i<=n-1;i++)
if((n%i)==0) isprime=0;
if(isprime==1)
printf(“%d is prime.”,n);
else
getch();
}
OUTPUT:
Run 1:
8 is NOT prime.
Run 2:
7 is prime.
RESULT:
Thus a program to check whether the given number is prime or not was
executed and the result verified.
Ex. No: 10
Date:
AIM:
To write a program to find the sum and average of the given ‘N’ numbers.
ALGORITHM:
#include<stdio.h>
#include<<conio.h>
void main()
float avg;
clrscr();
scanf(“%d”,&n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
sum+=a[i]
getch();
OUTPUT:
RESULT:
Thus a program to find the sum and average of given N umbers executed and the
result verified.