#include <stdio.h>
int getSum(long long int num)
{
int sum = 0;
while(num)
{
sum += num%10;
num /= 10;
}
return sum;
}
int main()
{
long long int num;
printf("Enter a positive number : ");
scanf("%lld",&num);
printf("The sum of digits is : %d\n",getSum(num));
}


Using a while loop and if-else statements if required, write a function file that will add...
Using MatLab Write a function called PrimeFinder that receives an integer n as an input argument, and provides an output argument called Primes that is a vector containing all prime numbers between 2 and n, inclusive. Verify the correctness of your code with inserting 13 as the input argument, and check that your output is Primes = [2,3,5,7,11,13]. You are NOT allowed to use any directly relevant MATLAB built-in function such as divisors, etc. NOTE: A prime number is a...
Function Name: sepDigits Inputs: 1. (double) A three-digit integer Outputs: 1. (double) The hundreds-place digit of the input 2. (double) The tens-place digit of the input 3. (double) The ones-place digit of the input Function Description: This function will take in a three-digit integer (integer between 100 and 999 , inclusive) and should return each digit as a separate number. For example, if the input is 472 , the first output would be 4 , the second would be 7...
3. Write a function called sort3 that takes a 3-element vector as its sole arguments. It uses if-statements, possibly nested, to return the three elements of the vector as three scalar output-arguments in nondecreasino-roer , i.e., the first output argument equals the smallest element of the input vector and the last output argument equals the largest element. NOTE: Your function may NOT use any built-in functions, e.g., sort, min, max, median, etc. (5 points) (bonus question). Write a function called...
c++ #include <iostream> #include <string> using namespace std; /* Write a function checkPrime such that input: an int output: boolean function: Return true if the number is a prime number and return false otherwise */ //TO DO ************************************** /* Write a function checkPrime such that input: an array of int and size of array output: nothing function: Display the prime numbers of the array */ //TO DO ************************************** /* Write a function SumofPrimes such that input: an int output: nothing...
Jave eclipse Wanna help Program 1 Algorithm Problem statement: Write a Java program to add up the digits of a number entered by the user and output the result. You may not use an array top perform this task. The program should be able to handle an integer of any size. For example, if the number 1256 was entered, the sum would be: SumOfDigits = 1 + 2 + 5 + 6 = 14 Solution: The following Algorithm could be...
In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let’s define a seed of an integer, n, to be a positive value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1...
WRITE THIS PROGRAM IN JAVA CODING ONLY ! Program 1: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt the user for three numbers and displays them in ascending order. First, the program will prompt the user for each of the three numbers. Next, find the smallest value of the three. Then decide which of the other two is the next smallest. Then have the program display the three numbers in ascending order. Be sure to...
C linux
please write it by only using “if and else” conditions, thanks
so much
this is my task 3
Requirements 1. Copy your solution for Task 3 t3.c to a new file t4.c. 2. The input is guaranteed to contain at least one non-whitespace character. 3. If the input is well-formed, i.e., can be parsed to a number, the program should behave identically to Task 3. All the requirements of Task 3 still apply except the file name. 4....
Using basic c++ write a separate code for each question. 1. Palindrome if else • Try to find if a 5 digit input number is a palindrome • Get one 5 digit number from user • Output: Enter a five-digit integer: 12345 12345 is not a palindrome Enter a five-digit integer: 34543 34543 is a palindrome 2. WiFi Diagonostics using multiple ifs PRINT: This program will help you diagnose a bad WiFi connection. 1 st level Check the below (Use...
(java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...