Posts

Inheritance

Image
 Inheritance is a process in which one object acquires all the properties and behaviors of its parent object automatically. In such a way, you can reuse , extend or modify the attributes and behaviors which are defined in other classes. In C++, the class which inherits the members of another class is called derived class and the class whose members are inherited is called base class. The derived class is the specialized class for the base class. Types of inheritance:-                               1) Single inheritance:-                                                                 When one class inherits another class, it is known as single                              ...

Basic of OOPs(Object Oriented Programmings)

Image
 Definition:-                    OOP (Object Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts. CLASS:- It is defined data type which defines its properties and its functions. It is the only logical representation of data. It is blue print of objects. For example:- Human beings is a class. The body part are its properties, and the actions performs by human is its function. Class does not occupy any space till an object is instantiated. Class is define by using keyword class followed by the name of class. Here, we defined a class named Room. The Variables length , breadth and height are declared inside the class are known as data members . The functions calculateArea() and calculateVolume() are known as member functions of a class. OBJECT:- It is run-time entity. It is an instance of the class. An obj...

Best program to calculate compound interest

      C ODE:- #include <stdio.h> int main() {     int p,t;     float i,r,a;     printf("Enter the principle amount.");     scanf("%d",&p);     printf("Enter the rate: ");     scanf("%f",&r);     printf("Enter the total time taken: ");     scanf("%d",&t);     for(int j=1;j<=t;j++)     {         i=p*r/100;         a=i+p;         p=a;         printf("Amount after %d years= %f\n",j,a);     }     printf("*******Total amount to paid= %f*******",a);     return 0; }

C Program to identify the number is prime or not.

 CODE:- #include<stdio.h> #include<conio.h> void main() { int num,i,rem; int flag=0; printf("Enter the number="); scanf("%d",&num); for(i=2;i<num;i++) {     rem=num%i;     if(rem==0)     {         flag=1;         break;     }     else     continue;      } if(flag==1) printf("%d is not prime number.",num); else printf("%d is prime number.",num); }

TO calculate reverse of number by using c programming

  CODE: - #include <stdio.h> int main() {     int total=0;     int d,rem;     printf("Enter the  number= ");     scanf("%d",&d);     do     {         rem=d%10;         d=d/10;         total=total*10+rem;     }     while(rem>0);     total=total/10;     printf("reverse of number = %d",total);     return 0; }

Program to calculate sum of digit of number

 CODE:- #include <stdio.h> int main() {     int total=0;     int rem, d;     printf("Enter the number= ");     scanf("%d",&d);     do     {         rem=d%10;         d=d/10;         total=total+rem;     }     while(rem>0);     printf("Sum of digit number = %d",total);     return 0; }

C program to cut paper parallel to short length.

CODE:- #include <stdio.h> int main() {     int l=1189;     int b=841;     printf("The dimension of A0 paper= %d mm x %d mm\n",l,b);     for(int i=1;i<=8;i++)     {         if(l>b)         {             l=l/2;             b=b;             printf("The dimension of A%d paper= %d mm x %d mm\n",i,l,b);         }         else         {             l=l;             b=b/2;             printf("The dimension of A%d paper= %d mm x %d mm\n",i,l,b);         }     }     return 0; }