Skip to main content

Posts

program to make a menu driven and reusable calculator

LIST OF PROGRAMS #include<stdio.h> #include<conio.h> #include<math.h> void main() { long int i=1,a,b,c=0,choice=1; clrscr(); do { switch(i) { case 1: { printf("enter numbers\n"); scanf("%ld%ld",&a,&b); printf("enter 1 for add\n"); printf("enter 2 for subtract\n"); printf("enter 3 for multiply\n"); printf("enter 4 for divide\n"); printf("enter 5 for modulus\n"); printf("enter choice\n"); scanf("%d",&choice); switch(choice) { case 1:c=a+b; break; case 2:c=a-b; break; case 3:c=a*b; break; case 4:c=a/b; break; case 5:c=a%b; break; default:printf("wrong input\n"); break; } if(choice>0&&choice<6) printf("%ld",c); break; } } printf(" enter 1 for re using calculator\n"); printf(" enter other number for exit\n"); scanf("%ld",&i); }while(i==1);  printf("t...

PROGRAM TO FIND OCTAL OF A NUMBER

LIST OF PROGRAMS #include<stdio.h> #include<conio.h> void main() { long int n,oct=0,r=1,pow=1;  clrscr(); printf("Enter a number "); scanf("%ld",&n); if(n<0) printf("WRONG INPUT"); else {  if(n<=7&&n>=0)  oct =n;  else  {  while(n>0)  { r=n%8; oct=oct+(r*pow); n=n/8; pow=pow*10;  }  }  printf("OCTAL = %ld",oct);  getch(); } } LIST OF PROGRAMS

program to find sum of first and last digit of a number

LIST OF PROGRAMS #include<stdio.h> #include<conio.h> void main() { long int n,sum=0,last;  clrscr(); printf("Enter a number "); scanf("%ld",&n); if(n<=9&&n>=0) printf("sum = %ld",n); else if(n<0) printf("WRONG INPUT"); else { last=n%10; /*for finding last digit of the number */ while(n>9) { n=n/10; } sum=n+last; printf("SUM =%ld",sum); getch(); } } LIST OF PROGRAMS

program to find total no. of currency notes(100,50,10) of the enterd value

LIST OF PROGRAMS eg: Enter a amount = 560 No. of Rs.100 notes  = 5 No. of Rs.50 notes  = 1 No. of Rs.10 notes  = 1 #include<stdio.h> #include<conio.h> void main() { long int n,x=0;  clrscr(); printf("Enter a amount = \n"); scanf("%ld",&n); x=n/100; printf("No. of Rs.100 notes  = %ld\n",x); n=n%100; x=n/50; printf("No. of Rs.50 notes  = %ld\n",x); n=n%50; x=n/10; printf("No. of Rs.10 notes  = %ld\n",x); getch(); } LIST OF PROGRAMS

program to print a new number by adding one to each of its digits

#include<stdio.h> #include<conio.h> void main() { long int n,i2=1,i=0,sum2=0,num,x,sum=0;  clrscr(); printf("Enter a number="); scanf("%ld",&n); x=n; while(n>0) { sum++; n=n/10; } printf("Number of digits in this number=%ld",sum); while(i<sum) { sum2=x+i2; i2=i2*10+1; i++; } printf("Number formed %ld",sum2); getch(); } LIST OF PROGRAMS