Posts

compute value of one number raised to another in c

Image
 compute value of one number raised to another in c  #include<stdio.h> int main() { float x,power; int y, i ; printf("\n Enter two number :"); scanf("%f%f",&x<&y); power =i=1; while(i<=y) { power=power*x; i++; } printf("%f to the power %d is %f\n",x,y,power); retrun 0; }  or  //compute value of one number raised to another in c  #include<stdio.h> int main() { float x,power; int y, i ; printf("\n Enter two number :"); scanf("%f%f",&x,&y); power =i=1; while(i<=y) { power=power*x; i++; } printf("%f to the power %d is %f\n",x,y,power); return 0; }       related program 1 . whether a character entered through the keyboard is a special symbol or not 2 . calculate of simple interest for 3 sets of p,n and r.. 3 . Demonstrates the use of new and delete operators for dynamic allocation and de-allocation of memory of C++.  4. calculation of factorial value of a number in c.  

calculation of factorial value of a number in c.

Image
 calculation  of factorial value of a number in c..  #include<stdio.h> int main() { int num , i,fact; printf("Enter the the number"); scanf("%d",&num); fact=i=1; while(i<=num) { fact=fact*i; i++; } printf("Factorial value of %d=%d\n",num,fact); return 0; } or   #include<stdio.h> int main() { int num , i,fact; printf("Enter the the number:"); scanf("%d",&num); fact=i=1; while(i<=num) { fact=fact*i; i++; } printf("Factorial value of %d = %d\n",num,fact); return 0; } output--     related program- 1- Determine overtime pay of 10 employees in c program 2 .   Demonstrates the use of new and delete operators for dynamic allocation and de allocation of memory of C++.  3 . calculate of simple interest for 3 sets of p,n and r.. 4 . whether a character intered through the keyboard is a special symbol or not .

illustrate the use of end1 and setw (Use of manipulator) of C++.

Image
 illustrate the use of end1 and setw (Use of manipulator) #include<iostream > #include<iomanip>   //for setw using namespace std; int main() { int Basic=950,Allowance=95,Total=1045; cout<<setw(10)<<"Basic="<<setw(10)<<Basic        <<setw(10)<<"\nAllowance"<<setw(10)<<Allowance       <<setw(10)<<"\nTotal"<<setw(10)<<Total; return 0; }

illustrate the use of new aand delete operations fordynamic allocation for class object the program uses bad_alloc exception instead of null pointer for handling allocation failure of C++

Image
 illustrate the use of new and delete operations for dynamic allocation for class object the program uses bad_alloc  exception instead of null pointer for handling allocation failure #include<iostream> using namespace std; class sample { private: int data1; char data2; public: void set (int i,char c) { data1=i; data2=c; } void display(void) { cout<<"Data1="<<data1;   cout<<"\nData2="<<data2; } }; int main(){ sample *s_ptr; try { s_ptr =new sample; } catch(bad_alloc ba)  { cout<<"Bad Allocation occurred.... the program will be terminate now..."; return 1; } s_ptr-> set(25,'A'); s_ptr-> display(); delete s_ptr; return 1; } output--

Determine overtime pay of 10 employees in c program

Image
  determine overtime pay of 10 employees #include<stdio.h> int main()  { float otpay; int hour,i=1; while (i<=10)  //loop for 10 employees { printf("\n Enter no. of hours worked:"); scanf("%d",&hour); if(hour>=40) otpay=(hour-40)*12; else otpay =0; printf("Hours=%d overtime pay =Rs.%f\n",hour,otpay); i++; } return 0; }  

Demonstrates the use of new and delete operators for dynamic allocation and deallocation of memory of C++.

Image
 Demonstrates the use of new and delete operators for dynamic allocation and deallocation of memory of C++.   use of new and delete operators   #include<iostream> using namespace std; int main(){ int *arr; int size; cout<<"Enter the size of  integer array :"; cin>>size; cout<<"Creating an array of size "<<size"<< . ."; arr=new int[size]; cout<<"\n Dynamic allocation of memory for array is successful."; delete  arr; return 0; } output -- Enter the size of  integer array: 9   Creating an array of size: 9.. Dynamic allocation of memory for array is successful  

calculate of simple interest for 3 sets of p,n and r..

Image
 calculate  of simple interest for 3 sets of p,n and r.   #include<stdio.h> #include<conio.h> void main() { int p,n,count=1; float r,si; clrscr(); while(count<=3) { printf(“Enter value for p,n & r\n\n”); scanf(“%d%d%f”,&p,&n,&r); si=(p*n*r)/100; printf(“\nSimple Interest =%f”,si); count++; } getch(); } or   #include<stdio.h> int main() { int p,n,count=1; float r,si; while(count<=3) { printf("\nEnter value p:"); scanf("%d",&p); printf("Enter value n:"); scanf("%d",&n); printf("Enter value r:"); scanf("%f",&r); si=(p*n*r)/100; printf("\nSimple Interest = %f",si); } count++; return 0; } output--