Answer:
Algorithm:
1.Create a variable N.
2.Read the value of N from user.
3.for i=1 to N.
3.1 Print value of i.
4.end program.
Implementation in C++:
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variable
int N;
cout<<"Enter value of N:";
// read the value of N
cin>>N;
cout<<"Natural number from 1 to "<<N<<" are:";
for(int i=1;i<=N;i++)
{
// print the numbers
cout<<i<<" ";
}
return 0;
}
Output:
Enter value of N:6
Natural number from 1 to 6 are:1 2 3 4 5 6
Answer:
//importing package java.util.ArrayList to use ArrayList in the program
import java.util.ArrayList;
import java.util.Date;
public class test_array_list {
// Main method
public static void main(String[] args) {
// Create an array list of objects
ArrayList<Object> s = new ArrayList<Object>();
s.add(new Loan());
s.add(new Date());
s.add(new String("String class"));
s.add(new Circle());
// Display all the elements in the list by
// invoking the object’s to String() method
for (int element = 0; element < o.size(); element++) {
System.out.println((s.get(element)).toString());
}
}
}
Explanation:
The Above code has proper comments to which is self explanatory.
Answer:
if the landing page provides all kind information of information as to that site people usually like it or will most likely enjoy it
BRAINLIEST?????
Explanation:
Answer: The working of the CPU is defined as a three-step process. First, an instruction is fetched from memory. Second, the instruction is decoded and the processor figures out what it's being told to do. Third, the instruction is executed and an operation is performed.
Explanation: Hope this helps
Answer:
Following are the code to the given question:
public class Main//defining a class Main
{
static int permut(int n, int r)//defining a method permut that holds two variable
{
return fact(n)/fact(n-r);//use return keyword to return calcuate value
}
static int fact(int n)//defining a fact method as recursive to calculate factorials
{
return n==0?1:n*fact(n-1);//calling the method recursively
}
public static void main(String[] abs)//main function
{
//int n=7,r=4;//defining integer variable
System.out.println(permut(7,4));//use print method to call permut method and print its values
}
}
Output:
840
Explanation:
Following is the explanation for the above code.
- Defining a class Main.
- Inside the class two methods, "permut and fact" were defined, in which the "permut" accepts two values for calculating its permutated value, and the fact is used for calculates factorial values recursively.
- At the last, the main method is declared, which uses the print method to call "permut" and prints its return values.