You are on page 1of 8

TECHNO INDIA COLLEGE OF

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;

for (i = 2; i <= n / 2; ++i) {


if (n % i == 0) {
flag = 1;
break;
}
}
if (flag == 0)
printf("%d is a prime number.", n);
else
printf("%d is not a prime number.", n);

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

SWAP OF NUMBER WITHOUT VARIABLES

#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 :-

SWAP NUMBER USING (THIRD VARIABLBE)


#include <stdio.h>
int main()
{
int num1,num2,temp;
printf("enter two numbers");
scanf("%d%d",&num1,&num2);
temp = num1;
num1 = num2;
num2 = temp;
printf("the number after swapping :-- %d %d",num1,num2);

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;

printf("Enter an integer: ");


scanf("%d", &n);

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;

printf("Enter a number: ");


scanf("%d",&number);

for(i=1;i<=number;i++){
fact=fact*i;
}

printf("Factorial of %d is: %d",number,fact);


return 0;
}

OUTPUT :-

AREA OF CIRCLE
#include <stdio.h>
int main(void) {

float pie = 3.14;


int radius ;

printf("Enter the radius");


scanf("%d",&radius);

float area = (float)(pie* radius * radius);

printf("The area of the circle is %f", area);


return 0;
}

OUTPUT:-

LARGET NUMBER AMONG THREE


#include <stdio.h>

int main()
{

int n1, n2, n3;

printf("Enter three different numbers: ");


scanf("%d%d%d",&n1,&n2,&n3);

if (n1 >= n2 && n1 >= n3)


{
printf("%d is the largest number.", n1);
}

if (n2 >= n1 && n2 >= n3)


{
printf("%d is the largest number.", n2);

}
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 :-

You might also like