Code With Harry is my attempt to teach basics and those coding techniques to people in short time which took me ages to learn. At Code With Harry, I provide a quick and to the point demo along with resources of anything and everything I teach. Source code and other resources are hosted on my website CodeWithHarry.com. I provide source code(if any) in the description of every video. Quality programming videos in Hindi :) Business enquiries: harry@codewithharry.com
import java.util.Random; import java.util.Scanner; class game{ Scanner sc= new Scanner(System.in); Random rand = new Random(); private int cno; private int tryno=1; private int choice=1000; game(){ cno=rand.nextInt(0,11); } public void iscorrect(){ while(cno!=choice){ System.out.print("Guess the number:"); choice=sc.nextInt(); if(choice>cno){ System.out.println("Your number is higher"); tryno++; } else if(choice==cno){ System.out.println("your number is correct"); } else{ System.out.println("Your number is lower"); tryno++; } } System.out.println("Congatulations!! you guessed the correct number"); } public int gettryno(){ return tryno; } } class guess{ public static void main(String args[]){ System.out.println("Welcome to the game you have to guess the number computer choose between 1-10 in lowest possible guess.... "); game g= new game(); g.iscorrect(); int x=g.gettryno(); System.out.println("the number of guesses you took are:"+x); } }
FOR LOOP #include<iostream> using namespace std; int main () { int i=1,n=6; for(int i=1;i<=10;i++) { cout<<i*n<<endl; } return 0; } WHILE LOOP #include<iostream> using namespace std; int main () { int i=1,n=6; while(i<=10) { i++; cout<<i*n<<endl; } return 0; } DO WHILE LOOP #include<iostream> using namespace std; int main() { int i=1,n=6; do { i++; cout<<i*n<<endl; } while (i<10); }
Hello sir, challenge accepted This is the code for my character array: char c[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; for (char a = 0; a < 10; a++) { printf("Enter the alphabets for index %c ", a); scanf("%c", &c[a]); } for (char a = 0; a < 10; a++) { printf("The alphabet for index is %c is %c ", a, c[a]); } This code is working but something weird is happening. So can you please diagnose the fault in this and tell me.
Actually I am a beginner and I want to learn web development but I am a little confused from where I should learn My friend gave me delta batch of apna college but some of my friends suggest that I should learn web development form code with Harry RU-vid so can you please suggest which one should I follow