Question

**In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())**

Complete the following functions using C programming language:

a) Complete the int Q7a(intQ7_input) function takes a seven-digit positive integer as input and returns it reversed. For example, if the integer is 9806593, the program should print 3956089. You are not permitted to use any function of C standard library other than scanf()and printf().You are not permitted to use arrays either. For the case when the integer ends with 0, the number printed cannot have leading 0’s (Eg: input 3412400; output 42143).

Note: Use the division and remainder operators to separate the number into its individual digits.

b) Modify your program so it returns backwards any positive integer, not necessarily a seven-digit one.

Answer #1

#include <stdio.h> int Q7a(int Q7_input) { int result = 0; while(Q7_input>0){ result *= 10; result += (Q7_input%10); Q7_input /= 10; } return result; } int main(){ int n; printf("Enter value for n: "); scanf("%d",&n); printf("Reverse: %d\n",Q7a(n)); return 0; }

int Q7a(int Q7_input) { int result = 0; while(Q7_input>0){ result *= 10; result += (Q7_input%10); Q7_input /= 10; } return result; }

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
For this exercise you should be able to write a logical
expression (i.e., with logical operators) which checks if some
integer x consists of exactly 5 digits. Ex: 30498 and -14004 are
5-digit numbers, while 1018, -2 and 46 are not.
Complete the intQ2(intQ2_input) function that takes an input
integer parameter and returns 1 if the number is...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following function using C programming
language:
Complete the function intQ3(floatQ3_input) that takes a
student’s average as an input, which is a floating-point value, and
returns:
4 if the average is in the range 90-100,
3 if it is in the range 80-89,
2 if it is in the range 70-79,
1 if it is in the...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
Calculate the value of π from the infinite series:
π = 4 – 4/3 + 4/5 – 4/7 + 4/9 – 4/11 + …
Complete the double Q4(intQ4_input) function which reads a
positive integer Q4_input as an input parameter and calculates the
value of π by adding up the first...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
intQ1_for()
intQ1_while()
intQ1_do()
To compute the sum of all numbers that are multiples of 4,
between 30 and 1000, in 3 different ways: with a for loop, a while
loop and a do-while loop, accordingly. After each loop print the
value. Return the total sum at the end of each...

In this example you are allowed to use from the C
standard library only functions for input and output (e.g.
printf(), scanf())
Complete the following functions using C programming
language:
A positive integer number is said to be a perfect number if its
positive factors, including 1 (but not the number itself), sum to
the number. For example, 6 is a perfect number because 6=1+2+3.
Complete the int Q6(intQ6_input, int perfect[])function that
determines all perfect numbers smaller than or equal...

Using C programming
Create a function called printMenu( ) with the following
properties:
Has no function inputs or output.
Prints the following menu to the screen:
1. Enter user name.
2. Enter scores.
3. Display average score.
4. Display summary.
5. Quit
Create a function called printLine( ) with the following
properties:
Takes as input a char
Takes as input an integer corresponding to the number of
times to print the character
Has no function output.
For example, if we...

This question is broken into 3 parts, each of which builds on
the functions developed in the previous part. Note that you can
(and should) still answer parts (b) and (c) even if you cannot
answer the preceding parts - just assume that the functions work as
they should, and continue.
Please explain the code as well
Write a C function called weighted_digit_sum that
takes a single integer as input, and returns a weighted sum of that
numbers digits. The...

You will write a program that loops until the user selects 0 to
exit. In the loop the user interactively selects a menu choice to
compress or decompress a file. There are three menu options: Option
0: allows the user to exit the program.
Option 1: allows the user to compress the specified input file
and store the result in an output file.
Option 2: allows the user to decompress the specified input file
and store the result in an...

Use C++ to implement the following program
about Prime Factorization of a Number. Do BOTH
parts of the problem or you will lose points. Provide
comments to explain each step.
a. Write a function that takes as a parameter a positive integer
and returns a list (array) of the prime factors of the given
integer. For example, if the parameter is 20, you should return 2 2
5.
b. Write a function that tests the above function by asking the...

Following are the most important file management functions
available in C. Use any 6 of them in your program and show the
output.
Function
purpose
fopen ()
Creating a file or opening an existing file
fclose ()
Closing a file
fprintf ()
Writing a block of data to a file
fscanf ()
Reading a block data from a file
getc ()
Reads a single character from a file
putc ()
Writes a single character to a file
getw ()
Reads...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 13 minutes ago

asked 30 minutes ago

asked 46 minutes ago

asked 55 minutes ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 3 hours ago

asked 3 hours ago

asked 3 hours ago