Apex Program



  1. Write a program to print area of a circle. A(circle)= 3.142 * R * R (Solution)
  2. Write a program to print area of a triangle A(Triangle)= 0.5 * B * H
  3. Write a program to print simple interest SI = (PNR)/100
  4. Write a program to accept a number from user and print it's square & cube
  5. Write a program to accept two values a & b and interchange their values.
  6. Write a program to accept roll no and marks of 3 subjects of a student, Calculate total of 3 subjects and average.
  7. Write a program to accept a number N and print whether it is positive, negative or zero
  8. Write a program to accept two numbers and print the greater value of the two.
  9. Write a program to accept a number N and print whether the number is EVEN or ODD
  10. Write a program to accept roll number ,and marks for three subjects, print total marks and average, also print grade by considering following conditions.
    Avg>=60 Grade A
    Avg<60,Avg >=50 Grade B
    Avg<50,Avg >=40 Grade C
  11. Write a Program to accept two numbers and an operator (+, -, *, / from user and complete that particular operation.
  12. Write a function to find whether the given input number is Odd. If the given number is odd, the function should return 2 else it should return 1.
    Note: The number passed to the function can be negative, positive or zero. Zero should NOT be treated as odd.
  13. Write a program to accept a number and check if it is >10, <10 or =10.
  14. Write a program to accept three numbers from user and print them in ascending and descending order.
  15. Write a Program to accept user’s marital status, gender and age to check if he/she is eligible for marriage or not.
  16. Write a program to print alternate numbers starting from 1 to 99 i.e. 1 3 5 7 9 11 13 . . . 95 97 99
  17. Write a program to print all numbers backwards from 100 to 0 i.e. 100 99 98 97 96 . . . 4 3 2 1 0
  18. Write a program to print numbers backwards from 100 to 1 by skipping 2 numbers i.e. 100 97 94 91 88 85 82 79. . . 22 19 16 13 10 7 4 1
  19. Write a program to print all the Numbers Divisible by 7 from 1 to 100.(Solution)
  20. Write a Program to print numbers n to 1 using Do While loop.
  21. Write a Program to print numbers 1 to n using while loop.
  22. Write a Program to print first n even numbers.
  23. Write a function that returns the last digit of the given number. Last digit is being referred to the least significant digit i.e. the digit in the ones (units) place in the given number.
    The last digit should be returned as a positive number.
    For example,
    if the given number is 197, the last digit is 7
    if the given number is -197, the last digit is 7
  24. Write a function that returns the second last digit of the given number. Second last digit is being referred to the digit in the tens place in the given number.
    For example,
    if the given number is 197, the second last digit is 9
    Note1 - The second last digit should be returned as a positive number. i.e. if the given number is -197, the second last digit is 9
    Note2 - If the given number is a single digit number, then the second last digit does not exist. In such cases, the function should return -1. i.e. if the given number is 5, the second last digit should be returned as -1
  25. Rohit wants to add the last digits of two given numbers. For example, If the given numbers are 267 and 154, the output should be 11. Below is the explanation -
    Last digit of the 267 is 7
    Last digit of the 154 is 4
    Sum of 7 and 4 = 11
    Write a program to help Rohit achieve this for any given two numbers.
    The prototype of the method should be -
    int addLastDigits(int input1, int input2);
    where input1 and input2 denote the two numbers whose last digits are to be added.
    Note: The sign of the input numbers should be ignored. i.e.
    if the input numbers are 267 and 154, the sum of last two digits should be 11
    if the input numbers are 267 and -154, the sum of last two digits should be 11
    if the input numbers are -267 and 154, the sum of last two digits should be 11
    if the input numbers are -267 and -154, the sum of last two digits should be 11









  1. Write a Program to print first n odd numbers.
    Write a Program to accept a number and print the number in reverse order. E.g. if 1324 is the number then the output will be 4231.
    Write a Program to accept a number and print sum of it’s digits.
    Write a Program to accept a number and count the number of digits in that number.
    Write a program to check whether a given Number is Palindrome or Not
    Write a program to Check whether a given Number is an Armstrong Number or not. An Armstrong number is a number that is equal to the sum of its digits, each raised to the power of the number of digits in the number
    Write a program to Check Whether given Number is Perfect or Not. A perfect number is a positive integer that is equal to the sum of its proper divisors, which are all of its positive divisors excluding the number itself.
    Write a program to print table of a given number n.
    Write a program to accept a number from user and print it’s factorial.
    Write a program to accept a number from user and print if it is prime or not.
    Write a program to accept a number and print prime numbers between 2 and n.
    Write a program to find the Sum of all prime numbers from 1 to n.
    Write a program to accept a number and print fibonacci series upto that level.
    Write a program to accept a number n from user and Add n terms of the series.
    1/2! + 2/3! + 3/4! + 4/5! + 5/6! + ………
    Write a program to accept a number from user and print that number in words but in reverse order.
    E.g. 153 -> THREE FIVE ONE
    Write a program to create a list of integer numbers and print addition of all the elements of the list.
    Write a program to create a list of integer numbers and print maximum and minimum element from that list.
    Write a program to create a list of integer numbers. Now pick all the even numbers from that list and store them in evenList. And pick all the odd numbers from that list and store them in oddList.
    Write a program to print day according to the day number entered by the user.
    Write a program to print the following sequence of integers.
    0, 5, 10, 15, 20, 25
    Write a program to find the Sum of following Series:
    (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
    Write a program to find the Sum of following Series:
    (1) + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n)
    Write a program to find the Sum of following Series:
    [(1^1)/1!] + [(2^2)/2!] + [(3^3)/3!] + [(4^4)/4!] + [(5^5)/5!] + ... + [(n^n)/n!]
    Write a program to find sum of even and odd numbers stored in a list.
    Write a program to Print All the Repeated Numbers with Frequency in a list.
    Write a program to Increment Every Element of the List by One & Print Incremented List.
    Jhon has sorted few confidential numbers in an array (array of int). To ensure that others do not find the numbers eassily, he has appiled a simple ecoding.
    Encoding used:
    Reverse the original array
    Each array element has been substituted with a value that is the sum of its original value and its succeeding element’s value. i.e. arr[i]= original value of arr[i] + original value of arr[i+1] i.e. also note that value of last element i.e. arr[last index] remains unchanged.
    Jhon Smith has been approached by the “techtomind society for kids” for help in generating the password. After listing the scenario, Smith realises that he will need a programmer’s support. Please help Smith by writing a function to generate the password.
    The scenario is as below-
    N- Numbers are available with the kids. These numbers are either stable or unstable. A number is stable if each of its digits occur the same number of times, i.e. the frequency of each digit in the number is same. For example: 112233, 1111, 4004, 12, 1010, 344366, 1010 are stable numbers.
    Similarly, a number is unstable if the frequency of each digit in the number is not the same. For example: 11233, 112, 1223, 101, 343 are unstable numbers.
    The password can be generating as:
    Password=sum of all stable numbers – sum of all unstable numbers
    For example:
    N=5
    Numbers: 12, 1313, 122, 678, 898
    Stable number: 12, 1313, 678 Sum_of_stable= 12+1313+678=2003
    Unstable number: 122, 898 Sum_of_unstable=122+898=1020
    Password= 2003-1020= 983
    Write a function which accepts two integer number (Assume that both numbers are >=0) as arguments and adding both numbers from right to left one digit at a time. You need to calculate and return the total number carries generated while adding digits of two numbers.
    Example: Input:
    Number1: 675
    Number2: 126
    Output: 2
    Note:
    5+6 = 11 => carry 1
    7+2+1(carry) = 10 => carry=1
    6+1+1(carry) = 8 => No Carry
    Write program to generate the password which the sum of all possible palindrome numbers between given two numbers.
    For Example:
    Input: 10, 80
    Output: 308
    Explanation: All palindrome numbers between 10 & 80 are: 11,22,33,44,55,66,77
    Password= 11+22+33+44+55+66+77 = 308
    Tresesco Biswas has been approached by the “techtomind society for kids” for help in generating the password. After listing the scenario, Tresesco realises that he will need a programmer’s support. Please help of Tresesco by writing a function to generate the password.
    The scenario is as below-
    Kids want to generate a password an integer number with K digits. The password is a smallest K-digits number (None of the digits in password is 0) and the product of digits in password is greater than or equal to the sum of digits in password.
    For Examples:
    Input-1: K=3
    Output-1: Password= 123
    Input-2: K=4
    Output-2: Password = 1124
    Input-3: K=6
    Output-3: Password = 111126
    Write a method, wordReverser(), that will take a given string and reverse the order of the words and append the number of characters of that word at the end of the word. You may assume that the string is a sentence that contains only letters and spaces.
    For examples:
    Input-1 : "LearNowx rules"
    Outptu-1: "rules5 LearNowx8"
    Input -2: "May the Fourth be with you"
    Output-2: "you3 with4 be2 Fourth6 the3 May3"
    Create a CountDigitOccurance() method that will take the number and digit as argument and return the number of times the given digit occurs.
    Create a primeDigits(number) method that will return all the prime digits of an integer number.
  2. 9

Post a Comment

0 Comments