1. Write a Program to take number from user and print summation of first and last Digit c program
2. Write a Program to find fibonacci series up to n number using for loop c program
3. Write a program to take number from user check it's number is prime or not prime c program
1.
Write a Program to take number from user and print summation of first and last Digit c program
/* Write a Program to take number from user and print summation of first and last Digit */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,p,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
p = num%10;
while(num>0)
{
t = num%10;
num = num/10;
}
sum = p +t;
printf("Sum of first and last digit = %d",sum);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,p,t,sum=0;
clrscr();
printf("Enter number : ");
scanf("%d",&num);
p = num%10;
while(num>0)
{
t = num%10;
num = num/10;
}
sum = p +t;
printf("Sum of first and last digit = %d",sum);
getch();
}
Download Program source code
2.
Write a Program to find fibonacci series up to n number using for loop c program - Program Code
/* Write a Program to find fibonacci series up to n number using for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,t1=0,t2=1,fibo;
clrscr();
printf("Enter the number of terms : ");
scanf("%d",&n);
printf("Fibonacci series : ");
for(i=0;i<=n;i++)
{
printf("%d,",t1);
fibo = t1 + t2;
t1 = t2;
t2 = fibo;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,t1=0,t2=1,fibo;
clrscr();
printf("Enter the number of terms : ");
scanf("%d",&n);
printf("Fibonacci series : ");
for(i=0;i<=n;i++)
{
printf("%d,",t1);
fibo = t1 + t2;
t1 = t2;
t2 = fibo;
}
getch();
}
Download Program source code
3.
Write a program to take number from user check it's number is prime or not prime
/* Write a program to take number from user check it's number is prime or not prime */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,f=0;
clrscr();
printf("Enter Number : ");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
f=1;
break;
}
}
if(f==0)
{
printf("%d is prime",n);
}
else
{
printf("%d is not prime",n);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,f=0;
clrscr();
printf("Enter Number : ");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
f=1;
break;
}
}
if(f==0)
{
printf("%d is prime",n);
}
else
{
printf("%d is not prime",n);
}
getch();
}
Download Program source code
0 Comments
If You have any query, Please let me know..