Skip to main content

Posts

2025 Results

 
Recent posts

2024 Results

 

2023 Results

 

Program to accept a number. Display the reverse of the number. Using Python

Program to accept a number. Display the reverse of the number. Input: 123 Output: 321 r=0 n = int(input("Enter a number:")) while n>0:     d=n%10     r=r*10+d     n=n//10 print("Reverse of the number is",r) ''' Dry Run r=0 n=123 123>0,True, d=123%10=3, r=0*10+3=3, n=123//10=12 12>0,True, d=12%10=2, r=3*10+2=32, n=12//10=1 1>0,True, d=1%10=1, r=32*10+1=321, n=1//10=0 0>0,False Reverse of the number is 321 '''

A departmental shop has 5 stores and 6 departments. The monthly sale of the department is kept in the Double Dimensional Array (DDA) as m[5][6]. The manager of the shop wants to know the total monthly sale of each store and each department at any time. Write a program to perform the given task. Hint: Number of stores as rows and Number of departments as columns.

 A departmental shop has 5 stores and 6 departments. The monthly sale of the department is kept in the Double Dimensional Array (DDA) as m[5][6]. The manager of the shop wants to know the total monthly sale of each store and each department at any time. Write a program to perform the given task. Hint: Number of stores as rows and Number of departments as columns. import java.util.Scanner; class Department{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int deptshop[][] = new int[5][6]; //5 stores(rows) 6 deparments(columns) int sales[] = new int[5]; //total sales data for 5 stores for(int i=0;i<5;i++){ //row System.out.println("Enter data for store:"+(i+1)); int sum=0; for(int j=0;j<6;j++){ //column System.out.println("Enter sales amount into department "+(j+1)); deptshop[i][j]=sc.nextInt(); sum=sum+deptshop[i][j]; } sales[i]=sum; //store the total sales amount for each store } ...

Write a program to accept the starting and ending range. Display the sum of even and odd numbers .

Write a program to accept the starting and ending range. Display the sum of even and odd numbers . import java.util.Scanner; public class Range {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);                                   System.out.println("Enter the starting and ending range:");         int m = sc.nextInt();         int n = sc.nextInt();         if(m<n){             int so=0,se=0;             for(int i=m;i<=n;i++)             {                 if(i%2==0)                 {                     se=se+i;        ...

Write a program to accept 50 numbers. Count and display the numbers which are positive and negative.

Write a program to accept 50 numbers. Count and display the numbers which are positive and negative. import java.util.Scanner; class posneg {     public static void main(String args[])     {         Scanner sc=new Scanner(System.in);         System.out.println("Enter 50 numbers:");         int nc=0,pc=0;         for(int i=1;i<=50;i++)         {             System.out.println("Enter number:");             int n=sc.nextInt();             if(n>=0)             {                 pc=pc+1;                 System.out.println(n+" is positive number");             }             else{          ...