we provide you the c downloads,c programing,c tutorials and much more at www.cplusplus-in.blogspot.com.Codes of c++ are also there for your help.This blog build your c programing style.
Friday, 27 July 2012
how to find prime number using c++
This is the source code for finding prime number
#include<iostream.h>
#include<conio.h>
main()
{
int n,d,p=1;
cout<<"enter the number?";
cin>>n;
d=2;
while(d<=n/2)
{
if(n%d==0)
p=0;
d++;
}
if(p==0)
cout<<"not prime number";
else
cout<<"prime number";
getch();
}
End
Wednesday, 25 July 2012
how to fill and display array using functions
This is the source code of how to fill and display array using functions
#include<iostream.h>
#include<conio.h>
const int n=9;
int GA[n];
void fillarray(void){
const int n=9;
int A[n];
int i=0;
while(i<=9){
cout<<"value of element"<<i<<"?"<<endl;
cin>>A[i];
GA[i]=A[i];
i++;
}
}
void displayarray(void){
for(int i=0;i<=9;i++){
cout<<GA[i]<<endl;
}
}
int main()
{
fillarray();
displayarray();
getch();
}
End
#include<iostream.h>
#include<conio.h>
const int n=9;
int GA[n];
void fillarray(void){
const int n=9;
int A[n];
int i=0;
while(i<=9){
cout<<"value of element"<<i<<"?"<<endl;
cin>>A[i];
GA[i]=A[i];
i++;
}
}
void displayarray(void){
for(int i=0;i<=9;i++){
cout<<GA[i]<<endl;
}
}
int main()
{
fillarray();
displayarray();
getch();
}
End
Sunday, 8 July 2012
How to calculate the average of all the values in the array
Subscribe to:
Posts (Atom)