Code:
#include <stdio.h>
int main()
{
/* variable declaration */
int i, max;
int a[50];
/* asking user to enter 4 numbers as input
*/
for(i = 1; i <= 4; i++){
printf("\nEnter number %d : ",
i);
scanf("%d", &a[i]);
}
/* initializing max to the first element */
max = a[0];
/* identifying max out of four numbers given */
for(i = 2; i <= 4; i++){
if(a[i] > max)
max =
a[i];
}
/* checking if max number is multiple of 3 */
if(max % 3 == 0)
printf("\nMax number %d is a
multiple of 3\n", max);
else
printf("\nMax number %d is not a
multiple of 3\n", max);
return 0;
}
Execution and output:
Unix Terminal> ./a.out
Enter number 1 : 18
Enter number 2 : 29
Enter number 3 : 3
Enter number 4 : 56
Max number 56 is not a multiple of 3
Unix Terminal> ./a.out
Enter number 1 : 10
Enter number 2 : 18
Enter number 3 : 7
Enter number 4 : 4
Max number 18 is a multiple of 3
Unix Terminal>
C Programming Read four numbers and find the largest value. Check if the largest value is...
Write a C++ program to read four whole numbers (integers) and perform the following (1) Display the largest of the numbers (2) Display the smallest of the numbers (3) Display sum of the even numbers (4) Display number of even and odd numbers
1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...
Using the programming language C, read user input of an integer, check and output whether the integer is an odd number or even number.
C programming Ask the user how many numbers they would like generated. Your program will then generate that many numbers (between 0 and 1000, inclusive) into an array of the same size. Find the smallest and largest numbers in the array, printing out the values and locations of those numbers in the array. Then, find the sum and average of the numbers in the array. Finally, print out the entire array to verify. You MUST use functions where appropriate!
Q1. Draw flowchart to find the average of 10 positive numbers. [Hint: Read the number in a loop, add them if it is positive and then find average] Q2. Draw flowchart to read 5 numbers from a user and then find the second largest number of them.
(C programming) Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each data set consists of: n a1 a2 . . an You can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000. The input end with a line consisting of a single 0. Output...
Use C++ Read numbers from a file and find the sum of numbers. Perform the following operations Read the console input and create a file.txt. $ in the console input is considered as an end of content for a file. Close the file after creation. Open the file in a read mode and read the numbers from a file and print the sum of all numbers. Input 77 124 2333 $ Where $ indicate an end of console input...
C++programming plese i need all codes in this homework 2. Homework 1) Read 3 numbers and display them in descending order. Enter 3 numbers 5 9 3 In descending order: 9 5 3 2) Implement following menu system. food Korean Rice, Bulgogi American Hamburger, Salad Chinese Noodle, Dimsum drink Cola, Orange juice, Water Select a menu 1. food 2. drink 1 You have selected food. Which food? 1. Korean 2. American 3. Chinese...
Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....
Programming language is C++. 9. Write a program that reads digits and composes them into integers. For example, 123 is read as the characters 1, 2, and 3. The program should output 123 is 1 hundred and 2 tens and 3 ones. The number should be output as an int value Handle numbers with one, two, three, or four digits. Hint: To get the integer value 5 from the character '5' subtract '0' that is, '5'-'0'