Question

P.2. Division Write a C program to input an integer n. Then the program asks users...

P.2. Division

Write a C program to input an integer n. Then the program asks users to input n integers. Calculate the sum of all non negative integers and the division of this with every negative integer in the sequence.

p3
Write a C program to print all 3-digit abc numbers, satisfying: (a+b+c)=(a.b.c). Example: 3-digit 123 number fulfills requirement as (1+2+3)=1.2.3

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main() {
    int i, n, sum = 0, num;
    printf("Enter a positive inger for n: ");
    scanf("%d", &n);
    printf("Enter %d integers: ",n);
    for (i = 0; i < n; ++i) {
        scanf("%d", &num);
        if (num > 0) {
            sum += num;
        }
    }
    printf("Sum of all non-negative integers is %d\n", sum);
    return 0;
}

\color{blue}as\;per\;guidelines\;we\;are\;only\;allowed\;to\;answer\;first\;program\\ Please\;make\;a\;separate\;post\;for\;second\;program\\ Thanks

Add a comment
Know the answer?
Add Answer to:
P.2. Division Write a C program to input an integer n. Then the program asks users...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program that asks users to input an integer number and print the summation...

    Write a Python program that asks users to input an integer number and print the summation of its digits and total number of its digits. (i.e., for n=35, sum is 3+5=8, and total number of digits is 2).

  • Write a program that asks the user to input a 4-digit integer and then prints the...

    Write a program that asks the user to input a 4-digit integer and then prints the integer in reverse. Your program needs to implement a function reverse that will take in as input the 4-digit number and print it out in reverse. Your code will consist of two files: main.s and reverse.s. Main.s will ask for the user input number and call the function reverse. For ARM/Data Structure needs to be able to run on Pi Reverse.s will take in...

  • C++ coding answer 5. Write a program that asks the user for a positive integer value....

    C++ coding answer 5. Write a program that asks the user for a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. Input Validation: Do not accept a negative starting number.

  • Program : Write a complete C++ program that Input: Read a positive integer from the keyboard...

    Program : Write a complete C++ program that Input: Read a positive integer from the keyboard (user) with proper prompt text and save it to a variable. The integer have up to five digits. Processing: From the right most digit, extract every digit from the input integer using modular operator %then save the digit to a separate variable. Remove the right most digit from the integer using integer division operator /. Repeat above two steps till all digits have been...

  • Write a C++ program that asks the user to input a decimal integer (i) and an...

    Write a C++ program that asks the user to input a decimal integer (i) and an integer radix from 2 to 16 (r) and outputs the value of iin radix r(base r). (HINT: use repeated division by base r) NOTE: show output screenshot

  • Exercise 1: Write a C++ program that asks the user to input an integer n followed...

    Exercise 1: Write a C++ program that asks the user to input an integer n followed by n other characters that will be stored in an array. We suppose here that the user will input only lowercase characters between ‘a’ and ‘z’. We also suppose that the user will input different characters. The program will then sort these characters according to an increasing order of their alphabetical order. In this exercise, feel free to use selection sort, insertion sort, or...

  • WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and...

    WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and b (a < b). You need to do error checking in this stage to make sure the input is correct. For example, a = 1, b = 50. B. Write a separate function, isEven() to list all even within [a, b] inclusive. C. n the main function, print a, b and the list of even numbers.

  • Write a program that reads a positive integer N, where N is greater than 1 and...

    Write a program that reads a positive integer N, where N is greater than 1 and prints the value of the floating-point value SUM where SUM is the results of the following series. SUM = 1/1! + 2/2! + 3/3! + 4/4! + ... N/N! Note that your program should print the message “Sorry, bad N”” if N is <=1, and keep reading user input until the user enters a valid value for N. Also, note that all division operations...

  • the user should be prompted to enter an integer and then your program will produce another...

    the user should be prompted to enter an integer and then your program will produce another integer depending on whether the input was even or odd. The following is an example of what you might see when you run the program; the input you type is shown in green (press Enter at the end of a line), and the output generated by the program is shown in black text. Enter an integer: 1234 Number is even, taking every other digit...

  • Exercise Write a program which asks the user to enter an integer n. It will print...

    Exercise Write a program which asks the user to enter an integer n. It will print a diamond shape if n is negative, AA AAAA AAAAAA AAAA AA a triangle otherwise. AA AMA AAAA AAAAA

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT