#include<stdio.h>
#include<conio.h>
void main()
{ int a[5],b[5],c[5],i; clrscr(); printf(“enter value for array a ”); for(i=0;i<5;i++) scanf(“%d”,&a[i]); printf(“enter value for array b ”); for(i=0;i<5;i++) scanf(“%d”,&b[i]); for(i=0;i<5;i++) c[i]=a[i]-b[i]; printf(“subtraction”); for(i=0;i<5;i++) printf(“ %d ”,c[i]); getch();
}
import java.util.Scanner;
public class ATS
{ public static void main(String[]args) { Scanner in = new Scanner(System.in); String M[][] = new String[5][10]; int i = 0, j = 0; for (i = 0; i < 5; i++) { System.out.println("Enter floor " + (i + 1)+ " guest details:"); for (j = 0; j < 10; j++) { System.out.print("Guest in room " +(j + 1) + ": "); M[i][j] = in.nextLine(); } } boolean found = false; System.out.print("\nEnter guest name to search: "); String guest = in.nextLine(); for (i = 0; i < 5; i++) { for (j = 0; j < 10; j++) { if (M[i][j].equals(guest)) { found = true; break; } } if (found) break; } if (found) System.out.println(guest + " is in room number "+ (j + 1) + " on floor number " + (i + 1)); else System.out.println(guest +" is not staying at this hotel"); }
}
•Reusability- The code written in C++ for one program canbe used in another program of C++.
•Bottom-Up Approach- C++ may define functions and program data first and then integrate them together for use.
•Object Oriented Programming- C++ Provides mechanism to combine both data and the function of that data into a single unit, called object.
•Portability- Same C++ code can be compiled in almost any type of computer and operating system without any changes.
•Brevity- Code written in C++ is very short in comparison with other languages.
•Modular Programming- An application’s body in C++ can be made up of several source code files (called modules) that are compiled separately and then linked together.
•C Compatibility- Any code of C can easily be included in a C++ program without hardly making any change.
•Speed-The resulting code from a C++ compilation is very efficient, due indeed to its duality as high-level and low-level language and to the reduced size of the language itself.
Object Oriented Programming Features
-Emphasis on objects instead of problem solution
-Program developed around objects and classes.
-There are 4 basic features of object oriented programming: