Printing Strong Numbers in the given Range
C Language Tutorial Videos | Mr. Srinivas
** For Online Training Registration: ? Call: +91-8179191999
? Visit Our Website for Classroom Training:
? For Online Training:
————————–
? About NareshIT:
“Naresh IT is having 14+ years of experience in software training industry and the best Software Training Institute for online training, classroom training, weekend training, corporate training of Hadoop, Salesforce, AWS, DevOps, Spark, Data Science, Python, Tableau, RPA ,Java, C#.NET, ASP.NET, Oracle, Testing Tools, Silver light, Linq, SQL Server, Selenium, Android, iPhone, C Language, C++, PHP and Digital Marketing in USA,Hyderabad, Chennai and Vijayawada,Bangalore India which provides online training across all the locations
————————–
? Our Online Training Features:
1.Training with Real-Time Experts
2.Industry Specific Scenario’s
3.Flexible Timings
4.Soft Copy of Material
5. Share Videos of each and every session.
————————–
Please write back to us at [email protected]/[email protected] or Call us at USA:
+1404-232-9879 or India: +918179191999
** Check The Below Links**
? For Course Reg:
? Subscribe to Our Channel:
? Circle us on G+:
? Like us on Facebook:
? Follow us on Twitter:
? Follow us on Linkedin:
? Follow us on Instagram: .
Images related to the topic naresh i technology c language

Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas
Search related to the topic Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas
#Printing #Strong #Numbers #Range #Language #Tutorial #Srinivas
Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas
naresh i technology c language
See all the latest ways to make money online: See more here
See all the latest ways to make money online: See more here
Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: https://goo.gl/HIB0wL
You prove we shouldn't judge a book by it's cover.
I think
for(n=1;n<=limit;n++)
Is correct
#Naresh I technologies
sir starting for loop in not i<=limit but n<=limt ayegana sir please rply
#include <stdio.h>
void main()
{
int n,i,j,rem,temp;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
temp=i;
int sum=0;
while(temp>0)
{
int fact=1;
rem=temp%10;
for(j=rem;j>0;j–)
{
fact*=j;
}
sum+=fact;
temp=temp/10;
}
if(i==sum)
printf("%dn",i);
}
}
/*strong number in given range*/
#include <stdio.h>
int main()
{
long int limit,r,n,temp,fact,i,sum=0;
printf("enter the value of the limit=");
scanf("%ld",&limit);
for(n=1;n<=limit;n++)
{
sum=0;
temp=n;
while(n>0)
{
r=n%10;
fact=1;
for(i=r; i>=1;i–)
{
fact=fact*i;
}
sum=fact+sum;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("strong numbers in given range are =%ld n",n);
}
}
return 0;
}
Sir here u didn't store n value to temp
there is a mistake in the code.
it should be like this
//printing strong number in the given range….strong number:(sum of the idividual factorial of individual digits is called strong number)
#include<stdio.h>
void main()
{
int sum=0,fact=1,r=0,temp,limit;
printf("enter lmit:");
scanf("%d",&limit);
for(int n=1;n<=limit;n++)
{ temp=n;
while(n>0)
{
r=n%10;
if(r!=0)
{
while(r!=0)
{
fact=fact*r;
r–;
}
sum=sum+fact;
}
fact=1;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("%d ",sum);
}
sum=0;
}
}
Where is that video what is a strong number plzzzzzzzzz anyone replyyyyyyyyyyy😭😭😭
sir why did we use count++?
#include<stdio.h>
int main()
{
int fact,i,n,sum,r,temp,start,end;
printf("enter rangen");
scanf("%d %d",&start,&end);
for(n=start;n<=end;n++)
{ sum=0;
temp=n;
while(n>0)
{ fact=1;
r=n%10;
for(i=r;i>=1;i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=temp;
if(n==sum)
printf("%d ",n);
}
}
// strong numbers in the given range
Here is the complete code:
#include<stdio.h>
main()
{
int n,r,sum=0,i,t, temp;
printf("enter the value of n");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
t=r;
n=n/10;
for(i=1;i<t;i++)
{
r=r*i;
}
sum=sum+r;
}
if(sum==temp)
printf("it is a strong number");
else
printf("it is not");
}
solution:-
#include<stdio.h>
void main()
{
int limit,n,i,r,sum,fact,tmp;
printf("enter the limits=");
scanf("%d",&limit);
for(n=1;n<=limit;n++)
{
sum = 0;
tmp = n;
while(n>0)
{
r=n%10;
fact=1;
for(i=r;i>=1;i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=tmp;
if(n==sum)
{
printf("%d is strong numbern",n);
}else
{
printf("%d is not the strong numbern",n);
}
}
}
if we put the limit=145 then it will give strong number between 1 to 145.
here is the correct program
//program to check whether a number is a strong number or not in a given limit
#include <stdio.h>
main()
{
int n, r, i, sum, fact, k, limit;
printf("Enter a value: ");
scanf("%d", &limit);
for(n=1; n<=limit; n++)
{
sum = 0;
k=n;
while(k>0)
{
r=k%10;
k=k/10;
fact = 1;
for(i=1; i<=r; i++)
{
fact = fact*i;
}
sum = sum + fact;
}
if(sum == n)
{
printf("%d is a strong numbern", n);
}
else
{
printf("%d is not a strong numbern", n);
}
}
}
You didn't stored n value in temp.. So whenever you check in last while printing the number.. No number will be perfect number.. As n's value would be 0
Sir forgot to say to insert temp value for n
Hey guys i have a pic where you all can find sequence and order of the
c-programming videos by Naresh sir …how many of you guys need it..
int main()
{
int r,n,fact,sum=0,temp;
printf("enter the valuen");
scanf("%d",&n);
temp=n;
While(n>0)
{
r=n%10;
fact=1;
for(int i=r ; i>=1 ; i–)
{
fact=fact*i ;
}
sum=sum+fact ;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("it's a strong numbern",n);
}
else
printf ("nikal lavde");
}
Thinks should go positive from here
Sir u told to replace the read with printf and scanf what we should write in printf and scanf
The one who is reading my comment can run this program and tell me what's wrong with this program ?
why does it give me wrong output ?
#include<stdio.h>
int main()
{
//declaring variables
int re; //remainder
int copy;
int i; //counter
int num;
int fact; //factorial
fact=1;
int sum; //sum
sum=0;
//taking input
printf("enter your number:n");
scanf("%d",&num);
copy=num; //storing the value of num to copy variable
while(copy!=0)
{
re=copy%10;
for(i=1;i<=re;i++);
{
fact=fact*i;
}
sum=sum+fact;
fact=1;
copy=copy/10;
}
if(sum==num)
printf("%d is the strong numbern",num );
else
printf("%d is not strong numbern",num);
return 0;
}
plz help me …
Sir the value of n is changing ,so temp variable is required?
i refered many codes not only this but different logics,i never felt i got it ,complete concept
but you made it clear sir, thank you so much keep going
when n becomes 0 in while loop then later if condition has n==sum here error ,,temp variable is need to be use there
HERE IS THE CODE FOR STRONG NUMBERS:
#include<stdio.h>
main()
{
int i,n,r,fact,sum=0,temp,limit;
printf("enter the limit ");
scanf("%d",&limit);
for(n=1;n<=limit;n++)
{
temp=n;
sum=0;
while(n>0)
{
fact=1;
r=n%10;
for(i=1;i<=r;i++)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=temp;
if(sum==n)
{
printf("%d strong number n",n);
} else
{
printf("%d not a strong numbern",n);
}
}
}//your welcome
You have to store n value in another variable before loop
there is a mistake in the program
n need to be replaced
check this solution:
for(j=1;j<=limit;j++)
{
n=j;
…..
……..
}
if(j==sum)
{
printf("%d strong",j);
}
Thank You
Sir
While loop will execute until the statement goes wrong. n>0 is always correct how will loop terminate
sir help me code is not working after compile
first for loop i did not understand repeat the explanation
sir in first for loop you passed i in condition checking i or n it wiil be
Not working
FOR ALL THOSE WHO ARE FACING PROBLEM IN THIS CODE
THIS IS THE CORRECT CODE FOR THIS PROGRAM:
#include <stdio.h>
#include <conio.h>
int main()
{
long int n, limit, r, i, temp, fact, sum=0;
printf("Enter the limit:");
scanf("%ld", &limit);
for(n=1; n<=limit; n++)
{
temp=n;
sum=0;
while(n>0)
{
r=n%10;
fact=1;
for(i=r; i>=1; i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=temp;
if(n==sum)
{
printf("%ld is a strong numbern", n);
}
}
getch();
}
FIRST COPY – PASTE THE ABOVE CODE AND TRY IN YOUR IDE
SURELY IT WOULD WORK.
here's the solution(with correction):-
#include<stdio.h>
#include<conio.h>
void main()
{
long int i,j,range,index,sum=0,fact=1,temp;
clrscr();
printf("Enter any number here:");
scanf("%ld",&range);
for(i=1;i<=range;i++)
{
temp=i;
sum=0;
while(temp!=0)
{
fact=1;
index=temp%10;
for(j=1;j<=index;j++)
{
fact=fact*j;
}
temp=temp/10;
sum=sum+fact;
}
if(sum==i)
{
printf("%ldn",i);
}
}
getch();
}
I've tried it so many times and it giving me the perfect and correct result. So you've to try it too.
I've just stored the i's value in temp var where i stores its value in temp and used temp to prevent loop infinite occurrence. and temp gets reset everytime when loop starts from beginning. That's all. The snippet is in the next comment.
# include <stdio.h>
# include <stdlib.h>
int fact(int n) {
int k, f = 1;
for (k = 1; k <= n; k++) {
f = f * k;
}
return f;
}
int main(int argc, char** argv) {
long low, up, i, temp, sum, numbers[100];
int strong, factoriel, rem;
printf("Enter lower limit!n");
scanf("%ld", &low);
printf("Enter upper limit!n");
scanf("%ld", &up);
for (i = low; i <= up; i++) {
sum = 0;
temp = i;
while (temp > 0) {
rem = temp % 10;
factoriel = fact(rem);
sum = sum + factoriel;
temp = temp / 10;
}
if(sum == i){
numbers[strong] = i;
strong++;
}
}
if(strong == 0)
printf("nNo strong numbers between %ld and %ldn", low, up);
else{
printf("nStrong numbers between %ld and %ld are :nn", low, up);
for(i = 0; i < strong; i++)
printf("numbers[%ld] je %ldn", i, numbers[i]);
}
return (EXIT_SUCCESS);
}
It is not working.since, there is no temporary value,sir please tell us how to store temporary value for like those numbers that are in a given range.
#include<stdio.h>
void main()
{
int limit,n,r,fact,i,temp,sum=0;
printf("Enter limit");
scanf("%d",&limit);
for(n=1;n<=limit;n++)
{temp=n;
sum=0;
while(n>0)
{
r=n%10;
fact=1;
for(i=r;i>=1;i–)
{
fact=fact*i;
}
sum=sum+fact;
n=n/10;
}
n=temp;
if(sum==n)
{
printf(" %d is strong no n",n);
}
}
}
Great illustration
sir explain more
There is need of temp variable as if(sum==temp) instead of n..
program is not working can any body modify the code
I think we need to assign 'n' value to some 'temp' variable before while loop, and we have to check with sum .
its not working we use one temparary variable because n==sum , also its not working
can any one help me
not working
Nice strong explanation sir for strong num program thank u so much sir
The correct program is as bellow:
int main()
{
int n, i, count=0;
printf("Enter any integer to check whether it is prime number or not:n");
scanf("%d",&n);
for(i=2; i<=n/2; i++)
{
if(n%i==0)
{
count=1;
}
}
if(count==0)
printf("%d is a prime number",n);
else
printf("%d is not a prime number",n);
return 0;
}
'n' value is lost while checking if it is equal to 'sum'. So, assigning the original number to another variable and checking this variable against 'sum' is needed.