Answer: technolyy is a graphic igneger that allows itenas to go throught...
Answer:
E. None of the above
Explanation:
char ans[20]
int num = 40;
sprintf(ans, "%d to %d", num, num +10);
This code fragment produce an error,because in 1st line of code char ans[20] ,there is no semicolon after the line.As ans is undeclared ,the ide will produce an error as we use it in
sprintf(<u>ans</u>, "%d to %d", num, num +10);
If we put semicolon after the char ans[20]
,then it will not give error but also don't produce an output because for sprintf we should initialize the num and ans as of pointer type.
It is a condition for sprintf and num should be of string type.
<u>C program
</u>
#include <stdio.h>
int main()
{
char ans[20];
int num = 40;
sprintf(ans, "%d to %d", num, num +10);
return 0;
}
<u>Output </u>
No output
(You can check this code on any ide for confirmation.)
Answer:
Written in Python
G = 6.673 *pow(10,-11)
M = 5.98 *pow(10,24)
d = float(input("Distance: "))
g = (G * M)/(pow(d,2))
print("Acceleration of gravity: "+str(g))
Explanation:
This line initializes the gravititational constant
G = 6.673 *pow(10,-11)
This line initializes the mass of the earth
M = 5.98 *pow(10,24)
This line prompts user for object distance
d = float(input("Distance: "))
This line calculates the object's gravity
g = (G * M)/(pow(d,2))
This line prints the calculated gravity without approximating
print("Acceleration of gravity: "+str(g))
Answer:
The class definition for above problem in java is as follows:-
Explanation:
class Counter // class counter
{
int counter; // variable counter
Counter(int v) // construtor
{
counter=v;
}
void increment() //increment function
{
counter=counter+1;
}
void decrement() //decrement function
{
counter=counter-1;
}
int getValue() //getvalue function
{
return counter;
}
}
Code Explanation:
- The above class definition is in java language.
- In this code, the name of the class is a Counter and it holds the three functions (increment, decrement and getvalue) and one constructor which is mentioned in the question.
- To call the above class and their function firstly the user needs to create an object of the counter class in the main function by passing the one integer value on it.
- The object declaration statement calls the constructor.
- And then any function can be called by the object of the class with the help of the dot operator.