beginner"problem in arrays help me in codes"

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 2
Reputation: naya is an unknown quantity at this point 
Solved Threads: 0
naya naya is offline Offline
Newbie Poster

beginner"problem in arrays help me in codes"

 
0
  #1
Nov 19th, 2004
undefined
hi,
i m naya.i m student of telecommunicatin engineering.i have a lot problems in "C PROGRAMMING".plz tell me the codes to find max,min values....to print factorial of a number...how copy an array to other.....to print tables of numbers....n how to swaps in array..
plz they all codes should be in arrays...plz help me
in 21 nov i will give exam in my uni. of "ARRAYS IN C"
I SHALL BE VERY TO U.....
BYE
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,848
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 754
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: beginner"problem in arrays help me in codes"

 
0
  #2
Nov 19th, 2004
I have a better idea. You prove that you've tried to solve these problems on your own, and we'll help you with any errors. No one is going to do your homework for you.
New members chased away this month: 4
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 68
Reputation: harshchandra is an unknown quantity at this point 
Solved Threads: 1
harshchandra harshchandra is offline Offline
Junior Poster in Training

Re: beginner"problem in arrays help me in codes"

 
-1
  #3
Nov 19th, 2004
oh sure !! i can help you out.Here are the codes
1. Finding Maximum and minimum values in a array

# include<stdio.h>
# define MAX 10
void main()
{ int a[MAX],i,mini,maxi;
for(i=0;i<MAX;i++)
{ printf("Enter Any number : ");
scanf("%d",&a[i]);
}
mini=a[0];
maxi[0];
for(i=1;i<MAX;i++)
{ if(a[i]>max)
maxi = a[i];
if(a[i]<min)
mini = a[i];
}
printf("The minimum and maximum no in the given array is %d and %d",mini,maxi);
getch();
}

2. Sorting an array.
There are many techniques to sort a given array .One of it is given below.This code sorts the array in an ascending order , if u want to sort in descending order just change the sign from ">" to "<" in the code.rest all wil remain as it is .

# include<stdio.h>
# define MAX 10
void main()
{ int a[MAX],i,j,temp;
for(i=0;i<MAX;i++)
{ printf("Enter Any number : ");
scanf("%d",&a[i]);
}
for(i=0;i<MAX;i++)
{ for(j=i+1;j<MAX;j++)
{ if(a[i]>a[j])
{ temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("The sorted Array is : \n");
for(i=0;i<MAX;i++)
{ printf("%d\n",a[i]);
}
getch();
}

3. Factorial of a given numbers , i m taking an example that an array consist of 10 elements and i have to find the factorial of each number ,and store it in seperate array and finally printing printing the array.

# include<stdio.h>
# include<conio.h>
# define MAX 10
void main()
{ long int a[MAX],fact[MAX],i,j;
int pro;
for(i=0;i<MAX;i++)
{ printf("Enter Any number : ");
scanf("%ld",&a[i]);
}
for(i=0;i<MAX;i++)
{ pro=1;
for(j=1;j<=a[i];j++)
{ pro *=j;
}
fact[i]=pro;
}
for(i=0;i<MAX;i++)
{ printf("\nFactorial of %d : ",a[i]);
printf("%ld\n",fact[i]);
}
getch();
}
I hope all these codes will be helpful to you.All the best for your Exams .

cheers,
Harsh chandra
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2681 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC