I have uploaded all my projects in C, C++, HTML, CSS, Java, and Android Development Projects in a topic-wise sequential manner.
Further posts are uploaded on https://mohitx001.blogspot.com/
package com.company ; public class Ch2_09_PrecedenceAndAssociativity { public static void main ( String [] args ) { int x = 1 - 4 * 5 ; //precedence of '*' is more than '-' System . out . println ( x ); int a = 50 / 5 - 2 * 5 ; //Associativity is applied left to right int b = 5 * 4 - 20 / 2 ; System . out . println ( a ); System . out . println ( b ); int x1 , y1 ; x1 = y1 = 10 ; //10 is assigned to y1 than value of y1 is assigned to x1(L to R) System . out . println ( "x1 = " + x1 + ", y1 = " + y1 ); //Quick quiz int x2 = 4 , y2 = 8 ; int exp1 = ( x2 - y2 ) / 2 ; System . out . println ( exp1 ); int a1 = 8 , b1 = 10 , c = 20 ; int exp2 = ( b1 * b1 - 4 * a1 * c ) / ( 2 * a1 ); System . out . println ( exp2 ); int v = 5 , u = 3 ; int exp3 = v * v - u * u ; System . out . println ( exp3 ); ...
package com.company ; import java.util.Random ; import java.util.Scanner ; public class Ch9_43_Ex3_GuessTheNumber { public static void main ( String [] args ) { Random rand = new Random (); int rand_num = rand . nextInt ( 100 ); System . out . println ( rand_num ); Scanner scan = new Scanner ( System . in ); int guessed_num = - 1 ; int numberOfGuesses = 1 ; while ( guessed_num != rand_num ) { System . out . println ( "Guess the number: " ); guessed_num = scan . nextInt (); if ( guessed_num > rand_num ) { System . out . println ( "Aww ...Too big number." ); numberOfGuesses ++; } else if ( guessed_num < rand_num ) { System . out . println ( "Oops...its a small number." ); numberOfGuesses ++; } } System . out . println ( "yehh...You got the number in...
Comments
Post a Comment