Posts
Showing posts from September, 2024
CPP MCQS AND PROBLEM STATEMENTS
- Get link
- X
- Other Apps
Select True or False: 1. Data items in a class may be public. 2. Class members are public by default. 3. Friend functions have access only to public members of the class. 4. A function designed as public can be accessible by non-members of a class. 5. Friendship is commutative. 6. new and delete are operators. 7. We can implement generic classes using templates 8. Using operator overloading we can invent new operators 9. Inheritance helps in making a general class into a more specific class.) 10. Classes can be inherited privately. 11. Constructors can be virtual like virtual destructors 12. A class encapsulates the implementation and interface of a user-defined data type and constitutes an abstract data type. 13. std::cout is a standard input stream. 14. Preprocessor #define macro and inline functions use the same mechanism. 15. The new operator returns the address and size of the memory block that it allocates....
Operators
- Get link
- X
- Other Apps
# == if [ 'Girish' == 'Girish' ]; then echo "same" #output else echo "not same" fi # != if [ 'Girish' != 'Apple' ]; then echo "not same" #output else echo "same" fi # -n if [ -n "Girish" ]; then echo "not null" #output else echo "null" fi # -z if [ -z "Girish" ]; then echo "null" else echo "not null" #output fi ========================== # -eq if [ 10 -eq 10 ];then echo "Equal" fi # -ge if [ 10 -ge 9 ];then echo "Greater or equal" fi # -gt if [ 10 -gt 8 ];then echo "Greater" fi # -le if [ 10 -le 12 ];then echo "Less than or equal" fi # -lt if [ 10 -lt 13 ];then echo "Less than" fi # -ne if [ 10 -ne 13 ];then echo "Not Equal" fi
Variables
- Get link
- X
- Other Apps
Defining Variables variable_name = <variable data> num="1" name="Devil" Accessing variable Variable data could be accessed by appending the variable name with ‘$’ as follows: #!/bin/bash VAR_1="Devil" VAR_2="OWL" echo "$VAR_1$VAR_2" Unsetting Variables The unset command directs a shell to delete a variable and its stored data from list of variables. It can be used as follows: #!/bin/bash var1="Devil" var2=23 echo $var1 $var2 unset var1 echo $var1 $var2 Note: The unset command could not be used to unset read-only variables. Read only Variables. These variables are read only i.e., their values could not be modified later in the script. Following is an example: #!/bin/bash var1="Devil" var2=23 readonly var1 echo $var1 $var2 var1=23 echo $var1 $var2 Now let us see all the above codes in action together. Following is a shell script that includes all the shell variables discussed above # accessing the declared varia...
While Loop
- Get link
- X
- Other Apps
Implementation of `While` Loop in Shell Script. vim looping.sh chmod +x looping.sh (./looping.sh) ==================================== #/bin/bash a=0 # lt is less than operator #Iterate the loop until a less than 10 while [ $a -lt 10 ] do # Print the values echo $a # increment the value a=`expr $a + 1` done ============================= #/bin/bash a=0 # -gt is greater than operator #Iterate the loop until a is greater than 10 until [ $a -gt 10 ] do # Print the values echo $a # increment the value a=`expr $a + 1` done ================== Implementation of `for` Loop with `break` statement in Shell Script. #/bin/bash #Start of for loop for a in 1 2 3 4 5 6 7 8 9 10 do # if a is equal to 5 break the loop if [ $a == 5 ] then break fi # Print the value echo “Iteration no $a” done ================== Implementation of `for` Loop with `continue` statement in Shell Script. #/bin/bash for a in 1 2 3 4 5 6 7 8 9 10 do # if a = 5 then continue the loop and # don’t move to line 8 if [ $a ...
Conditions
- Get link
- X
- Other Apps
Two types of decision-making statements are used within shell scripting. They are – If-else statement case-sac statement If-else statement If else statement is a conditional statement. It can be used to execute two different codes based on whether the given condition is satisfied or not. There are a couple of varieties present within the if-else statement. They are – ==================== if-fi Name="Girish" if [ "$Name" = "Girish" ]; then echo "His name is Girish. It is true." fi ==================== if-else-fi ==================== Age=17 if [ "$Age" -ge 18 ]; then echo "You can vote" else echo "You cannot vote" fi ==================== if-elif-else-fi ==================== Age=17 if [ "$Age" -ge 18 ]; then echo "You can vote" elif [ "$Age" -eq 17 ]; then echo "You can vote after one year" else echo "You cannot vote" fi ===============...
Dependencies
- Get link
- X
- Other Apps
< project xmlns = " http://maven.apache.org/POM/4.0.0 " xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation = " http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd "> < modelVersion > 4.0.0 </ modelVersion > < groupId > selenium </ groupId > < artifactId > selenium </ artifactId > < version > 0.0.1-SNAPSHOT </ version > < name > selenium </ name > < description > selenium </ description > < dependencies > <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> < dependency > < groupId > org.seleniumhq.selenium </ groupId > < artifactId > selenium-java </ artifactId > < version > 3.141.59 </ version > </ dependency > <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --> <!--...
Class File
- Get link
- X
- Other Apps
import io.github.bonigarcia.wdm.WebDriverManager; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.edge.*; public class Test { public static void main(String[] args) throws InterruptedException { WebDriverManager.edgedriver().setup(); WebDriver driver = new EdgeDriver(); driver.get("https://www.google.co.in/"); driver.manage().window().maximize(); WebElement textbox = driver.findElement(By.name("q")); textbox.sendKeys("harsh"); List<WebElement> list = driver.findElements(By.xpath("//input[@name='btnK']")); driver.findElement(By.xpath("//*[@alt = 'Google']")).click(); Thread.sleep(1000); driver.findElement(By.xpath("//*[@class='FPdoLc lJ9FBc']//input[@name='btnK']")).click(); //System.out.println(list); Thread.sleep(1000);...
cpp
- Get link
- X
- Other Apps
Assignment 1 Q1. Write a menu driven program for Date in a C. Declare a structure Date having data members day, month, year. Implement the following functions. void initDate(struct Date* ptrDate); void printDateOnConsole(struct Date* ptrDate); void acceptDateFromConsole(struct Date* ptrDate); Q2. Write a menu driven program for Date in a CPP language using structure and also using class. Date is having data members day, month, year. Implement the following functions. void initDate(); void printDateOnConsole(); void acceptDateFromConsole(); bool isLeapYear(); Q3. Write a menu driven program for Student in CPP language. Create a class student with data members roll no, name and marks. Implement the following functions void initStudent(); void printStudentOnConsole(); void acceptStudentFromConsole(); Q4. Create a namespace NStudent. Create the Student class(created as per Q3) inside namespace. Create the object of student and perform accept and display student. in c++ I'd be happy t...