The for loop looks like this:
for (i = 1; i <= 10; i++)
{
...
}
This will repeat anything inside ten times; the variable "i" will have the values 1, 2, ...10. The first part is the initial assignment, the second part specifies a condition - while it is true, the loop should continue, and the third part increments the variable(s).
Replace the "..." with anything you want to repeat 10 times, for example, a System.out.println(...) that involves the variable "i".
#include // This code multiplies all the numbers from 1 to 10 together. // If you just wanted a specific number, replace the outer for loop with (for example) i=5; .
int main(){
int i, j;
for(i=1;i
Hey Guys this is bharat from hyderabad.Heres a simple Multiplication table to get a table by just giving the number at runtime you want to get:
Ans 3 :
import java.util.*;
public class MultiplicationTable {
static public void main(String[] ar) {
Scanner sc=new Scanner(System.in);
System.out.println("please enter the number");
int n=sc.nextInt();
System.out.println("Multiplication table : ");
for(int i=1;i<=10;i++) {
System.out.println(n+"*"+i+"="+(n*i));
}
}
}
Ans. 1. This works, but isn't very pretty, especially when printed in variable-width fonts. Play with the format to get it to look the way you like.
// pre-print column headers
System.out.print(" ");
for (int c = 0; c <= 10; ++c) {
System.out.format("%4d", c);
}
System.out.println();
System.out.print(" ");
for (int c = 0; c <= 10; ++c) {
System.out.format(" -");
}
System.out.println();
// calculations
for (int r = 0; r <= 10; ++r) {
// row headers
System.out.format("%2d|", r);
// calculation for the current row
for (int c = 0; c <= 10; ++c) {
System.out.format("%4d", (r * c));
}
System.out.println();
}
Ans.2 :
class table
{
public static void main(String args[])
int n=2;
System.out.println("Table of " + n + " is :");
int result;
for (int a = 1; a <= 10; a++)
{
result = n * a;
System.out.println(result);
}
}
#include
#include
void main()
{
int i,j;
clrscr();
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
printf("%3d",i*j);
}
printf("\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j;
printf("Enter a number=");
scanf("\n%d",&a);
b=a*2,c=a*3,d=a*4,e=a*5,f=a*6,g=a*7,h=a*8,i=a*9,j=a*10;
printf("%d",a);
printf("\n%d",b);
printf("\n%d",c);
printf("\n%d",d);
printf("\n%d",e);
printf("\n%d",f);
printf("\n%d",g);
printf("\n%d",h);
printf("\n%d",i);
printf("\n%d",j);
getch();
}
#include<conio.h>
#include<stdio.h>
void main()
{
int no;
clrscr();
printf("enter the number==>");
scanf("\t%d",
I will write some pseudocode, I suppose that counts as an algorithm. // Given: Number n for i = 1 to 9 print the following: n + " x " + i + " = " + n * i
Use an enum if you are using a c style language. Or a map data structure. Assign each integer an English value and then match it to what the user inputs.
x -=y;
Use a counted for loop. On each iteration, multiply the control variable by 2 and print the result.
int firstNumber,secondNumber for(firstNumber = min; firstNumber <= max; firstNumber++); { for(secondNumber = min; secondNumber <=max; secondNumber++); int result firstNumber * secondNumber; }
To write a C++ program to display the student details using class and array of object.
how to write a program for matrix multiplication in microprocesspr
Use an enum if you are using a c style language. Or a map data structure. Assign each integer an English value and then match it to what the user inputs.
Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.
x -=y;
Use a counted for loop. On each iteration, multiply the control variable by 2 and print the result.
write a program to display your name age class schoolname e-mail 2hobby based on choice
Faisal
int firstNumber,secondNumber for(firstNumber = min; firstNumber <= max; firstNumber++); { for(secondNumber = min; secondNumber <=max; secondNumber++); int result firstNumber * secondNumber; }
To write a C++ program to display the student details using class and array of object.
integer = input("Please input an integer greater than 0: ") print(integer)
a*b = exp (ln a + ln b)
Write a program which takes the temperature in farhenheight.the program should display the farhenheight temperature as well as centigrade. C= (f-32)*5/9