C++ programming language
Create a program that
1) counts from 0 to 10, but doeesn't include 10
2) counts backwards from 100 to 50 (inclusive) by 2's
If you have any doubts please comment below.
Cpp Code:
#include <bits/stdc++.h>
using namespace std;
// Counts the number of '2' digits in a single number
int number0f2s(int n)
{
int count = 0;
while (n > 0)
{
if (n % 10 == 2)
count++;
n = n / 10;
}
return count;
}
// Counts the number of '2' digits between 0 and 10
int numberOf2sinRange(int n)
{
// Initialize result
int count = 0 ;
// Count 2's in every number from 2 to n
for (int i = 2; i < n; i++)
count += number0f2s(i);
return count;
}
int numberOf2sinRangeBackward(int n , int m)
{
int count = 0;
for(int i=n; i>=m; i--)
count += number0f2s(i);
return count;
}
int main()
{
cout << "Counts from 0 to 10 by 2's : "<< numberOf2sinRange(10)<<endl;
cout << "Counts from 100 to 50 backwards : "<< numberOf2sinRangeBackward(100,50);
return 0;
}
C++ programming language Create a program that 1) counts from 0 to 10, but doeesn't include...
THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is prime or not. The program should at the end of its analysis print the number followed by prime or composite. Part 2.Make the program from part 1 print the prime factors of any composite number entered (an additional feature to Part 1). THE PROGRAMMING LANGUAGE IS C++
Answer should be in C programming language Write a program that will create an array of 10 floating point numbers and take input 10 floats from keyboard. The program will print the position (index) of the maximum and minimum number among them
Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...
Language: C Programming, Please leave as many comments as possible! Create a program that has a menu as shown: 1. Generate 500 Random Numbers between 1 and 500 2. Show Current Set of Random Numbers ordered from Low To High 3. Show Frequency of each number from 1 to 500 4. Quit The program will store all random number in an array on the heap.
using C language Programming Question 1 Write a C program that takes students marks from a user, one by one until -1" is entered, which would indicate that no other marks are available, and the program terminates. For each mark the program will decide the student grade as: Fail, if mark < 60 • D. if 60<= mark <=70 • C. if 70<=mark <=80 • B. if 80c= mark <=90 • A. if 90cmark <=100 -T -- E - 15203...
Create a C# program that counts from -3 to 3 in the console using a do . . . while loop. Using a different kind of loop will result in a score of 0 for this problem.
C programming language 1. Write a program that prints the minimum value and the maximum value of a given array. For example array a is: int al 10] 140,30,20,50,10,80,99.90,85,70;: the minimum value is 10 and the maximum value is 99. Write a program that Converts an Integer from base 10 to base 2. 2. 3. Write a program that reads in ten marks and then calculates the pass rate
C++ Programming: Using Conditions Hello, can anyone create a C++ program that will allow me to ask the user to supply the current total and the quantity of the hardware purchased. This program should calculate the grand total based on the number of units purchased as shown in the chart below: Amount of Hardware Discount Received 10-19 20% 20-49 30% 50-99 40% 100 or more 50% Also, make sure to certify what happens when the user enter 0 or less...
Question 1 In the following incomplete C program: #include stdlib.h> #include <stdio.h> int main () { int i, n, max; int array[100]; ... } return 0; } an array of random int values is populated with n random values. Write only the code to find the location of the maximum value in the array. Question 2 Follow these instructions in your Linux account: 1. Create a file called data.txt in the root folder in your account. 2. Create a new...
Write in C# Programming Language. - count =0; - Create a 2d array "items". string[,] items = new string[100, 4]; - Create a do while loop, when user enter "0", stop the loop. - User enter item name, price, quantity, save these info and subtotal to array. - increase "count++" -conver price(decimal, Convert.ToDecimal() ) and quantity(int) to do mulplication for subtotal - create a for loop (with count ) to cycle through the "items", display item name, price, quantity, and...