Sunteți pe pagina 1din 4

write the program for prime numbers?

Answer
# 5
#include<stdio.h>
main()
{
int i,n,count=0;
printf("enter a no.");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
count++;
}
}
if(count>1)
{
printf("not prime no.");
}
else
printf("prime");
}

C program to reverse the digits of a number?


In: Computer Programming, C Programming [Edit categories]
Dell Take Your Own Pathwww.Dell.com/TakeYourOwnPath_India
Choose Dell For Growing Business. Powered w/ Intel® Core . Visit Now.
Ads
[Improve]
#include
#include
void main()
{
clrscr();
int r=0,d,m,n;
printf("Enter a value:");
scanf("%d",&n);
m=n;
do
{
d=m%10;
m= m/10;
r=(r*10)+d;
}
while(m!=0);
printf("%d is the reverse \n",r);
}
getch();
}

Read more: http://wiki.answers.com/Q/C_program_to_reverse_the_digits_of_a_number


#ixzz1BBbh0kla
main()
{
int amm=0,temp=0,n,x;
printf("enter thealue of n");
scanf("%d",&n);
x=n;
for(;n>0;)
{
temp=n%10;
amm=amm+(temp*temp*temp);
n=n/10;
}
if(x==n)
{
printf("THE GIVEN NUMBER IS AMSTRONG NUMBER");
}
else
printf("NOT AMSTRONG NUMBER");

void main()
{
int n,b=0,t;
clrscr();
printf( Enter the no );
scanf( %d ,&n);
t=n;
while(n>0)
{
a=n%10;
b=b+a*a*a;
n=n/10;
}
if(b==t)
{
printf( Armstrong no );
}
else
{
printf( Not an armstrong no );
}
getch();
}

Write a program to generate the Fibonacci Series?


In: C Programming, JavaScript, C Plus Plus Programming [Edit categories]
Win $50 Cash For Surveywww.surveymonkey.com/s/WB63RVH
Troubleshooting for Fun and Profit Get Promoted to Architect!
Ads
[Improve]
#include<stdio.h>
main()
{
int i=-1, j =1, n=8;
while( n-- > 0 && printf ("%d\t", j = (i = i) + (i = j) ) );
}

Read more: http://wiki.answers.com/Q/Write_a_program_to_generate_the_Fibonacci_S


eries#ixzz1BBc9jKos

#include<stdio.h>
main()
{
unsigned long int n,f;
printf("\nenter the number for which you want to find the factorial");
scanf("%d",&n);
f=fact(n);
printf("\nthe factorial of the number %d is %d",n,f);
}
fact(int n)
{
int k;
if(n==0)
return(1);
else
{
k=n*fact(n-1);
}
return(k);
}

STRING REVERSE PROGRAM


#include
#include
#include
void main()
{
char srcstr[30],desstr[30];
int i,len;
clrscr();
cout<<"\nenter the string\n";
cin>>srcstr;
len=strlen(srcstr);
for(i=0;srcstr[i]!='\0';i++)
{
desstr[--len]=srcstr[i];
}
desstr[i]='\0';
cout<<"\nreversed string is\n";
for(i=0;desstr[i]!='\0';i++)
{
cout< }
getch();
}

#include
main ()
{
int num,mod,rev=0;
printf("Enter a number:");
scanf("%d", &num);
while (num>0)
{
mod=num%10;
rev=(rev*10)+mod;
num=num/10;
}
printf("Reverse of the given number: %d", rev);
getchar();
}

S-ar putea să vă placă și