print the pattern 1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
if n=5

Answers were Sorted based on User's Feedback



print the pattern 1 2 4 ..

Answer / murthyknm

public class Pattern
{
public static void main(String args[])
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i*j+" ");
}
System.out.println();
}
}
}

Is This Answer Correct ?    2 Yes 1 No

print the pattern 1 2 4 ..

Answer / vamsi talapatra

#include<iostream>
using namespace std;
int main(){
int n = 1;
int l = 1;
while(n<=5){
for(int i = 1; i<=l; i++){
cout<<n*i<<" ";
}
cout<<endl;
l++;
n++;
}
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

print the pattern 1 2 4 ..

Answer / akshay chinche

#include<stdio.h>

int main()
{
int i,j,k,n=5,temp=2,fix;
fix=k=1;

for(i=1;i<=4;i++)
{
fix++;
k=fix;
for(j=1;j<=n;j++)
{
if(j<=i+1)
{
printf("%d ",k);
k=k+temp;
}
}

k=0;
temp++;
putchar (10);
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

how to find your architecture is LittleEndian or BigEndian?

1 Answers  


code for reverse alternate words from astring

1 Answers   IBM,


an algorithem for the implementation of circular doubly linked list

1 Answers  


write the program for maximum of the following numbers? 122,198,290,71,143,325,98

5 Answers  


What is the mean of this statement:: if(int i=0 * i=9)

2 Answers   HCL,






Write a program that receives as input a number omaadel-n-print, four digits.

0 Answers  


What are the different pointer models in c?

4 Answers  


What 'lex' does?

0 Answers   Tech Mahindra,


Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)

5 Answers   IBM, KJH,


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

0 Answers  


show how link list can be used to repersent the following polynomial i) 5x+2

0 Answers   CBSE,


What is the use of pointers in C?

0 Answers   Impetus, Motorola, Tavant Technologies, Virtusa,


Categories