A C program for finding a Factorial of user entered number.
In order to copy this code move your cursor to upper right corner of the post a source button will appear click on it and copy the code.
#include<stdio.h>
#include<conio.h>
void main() {
int i,n,ans;
clrscr();
printf("\n Enter the number: ");
scanf("%d",&n);
ans=1;
for (i=n;i>=1;i--) {
ans=ans*i;
}
printf("\n The factorial of this number is %d",ans);
printf("\n\n Press any key to exit the program...");
getch();
}
A C program for arranging elements of user entered array in ascending or descending order and finding minimum and maximum value among all.
In order to copy this code move your cursor to upper right corner of the post a source button will appear click on it and copy the code.
#include<stdio.h>
#include<conio.h>
void main() {
int n[10],i,j,t,max,min;
clrscr();
for (i=0;i<10;i++) {
printf("\n Enter the %d number: ",i+1);
scanf("%d",&n[i]);
}
for (i=0;i<20;i++) {
for (j=i+1;j<10;j++) {
t=n[i];
if (n[i]>n[j]) {
n[i]=n[j];
n[j]=t;
}
}
}
max=n[0];
min=n[0];
for (i=0;i<20;i++) {
if (max<n[i])
max=n[i];
if (min>n[i])
min=n[i];
}
printf("\n The sorted array is as follow: \n");
for (i=0;i<5;i++) {
printf("%d\n",n[i]);
}
printf("\n The max value in the array is: %d",max);
printf("\n The min value in the array is: %d",min);
getch();
printf("\n\n\n Copyright {EZOEC ISOC}");
printf("\n\n Press any key to exit the program...");
getch();
}

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Void « Default
Life
Earth
Wind
Water
Fire
Light 