Related:
- Program code needed.
- Battery reset code - Guide
- Samsung volume increase code - Guide
- How to get whatsapp verification code online - Guide
- Cs 1.6 code - Guide
- Samsung keypad reset code - Guide
2 responses
jack4rall
Posts
6428
Registration date
Sunday June 6, 2010
Status
Moderator
Last seen
July 16, 2020
Sep 15, 2010 at 08:38 AM
Sep 15, 2010 at 08:38 AM
Hello,
Try this 1.
1) To Find The Average
/* To Find The Average */
#include<stdio.h>
#include<conio.h>
main()
{
int n,i;
float t=0;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
t=t+i;
t=t/n;
printf("The average from 1 to %d is %.2f",n,t);
getch();
}
2) To find the factorial of a given number
/* To find the factorial of a given number */
#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
long t=1;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
if(n==0)
exit();
else
for(i=1;i<=n;i++)
t=t*i;
printf("Factorial of given number is %d is %ld",n,t);
getch();
}
Good Luck.
Try this 1.
1) To Find The Average
/* To Find The Average */
#include<stdio.h>
#include<conio.h>
main()
{
int n,i;
float t=0;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
t=t+i;
t=t/n;
printf("The average from 1 to %d is %.2f",n,t);
getch();
}
2) To find the factorial of a given number
/* To find the factorial of a given number */
#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
long t=1;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
if(n==0)
exit();
else
for(i=1;i<=n;i++)
t=t*i;
printf("Factorial of given number is %d is %ld",n,t);
getch();
}
Good Luck.