0% found this document useful (0 votes)
44 views

#Include #Include Void Main (Int I, N, F 1 CLRSCR Printf ("Enter A Number:/n") Scanf ("%D",&N) For (I 1 I N I++) (F F I ) Printf ("The Factorial Value Is:%d",f) Getch )

This document contains C code for several programs that perform common mathematical operations and analyses: 1) A program to calculate the factorial of a user-input number. 2) A program to check if a user-input number is prime. 3) A program to print all prime numbers up to a user-input limit. 4) A program to print the Fibonacci sequence up to a user-input limit. 5) A program to find the largest number from user-input values. 6) A program to reverse a user-input number. 7) A program to calculate the sum of digits of a user-input number. 8) A program to separately calculate the sum of

Uploaded by

ngovardhan
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)
44 views

#Include #Include Void Main (Int I, N, F 1 CLRSCR Printf ("Enter A Number:/n") Scanf ("%D",&N) For (I 1 I N I++) (F F I ) Printf ("The Factorial Value Is:%d",f) Getch )

This document contains C code for several programs that perform common mathematical operations and analyses: 1) A program to calculate the factorial of a user-input number. 2) A program to check if a user-input number is prime. 3) A program to print all prime numbers up to a user-input limit. 4) A program to print the Fibonacci sequence up to a user-input limit. 5) A program to find the largest number from user-input values. 6) A program to reverse a user-input number. 7) A program to calculate the sum of digits of a user-input number. 8) A program to separately calculate the sum of

Uploaded by

ngovardhan
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/ 4

#include<stdio.

h>
#include<conio.h>
void main()
{
int i,n,f=1;
clrscr();
printf("Enter a number:\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
printf("The factorial value is:%d",f);
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int i,n,flag=0;
printf("Enter a number:");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if (flag==0)
printf("n=%d is a prime number",n);
else
printf("n=%d is not a prime number.",n);
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=1,j,count;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
printf("Prime Numbers upto %d :\n",n);
while(i<=n)
{

count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2)
printf("%d ",i);
i++;
}
getch();
}
#include <stdio.h>
#include <conio.h>
int main()
{
int n,a=0,b=1,c,d;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
printf("Fibonacci Series: %d,%d,",a,b);
c=2;
while (c<n)
{
d=a+b;
a=b;
b=d;
c++;
printf("%d,",d);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,i,big=1;
clrscr();
printf("Enter a number:\n");
scanf("%d",&n);
printf("Enter values:\n");
for(i=1;i<=n;i++)
{
scanf("%d",&m);
if(big<m)
big=m;
}
printf("Largest number is: %d",big);
getch();

}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,b=0;
clrscr();
printf("Enter a number:\n");
scanf("%d",&n);
while(n!=0)
{
a=n%10;
b=b*10+a;
n=n/10;
}
printf("Reverse of a number is: %d",b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a=1,b=0;
clrscr();
printf("Enter a number:\n");
scanf("%d",&n);
while(n!=0)
{
a=n%10;
b=b+a;
n=n/10;
}
printf("sum of digits is: %d",b);
getch();
}
#include<stdio.h>
void main()
{
int n, a = 0, b = 0, m,i;
clrscr();
printf("Enter how many numbers you want print:\n");
scanf("%d",&n);
printf("Enter numbers:\n");
for(i=0;i<n;i++)
{
scanf("%d",&m);
if(m > 0)
a += m;

else
b += m;
}
printf("Sum of +ve number:%d\n",a);
printf("Sum of -ve number:%d\n",b);
getch();
}

You might also like