0% found this document useful (0 votes)
16 views7 pages

Armstrongn Merged

The document contains multiple C programs that implement various mathematical functions, including checking for Armstrong numbers, calculating the least common multiple (LCM), identifying prime numbers, and summing prime numbers. Each program prompts the user for input and processes the data accordingly, with some programs containing logical errors. Overall, the code demonstrates basic programming concepts in C related to number theory.

Uploaded by

anushkarokade21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Armstrongn Merged

The document contains multiple C programs that implement various mathematical functions, including checking for Armstrong numbers, calculating the least common multiple (LCM), identifying prime numbers, and summing prime numbers. Each program prompts the user for input and processes the data accordingly, with some programs containing logical errors. Overall, the code demonstrates basic programming concepts in C related to number theory.

Uploaded by

anushkarokade21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

D:\c language\armstrong12.

c 1
//armstrong digits
#include<stdio.h>
void main()
{
int count;
int rem,temp1;
int r;
int n;
int sum=0;
int ans=1;
int k;
printf("Enter the value of n");
scanf("%d",&n);
int temp=temp1=n;
while(n%10>0)
{

rem=n%10;
count++;
n=n/10;

while(temp>0)
{
ans=1;
for(r=1;r<=count;r++)
{
ans=ans*(temp%10);

}
sum=sum+ans;
temp=temp/10;
}
while(temp1>0)

{
ans=1;
for(k=1;k<=count;k++)
{
ans=ans*(temp1%10);
}
sum=sum+ans;
temp1=temp/10;
}
if(r==sum)
{
printf("%d",sum);
}
}
D:\c language\armstrong.c 1
//armstrong digits
#include<stdio.h>
void main()
{
int count=0;
int rem,temp1;
int r;
int n;
int sum=0;
int ans=1;
printf("Enter the value of n");
scanf("%d",&n);
int temp=temp1=n;
while(n%10>0)
{

rem=n%10;
count++;
n=n/10;

while(temp>0)
{
ans=1;
for(r=1;r<=count;r++)
{
ans=ans*(temp%10);

}
sum=sum+ans;
temp=temp/10;
}
if(temp1=sum)
{
printf("Number is armstrong");
}
else
{
printf("number is not armstrong");
}
}
D:\c language\lcm.c 1
#include<stdio.h>
void main()
{
int ai;
int bi;
int c;
int i1;
int i;
printf("Enter the value of ai");
scanf("%d",&ai);
printf("Enter value of");
scanf("%d",&bi);
i1=ai>bi?ai:bi;
for(i=i1; ;i++)
{
if(i%ai==0 && i%bi==0)
{
printf("The lcm is%d",i);
break;
}

}
C:\Users\sunil\OneDrive\Desktop\fail\drime.c 1
#include<stdio.h>
void main()
{
int i;
int n;
int z;
printf("Enter the value of z");
scanf("%d",&z);
int count=0;
for (n=1;n<=z;n++)
{
count=0;
for(i=1;i<=n;i++)
{

if(n%i==0)
{
count++;
}
}

if(count==2)
{

printf("%d\n",n);
}

}
}
D:\c language\drime.c 1
#include<stdio.h>
void main()
{
int i;
int n;
int z;
printf("Enter the value of z");
scanf("%d",&z);
int count=0;
for (n=1;n<=z;n++)
{
count=0;
for(i=1;i<=n;i++)
{

if(n%i==0 && z%n==0)


{
count++;
}
}

if(count==2)
{

printf("%d\n",n);
}

}
}
D:\c language\primesum.c 1
#include<stdio.h>
void main()
{
int i;
int sum=0;
int n;
int z;
printf("Enter the value of z");
scanf("%d",&z);
int count=0;
for (n=1;n=z;n++)
{
count=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
{
count++;
}
}
if(count==2)
{
printf("%d",n);

}
}
}
D:\next\primenumber.c 1
#include<stdio.h>
void main()
{
int i;
int n;
printf("Enter the value of i");
scanf("%d",&i);
int count=0;
for(n=1;n<=i;n++)
{
if(i%n==0)
{
count=count+1;
}
}
if(count==2)
{
printf("Number is prime");

}
else

{
printf("Number is not prime");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy