Answer:
Class are the collection of variable and member function.
Class are the blueprint of an object.
Explanation:
Following are the points regarding class in c++
1.In C++ class is an user defined datatype..
2.Classes are the collection of variable and function in c++.
3.To access the property of class we can create object of that class
4.We can use following syntax to declared any class in c++
class classname
{
accessmodifier:
//statement and function
};
main()
{
classname objectname;
}
implementation of class in c++
#include<iostream>
class test // class declaration
{
public: // access modifier
void fun3() // Method definition
{
cout<<" hello :";
}
};
void main() // main function
{
test ob;// creating object
ob.fun3(); // calling function
}
In this program we declared a class "test " in class test. We giving public access modifier .The public access modifier define that variable and function are accessible outside the class and in main method we create the object ob which call the function fun3().
Output:hello :
Answer: Unable to follow normal shutdown process creates a bad sector on the harddrive and too much of this crashes the disk .
Answer:
public static void swap(int[] arr, int i, int j) {
if(i >=0 && i <=arr.length-1 && j >=0 && j<=arr.length-1){
int hold = arr[i];
arr[i] = arr[j];
arr[j] = hold;
}
}
public static void allSwap(int[] arr) {
if (arr.length % 2 == 0){
for(int i=0; i<arr.length; i+=2){
int hold = arr[i+1];
arr[i+1] = arr[i];
arr[i] = hold;
}
} else{
System.out.println("array length is not even.");
}
}
Explanation:
The two functions, swap and allSwap are defined methods in a class. The latter swaps the item values at the specified index in an array while the second accepts an array of even length and swap the adjacent values.
import java.util.Scanner;
public class JavaApplication40 {
public static void printGPA(Scanner scan){
System.out.println("Enter a student name:");
String name = scan.nextLine();
System.out.println("Enter the number of courses:");
int courses = scan.nextInt();
double total = 0;
for (int i = 1; i <= courses; i++){
System.out.println("Course "+i+" Grade:");
double grade = scan.nextDouble();
total += grade;
}
System.out.println(name+"'s grade is "+(total/courses));
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
printGPA(scan);
}
}
I hope this helps!