Question:Write a C program to input an integer
k. Compute 10^k and store the
result in a double variable. Display
the result on the standard output using printf.
Implementation
° The program is named lab4c . c. Use the given template lab4c .c
(BELOW ) and fill in your code.
° Assume that the input integer k is small enough so that 10^k
can be stored in a double variable
named my_double.
° Display on the standard output the result using the printf
statement as follows:
printf( "% . 15lf\n", my_double );
--------------------------------------------------------------
Sample Inputs/Outputs
indigo 152 % a.out
Enter an integer>0
1.000000000000000
indigo 153 % a.out
Enter an integer>3
1000.000000000000000
indigo 154 % a.out
Enter an integer>12
1000000000000.000000000000000
indigo 155 % a.out
Enter an integer>15
1000000000000000.000000000000000
indigo 156 % a.out
Enter an integer>-1
0.100000000000000
indigo 157 % a.out
Enter an integer>-10
0.000000000100000
indigo 158 % a.out
Enter an integer>-14
0.000000000000010
indigo 159 % a.out
Enter an integer>-15
0.000000000000001
indigo 160 % a.out
Enter an integer>—16
0.000000000000000
-----------------------------------------------------------------
#include <stdio.h>
void power_of_ten( receive k and my_double from main function )
{
/* Add your code here */
} /* end power_of_ten */
main()
{
int k;
double my_double;
scanf( "%d", &k );
power_of_ten( pass k and my_double to the function );
/* Hint: my_double must be passed by reference (i.e., using a pointer). */
/* Do not modify the following line. */
printf( "%.15lf\n", my_double );
}Here I've provided the code.
*** CODE STARTS HERE ***
#include <stdio.h>
void power_of_ten( int k, double *mydouble )
{
/* Add your code here */
double result = 1;
// compute power k times
while (k--) {
result = result * 10;
}
*mydouble = result;
} /* end power_of_ten */
main()
{
int k;
double my_double;
scanf( "%d", &k );
power_of_ten( k, &my_double);
/* Hint: my_double must be passed by reference (i.e., using a
pointer). */
/* Do not modify the following line. */
printf( "%.15lf\n", my_double );
}
*** CODE ENDS HERE ***
for any queries please do comment.
Question:Write a C program to input an integer k. Compute 10^k and store the result in...
Convert the C program into a C++ program.Replace all C input/output statements with C++ statements (cin, cout, cin.getline) . Re-make the func function by the following prototype: void func( double, double &); #include int user_interface(); double func(double); void print_table(); int main (int argc, char *argv[]) { print_table(user_interface()); return 0 ; } int user_interface(int val){ int input = 0; printf("This function takes in x and returns an output\n"); printf("Enter Maximum Number of X:"); scanf("%d", &input);...
C Program: How do I display if the input is invalid for input not in the range from (1-10); #include <stdio.h> int main(){ int number,i; // prompt user to enter number of lines to print Bad Dog printf("Enter a number of lines to print Bad Dog:"); scanf("%d",&number); for(i=0;i<number;i++){ goto nonono; nonono: printf("Bad Dog\n"); } return 0; }// end main
C program--write a program to find whether the given number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is since 3**3 + 7**3 + 1**3 = 371. Output: Enter a number, or * to quit : 432 4**3 + 3**3 + 2**3 is not = 432 Enter a number, or * to quit : 371 3**3 + 7**3 + 1**3 is = 371...
1. Specification Write a C program to implement a simple calculator that accepts input in the following format and displays the result of the computation: calc [operand_1] [operator] [operand_2] The operands operand_1 and operand_2 are non-negative integers. The operator is one of the following: addition (+), subtraction (-), multiplication (x), division (/) and modulo (%). Note: For the multiplication operator, use letter ‘x’. If you use the asterisk ‘*’, your program will not work properly 2. Implementation • The program...
C program--write a program to find whether the given number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is since 3**3 + 7**3 + 1**3 = 371. Output: Enter a number, or * to quit : 432 4**3 + 3**3 + 2**3 is not = 432 Enter a number, or * to quit : 371 3**3 + 7**3 + 1**3 is = 371...
Can i get help with this C program requirement. Modify the program Figure 2.13 (letter/while). Create a variable at the top of your code named power2 and assign it the value 8 Create a variable at the top of your code named result and assign it the value 0 Ask the user to enter FOUR 1's and 0's followed by a '*' In the loop, when the letter is '1' add power2 to result and store it back into result...
Here is a serial program in C and parallel program in OpenMP that takes in a string as input and counts the number of occurrences of a character you choose. Why is the runtime for the output for the OpenMP parallel program much longer? Serial Program #include <stdio.h> #include <string.h> #include <time.h> int main(){ char str[1000], ch; int i, frequency = 0; clock_t t; struct timespec ts, ts2; printf("Enter a string: "); gets(str); int len = strlen(str); printf("Enter a character...
Create another program that will prompt a user for input file. The user will choose from 4 choices: 1. Display all positive balance accounts. 2. Display all negative balance accounts. 3. Display all zero balance accounts. 4. End program. C PROGRAMMING my code so far #include<stdlib.h> #include<stdio.h> int main(void) { int request; int account; FILE *rptr; char name[20]; double balance; FILE *wptr; int accountNumber; if((wptr = fopen("clients.dat","w")) == NULL) { puts("File could not be opened"); } else {...
Solve using C programming
3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...
Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...