Showing posts with label Simple Programs. Show all posts
Showing posts with label Simple Programs. Show all posts
Wednesday, December 19, 2018
Tuesday, December 18, 2018
WAP to print Fibinacci Serien upto nth term
Easy Programming All
December 18, 2018
0
#include<stdio.h>
int main()
{
int n, i, first = -1, second = 1, third;
printf("Enter nth term to print Fibonacci Series\n");
scanf("%d",&n);
printf("Fibonacci Series is:\n");
for(i = 1; i <= n; i++)
{
third = first + second;
printf("%d ",third);
first = second;
second = third;
}
return 0;
}
INPUT :
Enter nth term to print Fibonacci Series
8
OUTPUT :
Fibonacci Series is:
0 1 1 2 3 5 8 13
int main()
{
int n, i, first = -1, second = 1, third;
printf("Enter nth term to print Fibonacci Series\n");
scanf("%d",&n);
printf("Fibonacci Series is:\n");
for(i = 1; i <= n; i++)
{
third = first + second;
printf("%d ",third);
first = second;
second = third;
}
return 0;
}
INPUT :
Enter nth term to print Fibonacci Series
8
OUTPUT :
Fibonacci Series is:
0 1 1 2 3 5 8 13
Monday, December 17, 2018
WAP in C to check Whether a given Number is Krishnamurthi or Not
HindiKisseKahaniyaan
December 17, 2018
0
#include<stdio.h>
int main()
{
int i, n, fact, sum = 0, copy, rem;
printf("Enter any positive integer number to check Krishnamurthi or Not\n");
scanf("%d",&n);
copy = n;
while(n > 0)
{
rem = n % 10;
fact = 1;
for(i = 1; i <= rem; i++)
fact = fact * i;
sum = sum + fact;
n = n / 10;
}
if(copy = = sum)
{
printf("%d given Number is Krishnamurthi",copy);
}
else
{
printf("%d Number is Not Krishnamurthi",copy);
}
return 0;
}
INPUT 1:
Enter any positive integer number to check Krishnamurthi or Not
145
OUTPUT 1:
145 Number is Krishnamurthi
INPUT 2:
Enter any positive integer number to check Krishnamurthi or Not
123
OUTPUT 2:
123 Number is Not Krishnamurthi
int main()
{
int i, n, fact, sum = 0, copy, rem;
printf("Enter any positive integer number to check Krishnamurthi or Not\n");
scanf("%d",&n);
copy = n;
while(n > 0)
{
rem = n % 10;
fact = 1;
for(i = 1; i <= rem; i++)
fact = fact * i;
sum = sum + fact;
n = n / 10;
}
if(copy = = sum)
{
printf("%d given Number is Krishnamurthi",copy);
}
else
{
printf("%d Number is Not Krishnamurthi",copy);
}
return 0;
}
INPUT 1:
Enter any positive integer number to check Krishnamurthi or Not
145
OUTPUT 1:
145 Number is Krishnamurthi
INPUT 2:
Enter any positive integer number to check Krishnamurthi or Not
123
OUTPUT 2:
123 Number is Not Krishnamurthi
WAP in C to check Whether a given Number is Armstrong or Not
HindiKisseKahaniyaan
December 17, 2018
0
#include<stdio.h>
#include<math.h>
int main()
{
int i, n, sum = 0, rem, copy, count = 0;
printf("Enter any integer number to check armstrong or not\n");
scanf("%d",&n);
copy = n;
while(n > 0)
{
count = count + 1;
n = n / 10;
}
n = copy;
while(n > 0)
{
rem = n % 10;
sum = sum + pow(rem, count);
n = n/10;
}
if(copy = = sum)
{
printf("The given %d number is Armstrong",copy);
}
else
{
printf("The given %d number is Not Armstrong",copy);
}
return 0;
}
INPUT 1:
Enter any integer number to check armstrong or not
153
OUTPUT 1:
The given 153 number is Armstrong
Enter any integer number to check armstrong or not
153
OUTPUT 1:
The given 153 number is Armstrong
INPUT 2:
Enter any integer number to check armstrong or not
1634
OUTPUT 2:
The given 1634 number is Armstrong
Enter any integer number to check armstrong or not
1634
OUTPUT 2:
The given 1634 number is Armstrong
INPUT 3:
Enter any integer number to check armstrong or not
126
OUTPUT 3:
The given 126 number is Not Armstrong
Enter any integer number to check armstrong or not
126
OUTPUT 3:
The given 126 number is Not Armstrong






