Java program to Calculate Sum of Odd or Even numbers | Learn Coding

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ก.ย. 2024
  • Java Full Course for Beginners...!👇👇
    • Java Programming
    Please Like | Share | SUBSCRIBE our Channel..!
    Learn Coding
    🙏🙏🙏
    Like our Facebook Page...!
    Learn Coding
    Don't forget to tag our Channel...!
    #AddOddEven
    #LearnCoding
    #ask4help
    #JavaProgramSumOfOddEven

ความคิดเห็น • 25

  • @suraj_Suraj
    @suraj_Suraj 2 ปีที่แล้ว +12

    Instead of two for loops I used single common *for loop* as follows:
    import java.util.Scanner;
    class HelloWorld {
    public static void main(String[] args) {
    int n,sum=0;
    System.out.print("Enter the range: ");
    Scanner obj=new Scanner(System.in);
    n=obj.nextInt();
    for (int i=n; i>=0; i-=2)
    {
    sum=sum+i;
    }if(n%2==0)
    System.out.println("Sum of even numbers in the range: "+sum); else
    System.out.println("Sum of odd numbers in given range: "+sum);
    }
    }

    • @Sjot2416
      @Sjot2416 2 ปีที่แล้ว

      What if you don't want to use if else

    • @-GCET-CS
      @-GCET-CS ปีที่แล้ว

      Nice

  • @akhileshkushwaha9211
    @akhileshkushwaha9211 3 ปีที่แล้ว +1

    Nicely explanationed

  • @b4bikramjit
    @b4bikramjit ปีที่แล้ว

    Pranam guruji...

  • @greedyontop
    @greedyontop 9 หลายเดือนก่อน

    My question 9 is not odd number but you write

  • @tapansingh6956
    @tapansingh6956 2 ปีที่แล้ว +1

    Bhai ye ek hee for loop me mene kar diya .. for loop me if else liya aur if k liye evensum aur else k liye oddsum .... Iske wajah se program easy hogya hai jabki tumne jo liya hai usme i =i+2 woh unusual hai aur samjhna thoda mushkil hai

  • @AlexG-ec3do
    @AlexG-ec3do 8 หลายเดือนก่อน

    Bro why you use if else 🤷🏻‍♂️ if you had to manipulate for loop according to you 😮

  • @nishasingamvadisherla3606
    @nishasingamvadisherla3606 3 ปีที่แล้ว +1

    Explaining in very easy language. Thank you so much....

  • @art_flix_
    @art_flix_ ปีที่แล้ว

    can you make a video on-Given maximum of 100 digit numbers as input, find difference between sum of odd and even position

  • @viraltoovideos
    @viraltoovideos 2 ปีที่แล้ว

    Sir ap jab copy ka video shoot karte hai to extra bahar ka background nahi show karta hai sir mujhe bhi please bataea kese karte hai sir please.

  • @whitedevil-xm4ug
    @whitedevil-xm4ug ปีที่แล้ว +1

    😊😊😊

  • @kuldeepkashyap8641
    @kuldeepkashyap8641 9 หลายเดือนก่อน

    full Spring boot padha do sir

  • @AnkitSharma-yx6fh
    @AnkitSharma-yx6fh ปีที่แล้ว

    Sir telegram link not working sir

  • @satishreddybojanpally9824
    @satishreddybojanpally9824 ปีที่แล้ว

    Sir u r hero of coding sir
    U r helping a lot sir

  • @kainaatmakhani6550
    @kainaatmakhani6550 2 ปีที่แล้ว

    good job

  • @coronagaming1919
    @coronagaming1919 3 ปีที่แล้ว

    Sir ap kha se h bihar ya jharkhand??

  • @snehalwaman2414
    @snehalwaman2414 ปีที่แล้ว

    What if we have to do odd and even at a same time?

    • @-GCET-CS
      @-GCET-CS ปีที่แล้ว +1

      Than u have to remove only the following if and else condn from the above program and u r ready to go
      If(n%2==0)

  • @jigneshpatel5876
    @jigneshpatel5876 2 ปีที่แล้ว

    adavance cograts for 1m family

  • @bhagwanjundre3630
    @bhagwanjundre3630 ปีที่แล้ว

    We can't increment +2 in for loop