Posts

access the private and public in c++.

Image
 access the private and public in c++.   #include<iostream> using namespace std; class Employee {     private:     int  a,b,c; public:     int d,e,f;     void setData(int a1,int b1,int c1);     void getData(){     cout<<"The value of a is= "<<a<<"\n";     cout<<"The value of b is= "<<b<<"\n";     cout<<"The value of c is= "<<c<<"\n";     cout<<"The value of d is= "<<d<<"\n";     cout<<"The value of e is= "<<e<<"\n";             cout<<"The value of f is= "<<f<<"\n";             } };    void Employee::setData(int a1 ,int b1, int c1){     a=a1;     b=b1;     c=c1; }  ...

implement class and object(c++)

Image
implement class and object #include<iostream> using namespace std; class item {     int number;// private by default     float cost;//privale by defaault     public:     void getdata(int a ,float b);  //prototype declaration to be defined //............function defined in class.......... void putdata(void)  {      cout<<"number:"<< number<<"\n";      cout<<"cost:"<<cost <<"\n";  } }; //............member function definetion >>..............        void item::getdata(int a ,float b)//use membership label {     number =a;// private variable directly used     cost=b; } //..............main program..............     int main() {     item x;     cout<<"\n object x "<<"\n";     x.getdata(100,299.95); //...

Write a program to print out all armstrong numbers between 1 to 500 . If sum of cube of each digit of the number is equal to the number itself then the number is called Armstrong number for example 153 = (1*1*1)+(5*5*5)+(3*3*3).

Image
Write a program to print out all Armstrong numbers between 1 to 500 . If sum of cube of each digit of the number is equal to the number itself then the number is called Armstrong number for example  153=(1*1*1)+(5*5*5)+(3*3*3). #include<stdio.h> #include<conio.h> #include<math.h> int main() { int num,temp,rem=0,sum=0,i; float cube; temp =1; for(i=1;i<500;i++) { while(num!=0) { rem=num%10; cube=pow(rem,3);//or we can write (rem*rem*rem) sum =sum+cube; num=num/10;//here the value of  num =0 } if(sum==temp) priintf("%d\n",temp); //set default values to the variables rem=0; sum=0; cube=0; //increment temp and  num value according to i //for the first loop i=1 temp=i+1; num=i+1; } } OR #include<stdio.h> #include<conio.h> #include<math.h> int main() { int num,temp,rem=0,sum=0,i; float cube; temp =1; for(i=1;i<500;i++) { while(num!=0) { rem=num%10; cube=pow(rem,3); //or we can write (rem*rem*rem) sum =sum+cube; num=num/10;//here the valu...

write a program to the ASCII values and their eqivalent character using a while loop the ASCII values vary from 0to 255.

Image
  write a program to the ASCII values and their  equivalent character using a while loop the ASCII values vary from 0to 255. #include<stdio.h> #include<conio.h> int main() { int i; char ascii; for(i=0;i<=255;i++) { printf("%c=%d\n",i,i); } }  

Write a program using reference variables a argument to swap the value of a pair of a integers of C++.

Image
  Write a program using reference variables a argument to swap the value of a pair of a integers   #include<iostream> using namespace std; void swap(int&x,int&y) { int temp; temp =x; x=y; y=temp; } int main(){ int a,b; cout<<"Enter the value of a"; cin>>a; cout<<"Enter the value of b"; cin>>b; cout<<"\n"<<"Before swapping:"; cout<<" a="<<a<<"and b = "<<b; swap(a,b);  cout<<"\n"<<"After swapping:";  cout<<" a="<<a<<"and b = "<<b; } or  👇👇👇👇👇👇👇👇👇👇👇👇👇   #include<iostream> using namespace std; void swap(int&x,int&y) { int temp; temp =x; x=y; y=temp; } int main(){ int a,b; cout<<"Enter the value of a:"; cin>>a; cout<<"Enter the value of b:"; cin>>b; cout<<"\n"<<"Before swapping:"; co...

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 .