473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Please any one answer thease questions

Please any one provide the logic for these out puts


[html]
[pre]

Q1)

0
12
345
6789

Q2)

0
21
543
9876

Q3)
0
101
21012
3210123
432101234
3210123
21012
101
0
[/pre]
[/html]
Sep 7 '06 #1
6 1829
Banfa
9,065 Expert Mod 8TB
A homeowrk question if ever I saw one.

Do you not see any pattern to numbers?

In question 1 try putting the numbers on a single line

How does this apply to question 2?

In question 3 look at the columns of numbers created. What do you notice?
Sep 7 '06 #2
I try to solve these questions
but i coudn't
which was asked my teacher in yesterday class..

pls help me...
Sep 7 '06 #3
at a brief glance, question one is not only vertical but diagonal too. e.g. plus two, plus three, plus four

0+2 = 2
2+3 = 5
5+4 = 9
Sep 7 '06 #4
silly me, just listen to banfa
Sep 7 '06 #5
risby
30
Please any one provide the logic for these out puts


[html]
[pre]

Q1)

0
12
345
6789

Q2)

0
21
543
9876

Q3)
0
101
21012
3210123
432101234
3210123
21012
101
0
[/pre]
[/html]
I can't help wondering if you and durini ali attend the same class.

Anyway, is this the kind of logic you are looking for?
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char ** argv)
  5. {
  6.     int r = 0;
  7.     int i;
  8.     int first;
  9.     char digits[] = "0123456789";
  10.  
  11. /* print consecutive digits in lines of increasing width */
  12.     for (i=first=0; first+i<(int)strlen(digits)+1; i++, first += i)
  13.     {
  14.         printf("%*.*s\n", i+1, i+1, &digits[first]);
  15.     }
  16.     printf("\n");
  17.  
  18.     return r;
  19. }
  20.  
Sep 7 '06 #6
risby
30
Anyway, is this the kind of logic you are looking for?
Hmmm, I forgot to right-justify the strings. How about this:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char ** argv)
  5. {
  6.     int r = 0;
  7.     int i;
  8.     int first;
  9.     int width;
  10.     char digits[] = "0123456789";
  11.  
  12. /* calculate maximum width */
  13.     for (i=first=0; first+i<(int)strlen(digits)+1; i++, first += i)
  14.     {
  15.         width=i+1;;
  16.     }
  17.  
  18. /* print consecutive digits in lines of increasing width */
  19.     for (i=first=0; first+i<(int)strlen(digits)+1; i++, first += i)
  20.     {
  21.         printf("%*.*s\n", width, i+1, &digits[first]);
  22.     }
  23.  
  24.     return r;
  25. }
  26.  
Sep 7 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Carolyn Gill | last post by:
I have already created an asp login/database for a learning/quiz section on a small site. There will be multiple quizzes through the site and what I need now would be help: tutorials or advice that...
2
by: A. Wiebenga | last post by:
Hi all! I am currently involved in a project in which I am supposed to write a XSLT-transformation sheet for some XML data. I will outline the situation first: I've got one large XML file...
18
by: free2cric | last post by:
Hi, I attanded an interview on C++ Question asked were and my answers to them.. 1. In a CPP program what does memory leak occure? -- i said.. In a constructor , the pointer variables were...
15
by: Anton Gavrilov | last post by:
Hi all, I seek your advice on where to start if I want to write a compiler for a toy C-like language I invented (or, rather, am in the process of inventing). Yes, yes, I know I'm crazy and the...
0
by: Henry | last post by:
Hi Everyone, My name is Henry and I'm a Master of Computing student at Unitec New Zealand (www.unitec.ac.nz). I'm currently doing my Thesis titled: "Utilizing Newsgroups as Customer Support Tool...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
12
by: si_owen | last post by:
Hi all, I have a SQL query that worked fine in my project until it came to testing. I found that the NvarChar fields I have wont accept the use of an ' My code and query is here does anyone...
5
by: NaziaAkter | last post by:
Hi EveryOne, I am having problem with deleting data form database after anyone have close the site. or any one have click the cancel button after entering data. I know the code for deleting data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.