Professional Documents
Culture Documents
TECNOLOGY
TOPIC
C PROGRAMMING
NAME OF STUDENT :- RAHUL NATH
STUDENT ID :-2231462011
DEPARTMENT :- CYS DEPARTMENT 1st year
SEMESTER :- 1ST
Armstrong number Program
#include<stdio.h>
int main()
{
int n,r,sum=0,temp;
printf("enter the number::-- ");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong number ");
else
printf("not armstrong number");
return 0;
}
OUTPUT :-
FIBONACCI SERIESE
#include <stdio.h>
int main()
{ int n1= 1, n2 =2,num,n3,i;
printf("enter the series number");
scanf("%d",&num);
printf("%d %d",n1,n2);
for (i=0;num>=i;i++)
{n3 = n1+n2;
n1= n2;
n2 = n3;
printf(" %d ",n3);
return 0;
}
OUTPUT :-
PRIME NUMBER
#include <stdio.h>
int main() {
int n, i, flag = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
if (n == 0 || n == 1)
flag = 1;
return 0;
}
OUTPUT :-
SUM OF THREE
#include <stdio.h>
int main()
{
int var1,var2,var3,sum;
printf("enter three numbers");
scanf("%d %d %d",&var1,&var2,&var3);
sum =var1+var2+var3;
printf("Sum of three numbers is :-- %d ",sum);
return 0;
}
OUTPUT :-
#include <stdio.h>
int main()
{
int a,b;
printf("enter two number for swap");
scanf("%d %d",&a,&b);
a = a+b;
b = a-b;
a = a-b;
printf("numbers after swapping:-- %d %d",a,b);
return 0;
}
OUTPUT :-
return 0;
}
OUTPUT:-
PALINDROME NUMBER
#include<stdio.h>
int main()
{
int n,r,sum=0,temp;
printf("enter the number:-");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
printf("palindrome number ");
else
printf("not palindrome");
return 0;}
OUTPUT :-
COUNTING OF DIGITS
#include <stdio.h>
int main() {
long n;
int count = 0;
printf("Enter an integer: ");
scanf("%lld", &n);
do {
n /= 10;
++count;
} while (n != 0);
printf("Number of digits: %d", count);
}
OUTPUT :-
REVERSE NUMBER
#include <stdio.h>
int main() {
int n, reverse = 0, remainder;
while (n != 0)
{
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}
printf("Reversed number = %d", reverse);
return 0;
}
FACTORIAL
#include<stdio.h>
int main()
{
int i,fact=1,number;
for(i=1;i<=number;i++){
fact=fact*i;
}
OUTPUT :-
AREA OF CIRCLE
#include <stdio.h>
int main(void) {
OUTPUT:-
int main()
{
}
if (n3 >= n1 && n3 >= n2)
{
printf("%d is the largest number.", n3);
}
return 0;
}
OUTPUT :-
TRINGLE TYPES
#include <stdio.h>
int main()
{
int s1,s2,s3,aot;
printf("enter the sides of Tringle");
scanf("%d%d%d",&s1,&s2,&s3);
if(s1==s2&&s2==s3)
printf("this is an equilateral triangle");
else if(s1==s2&&s2!=s3)
printf("this is an isoceles triangle");
else if(s1!=s2&&s2!=s3)
printf("this is an scalene triangle");
return 0;
}
OUTPUT :-