//Enter one number and check it is armstrong no or not #include #include void main() { int no,i,r=0,d; clrscr(); printf("\n Enter The No :- "); scanf("%d",&no); while(no>0) { d=no%10; no=no/10; r=r+(d*d*d); } if(r==0) { printf("\n No is Armstrong"); } else { printf("\n No Is Not Armstrong"); } getch(); }
/*except one no from user and display its factorial*/
#include #include
void main() { int no,i,fact=1; clrscr(); printf("\n Enter The No :- "); scanf("%d",&no); for(i=no;i>=1;i--) { fact=fact*i; } printf("\n factorial of this number is :- %d",fact); getch(); }
*/ except one no from user and display sum of each digit */
#include #include
void main() { int no,d,sum=0; clrscr(); printf("\n Enter The No :- "); scanf("%d",&no); while(no>0) { d=no%10; no=no/10; sum=sum+d; } printf("\n The Sum Digit :- %d",sum); getch(); }
/* except one no from user and display reverse of it.*/
#include #include
void main() { long int no,d,rev=0; clrscr(); printf("\n Enter The No :- "); scanf("%ld",&no); while(no>0) { d=no%10; no=no/10; rev=d+(rev*10); } printf("\n Reverse No Is :- %ld",rev); getch(); }
/*write a program to calculate the area of circle ,rectangle,square and triangle in one program with using switch case /*
#include #include void main() { int a=0,b,pi=3.14,r,h,n; clrscr(); printf("enter r:"); scanf("%d",&r); printf("enter b:"); scanf("%d",&b); printf("enter h:"); scanf("%d",&h); printf("\nenter 1 for circle\nenter 2 for square\nenter 3 for rectangle\nenter 4 for triangle\n"); printf("enter choice:"); scanf("%d",&n);
switch (n) { case 1: a=pi*r*r; printf("area of circle is %d",a); break; case 2: a=4*b; printf("area of square is %d",a); break; case 3: a=2*b*h; printf("area of rectangle is %d",a); break; case 4: a=(b/2)*h; printf("area of triangle is %d",a); break; default: printf("bug"); break; } getch(); }
/* input 2 number and print the maximum among them.(with conditional operator) */
#include #include void main() { int x,y,max; clrscr(); printf("enter number of value1"); scanf("%d",&x); printf("enter number of value2"); scanf("%d",&y); max = (x>y?x:y); printf("maximum is %d",max); getch(); }
{ float t,b,h; clrscr(); printf("enter value for b:"); scanf("%f",&b); printf("enter value for h:"); scanf("%f",&h); t=(float)0.5*b*h; printf("%f",t); getch(); }
{ int v,s,l,m,t; clrscr(); printf("t=((v+s)+(l-m)*l)"); printf("\nenter value of s:"); scanf("%d",&s); printf("enter value of v:"); scanf("%d",&v); printf("enter value of l:"); scanf("%d",&l); printf("enter value of m:"); scanf("%d",&m); t=(((v+s)+(l-m)*l)); printf("ans:%d",t); getch(); }