Printing Strong Numbers in the given Range | C Language Tutorial | Mr. Srinivas naresh i technology c language

by Krabihometownbt1
banner



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 us.training@nareshit.com/online@nareshit.com 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

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

You may also like

39 comments

Naresh i Technologies 13/09/2021 - 8:59 Chiều

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

Reply
Udit Sahoo 13/09/2021 - 8:59 Chiều

You prove we shouldn't judge a book by it's cover.

Reply
SAIKUMAR KISSTALA 13/09/2021 - 8:59 Chiều

I think
for(n=1;n<=limit;n++)
Is correct
#Naresh I technologies

Reply
interesting world 13/09/2021 - 8:59 Chiều

sir starting for loop in not i<=limit but n<=limt ayegana sir please rply

Reply
Venkatesh Jajula 13/09/2021 - 8:59 Chiều

#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);
}
}

Reply
parthik sonagara 13/09/2021 - 8:59 Chiều

/*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;
}

Reply
Vishal V 13/09/2021 - 8:59 Chiều

Sir here u didn't store n value to temp

Reply
Praveentechintelugu 13/09/2021 - 8:59 Chiều

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;

}

}

Reply
ENG20CS0074 _chetan.r 13/09/2021 - 8:59 Chiều

Where is that video what is a strong number plzzzzzzzzz anyone replyyyyyyyyyyy😭😭😭

Reply
suhas g 13/09/2021 - 8:59 Chiều

sir why did we use count++?

Reply
IRFAN Irfu 13/09/2021 - 8:59 Chiều

#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

Reply
DEEKSHANT GOYAL 13/09/2021 - 8:59 Chiều

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");
}

Reply
Smita Mohite 13/09/2021 - 8:59 Chiều

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.

Reply
Dhruv Jain 13/09/2021 - 8:59 Chiều

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);

}

}

}

Reply
Vaibhav Garg 13/09/2021 - 8:59 Chiều

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

Reply
AKHILA KS 13/09/2021 - 8:59 Chiều

Sir forgot to say to insert temp value for n

Reply
sai dikshith 13/09/2021 - 8:59 Chiều

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..

Reply
SCORPUS GAMING 13/09/2021 - 8:59 Chiều

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

Reply
likhitha shetty 13/09/2021 - 8:59 Chiều

Sir u told to replace the read with printf and scanf what we should write in printf and scanf

Reply
A kan 13/09/2021 - 8:59 Chiều

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 …

Reply
ARJUN V 13/09/2021 - 8:59 Chiều

Sir the value of n is changing ,so temp variable is required?

Reply
T Deepak reddy 13/09/2021 - 8:59 Chiều

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

Reply
VENKATESWARA REDDY 13/09/2021 - 8:59 Chiều

when n becomes 0 in while loop then later if condition has n==sum here error ,,temp variable is need to be use there

Reply
pranay varma 13/09/2021 - 8:59 Chiều

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

Reply
Amit Jaiswal 13/09/2021 - 8:59 Chiều

You have to store n value in another variable before loop

Reply
all is well 13/09/2021 - 8:59 Chiều

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);
}

Reply
Mohammed Zidan 13/09/2021 - 8:59 Chiều

Thank You

Reply
Pavan Kalyan Vakiti 13/09/2021 - 8:59 Chiều

Sir
While loop will execute until the statement goes wrong. n>0 is always correct how will loop terminate

Reply
Samrat Chatterjee 13/09/2021 - 8:59 Chiều

sir help me code is not working after compile

Reply
Samrat Chatterjee 13/09/2021 - 8:59 Chiều

first for loop i did not understand repeat the explanation

Reply
Samrat Chatterjee 13/09/2021 - 8:59 Chiều

sir in first for loop you passed i in condition checking i or n it wiil be

Reply
KEVZ TECH 13/09/2021 - 8:59 Chiều

Not working

Reply
Sanchit Gupta 13/09/2021 - 8:59 Chiều

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.

Reply
BossySmaxx Hex 13/09/2021 - 8:59 Chiều

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.

Reply
BossySmaxx Hex 13/09/2021 - 8:59 Chiều

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.

Reply
Slobodan Tajisic 13/09/2021 - 8:59 Chiều

# 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);
}

Reply
VenkY V7 Plus 13/09/2021 - 8:59 Chiều

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.

Reply
Subhadeep Sarkar 13/09/2021 - 8:59 Chiều

#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);
}

}
}

Reply
Anubhav Roy 13/09/2021 - 8:59 Chiều

Great illustration

Reply

Leave a Comment