/*to make number pyramid*/ #include<stdio.h> #include<math.h> main() { int num,t=0,s=1,j=0; int choice,num1,dig,sum=0; int n,i,pro; printf("1. FOR MAKE PYRAMID\n"); printf("2. FOR FIND DIGITS SUM\n"); printf("3. FOR MAKE MATHEMATICAL TABLE OF GIVEN NUMBER\n4. EXIT\n\n"); do{ printf("\nENTER YOUR CHOICE\n\n"); scanf("%d",&choice); switch(choice) { case 1 : printf("enter the terms of pyramid\n"); scanf("%d",&num); for(t=0;t<=num;t++) { for(j=0;j<=num-t;j++) { printf(" "); } for(s=1;s<=t;s++) { printf(" %d",s); } printf(" \n"); } printf(" "); break; case 2 : printf("enter the number\n"); scanf("%d",&num1); while(num1!=0) { dig=num1%10; sum=sum+dig; num1=num1/10; } printf("sum of indivisual digits=%d\n",sum); break; case 3 : printf("enter the number to make mathematical table\n"); scanf("%d",&n); printf("table of number is \n\n"); for(i=1;i<=10;i++) { pro=n*i; printf("%d\n",pro); } break; case 4 : break; default : printf("invalid option\ntry again\n"); break; } }while(choice!=4); }
New Android apps UniqueKey
Saturday, 7 March 2015
Program to create number pyramid.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment