473,398 Members | 2,812 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,398 software developers and data experts.

need help to write a program

please help me how could i get the output ?
1
12
123
1234
123
12
1
if i m using C++ array and next qusestion is how can i search an integer from two dimensional array?
Oct 14 '06 #1
10 3344
Karan
5
please help me how could i get the output ?
1
12
123
1234
123
12
1
if i m using C++ array and next qusestion is how can i search an integer from two dimensional array?
Hi,
You have to use two for loops to display these kind of output.

the for loops can be:-

for( i=1; i<5; i++)
for( j=1; j<=i; j++)
print ( j )


and to search a integer in an 2D array u hve to use again two for loops.
Oct 14 '06 #2
sircool
12
please help me how could i get the output ?
1
12
123
1234
123
12
1
if i m using C++ array and next qusestion is how can i search an integer from two dimensional array?
karan is true i would help you about finding a integer from the 2D arrays
you shold write 2 for loops and a if state like that

int search;

for(int i;i<size;i++)
for(int j;j<size;j++)
if(array[i][j]==search)
return 0;

can be...
Oct 14 '06 #3
karan is true i would help you about finding a integer from the 2D arrays
you shold write 2 for loops and a if state like that

int search;

for(int i;i<size;i++)
for(int j;j<size;j++)
if(array[i][j]==search)
return 0;

can be...
thanks for helping but one thing that i've forget to mention that i m following this method but it's not doing....and always give output not found this program is behaving miserably
can u tell me this from the first thing to the end i mean from #include<iostream.h>.........to ..........getch();}
i'll very thankful to u please reply me as soon as possible thanks alot again
Oct 15 '06 #4
Hi,
You have to use two for loops to display these kind of output.

the for loops can be:-

for( i=1; i<5; i++)
for( j=1; j<=i; j++)
print ( j )


and to search a integer in an 2D array u hve to use again two for loops.
hello Karan...thanks to help but Karan i m still learning and really,still i dont understand how to initiate this program please could u write this program again clearly besides giving me hints ....i 'll be very thankful to u
waiting for ur reply
Oct 15 '06 #5
code of the your problem is very simple


#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int search;
int arr[row][colom]={{here enter the element of array}};
cout<<"enter the element to be search";
cin>>search;
for(int i=0;i<=row;i++)
{
for(int j=0;j<=colom;j++)
{
if(arr[i][j]==search)
break;
}
}
cout<<"no can be found at the position of:" <<arr[i][j];
getch();
}
Oct 16 '06 #6
code of the your problem is very simple
oh thank u so much u've made my day
its working inshallah if i got type of problem i'll ask u in future ok thanks once again
Oct 18 '06 #7
i need again help in writing a program
how can i make a program which can calculate factorial using C++
Oct 19 '06 #8
D_C
293 100+
Expand|Select|Wrap|Line Numbers
  1. int factorial(int n)
  2. {
  3.   int result = 1;
  4.   while(n > 1)
  5.   {
  6.     result *= n;
  7.     n--;
  8.   }
  9.   return result;
  10. }
Oct 19 '06 #9
hi khan,
this is in simple c++
if you want to use class or some other concepts than will send you



void fac(int num)
{
int fac=1;
for(i=num;i>=1;i--)
{
fac=fac*i;
}
cout<<"Factorial ="<<fac;
getch();
}
Rawinder dhillon
Oct 20 '06 #10
try this

A recursive factorial

int fact(int n)
{
if (n == 0)
return 1;

return ( n * fact( n-1 ) );
}
Oct 28 '06 #11

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

Similar topics

10
by: Jeff Wagner | last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting...
9
by: terry | last post by:
I am a programmer (cobol, peoplesoft, sqr, etc.) so I am familiar with programming logic, etc. but not very familiar with C. I need a C program in a study I'm doing. The program is fairly simple,...
11
by: abico | last post by:
Write a program that reads in a sequence of words and prints them in reverse order.Using STACK.
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
25
by: vikram Bhuskute | last post by:
I have plans to train some students for C in coming weeks. I am badly looking for C programming assignments fot them. Need 1) lots of them per topiic 2) Should be doable for beginners thanks...
24
by: kevin | last post by:
write a program in c.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.