hello frends ... i need sme help in developing some programs in C
1) i want the out like this 1
1 1
1 1 2
1 1 2 3
1 1 2 3 5
1 1 2 3 5 8 ... & soon .. till the range i specify
... here you can see tht we are adding the Diagonal digits ... plz help
2 ) program .. i want out like this .. in this program .....
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
|
Newbie Member
|
|
| 1Jun2009,00:17 | #2 |
|
2)this is the answer:
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,k,before=0,array[10][10];
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=(2*i);j++)
{
if(j<=i)
{
array[i][j]=before+1;
before++;
}
else
{
array[i][j]=before-1;
before--;
}
}
before=0;
}
for(i=1;i<=5;i++)
{
for(j=1;j<=((2*i)-1);j++)
{
printf("%d",array[i][j]);
printf("\t");
}
printf("\n");
}
getch();
}
abhix95
likes this
|
|
Newbie Member
|
|
| 1Jun2009,00:39 | #3 |
|
1)
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b,c,i,j,array[10][10];
clrscr();
for(i=1;i<=5;i++)
{
a=0,b=1;
for(j=1;j<=i;j++)
{
if(j==1)
array[i][j]=1;
else
{
c=a+b;
array[i][j]=c;
a=b;
b=c;
}
}
}
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",array[i][j]);
printf("\t");
}
printf("\n");
}
getch();
}
abhix95
likes this
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 1Jun2009,06:49 | #4 |
|
Please post you code inside code-blocks.
If you are not allowed to change your post, shabbir might change it for you. |
|
Newbie Member
|
|
| 14May2010,13:37 | #5 |
|
Code:
#include<stdio.h>
int main(int argc , char *argv[])
{
int next = 1;
int range = 1, rangeEnd = 0;
int nextInRange = 0;
int prev = 1;
if(argv[1] == NULL) {
printf("Usage : ./a.out <range_number>\n");
} else {
rangeEnd = atoi(argv[1]);
}
for(; range <= rangeEnd ; range++) {
next = 1;
prev = 1;
if(range >= nextInRange) {
printf("%d %d ", prev, next);
for(; next < range ;) {
next = prev + next;
printf("%d ", next);
prev = next - prev;
}
nextInRange = next + prev;
putchar('\n');
}
}
}
abhix95
likes this
|
|
Mentor
|
![]() |
| 15May2010,14:43 | #6 |
|
OK, now where are the difficult C programs?
|
|
Newbie Member
|
|
| 25Feb2011,12:32 | #7 |
|
[QUOTE=aijaz;27389]hello frends ... i need sme help in developing some programs in C
Code:
1) i want the out like this 1
1 1
1 1 2
1 1 2 3
1 1 2 3 5
1 1 2 3 5 8 ... & soon .. till the range i specify
Code:
public class Pattern {
public static void main(String[] args) {
for(int i=1;i<7;i++) {
int p=0,n=1,t;
for(int j=1;j<=i;j++) {
System.out.print(n);
t=n;
n+=p;
p=t;
}
System.out.println("");
}
}
}
|
|
Newbie Member
|
|
| 25Feb2011,12:40 | #8 |
|
Quote:
Originally Posted by aijaz Code:
public class Pattern {
public static void main(String[] args) {
System.out.println("1");
for(int i=1,j;i<5;i++){
for(j=1;j<=i;j++){
System.out.print(j+" ");
}
for(;j>=1;j--){
System.out.print(j+" ");
}
System.out.println("");
}
}
}
|
|
Newbie Member
|
|
| 25Feb2011,12:46 | #9 |
|
[QUOTE=sameerthapa2050;79916]
Quote:
Originally Posted by aijaz
abhix95
likes this
|
|
Newbie Member
|
|
| 22Aug2011,18:01 | #10 |
|
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long n,j,p=0,q;
clrscr();
printf("\n Enter the number of rows : ");
scanf("%ld",&n);
for(j=0;j<=n-1;j++)
{
p=1*pow(10,j)+p;
q=p*p;
printf("%ld",q);
printf("\n");
}
getch();
}
abhix95
likes this
|



