Sunday, December 20, 2015

Addition of vector element

#include <iostream>
#include <vector>
using namespace std;
main()
{   int s=0;
vector<int> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
vector <int>::iterator it;
for(it = v.begin(); it != v.end();++it)
s=s+*it;
        cout <<s;
        return 0;
}

Monday, April 8, 2013

//wap to add two no by pointer



Adding two numbers using pointer




#include<stdio.h>
#include<conio.h>
  main()
{ int a,b,*pa,*pb;
//a=10,b=20;
pa=&a;
pb=&b;
printf("input 2 no ");
scanf("%d%d",pa,pb);
printf("\n sum=%d",*pa+*pb);
getch();
}

Saturday, March 30, 2013

Program to add two no by pointer .


#include<stdio.h>
#include<conio.h>
  main()
{ int a,b,*pa,*pb;
//a=10,b=20;
pa=&a;
pb=&b;
printf("input 2 no ");
scanf("%d%d",pa,pb);
printf("\n sum=%d",*pa+*pb);
getch();
}

Friday, May 11, 2012


Filecrop.com - search and download Mediafire, Hotfile and Rapidshare files

Program to check that entered no is divisible by 5 or not.


//program to check that entered no is divisible by 5 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s,i;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
for(i=0;i<1;i++)
 { r=n%10;
  n=n/10;
 }
 if(r==0||r==5)
 printf("Entered no is divisible by 5");
 else
 printf("Entered no is Not divisible by 5");
getch();
}

Program to count number of digits in a number.


// program to count number of digits in a number.
#include<stdio.h>
#include<conio.h>
main()
{
     int  num,count=0;
  printf("Enter a number: ");
  scanf("%d",&num);
   while(num)
  {
      num=num/10;
      count++;
  }
  printf("Total digits is:  %d",count);
getch();
}

Program to check that entered no is divisible by 9 or not.


//program to check that entered no is divisible by 9 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
 while(r!=0)
 { r=n%10;
  n=n/10;
  s=s+r;
 }
 if(s%9==0)
 printf("Entered no is divisible by 9");
 else
 printf("Entered no is Not divisible by 9");
getch();
}

Program to check that entered no is divisible by 10 or not.


//program to check that entered no is divisible by 10 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s,i;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
for(i=0;i<1;i++)
 { r=n%10;
  n=n/10;
 }
 if(r==0)
 printf("Entered no is divisible by 10");
 else
 printf("Entered no is Not divisible by 10");
getch();
}

Thursday, May 3, 2012

Program to check that entered no is divisible by 3 or not.


//program to check that entered no is divisible by 3 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
 while(r!=0)
 { r=n%10;
  n=n/10;
  s=s+r;
 }
 if(s%3==0)
 printf("Entered no is divisible by 3");
 else
 printf("Not divisible by 3");
getch();
}

Sunday, March 18, 2012

Program To print the two dimensional array.

//To print the two dimensional array.
#include<stdio.h>
#include<conio.h>
main()
{
      int a[3][3],i,j;
      printf("Enter the value of 3X3 array:-");
      for(i=0;i<3;i++)
      {
         for(j=0;j<3;j++)
          { scanf("%d",&a[i][j]);
          }
      } 
        printf("The 2D array is :");
        for(i=0;i<3;i++)
        { printf("\n\n");
         for(j=0;j<3;j++)
          { printf("%d  ",a[i][j]);
          }
        } 
        getch();
 }
          

To print the reverse of character.

//To print the reverse of character.
#include<stdio.h>
#include<conio.h>
main()
{     int i;
      char a[5];
      printf("Enter the name- ");
      for(i=0;i<5;i++)
      scanf("%c",&a[i]);
      printf("Your name is: ");
      for(i=0;i<5;i++)
      printf("%c",a[i]);
      printf("\nYour reverse  name is: ");
      for(i=4;i>=0;i--)
      printf("%c",a[i]);
      getch();
      }

Program To take character from the user by array .

//To take character from the user by array .
#include<stdio.h>
#include<conio.h>
main()
{     int i;
      char a[5];
      printf("Enter the name ");
      for(i=0;i<=4;i++)
      scanf("%c",&a[i]);
      printf("Your name is ");
      for(i=0;i<=4;i++)
      printf("%c",a[i]);
      getch();
      }

Saturday, March 17, 2012

Program for identify +ve and -ve no in an array .

Program for identify +ve and -ve no in an array .


#include<stdio.h>
#include<conio.h>
 main()
{
 int n[15],m,e,i;
 m=n[0];
 printf("Enter the 10 no ");
 for(i=0;i<10;i++)
 {
  scanf("%d",&n[i]);
 }

  printf("\nThe positive no are:\n");
  for(i=0;i<10;i++)
  {
   if(n[i]>0)
   {
    printf("%d,",n[i]);
   }
  }
  printf("\nThe negative no are:\n");
  for(i=0;i<10;i++)
  {
   if(n[i]<0)
   {
    printf("%d,",n[i]);
   }
  }
  getch();
}

Program to find odd and even nos. in an array.

//Program to find odd and even nos. in an array.
#include<stdio.h>
#include<conio.h>
 main()
{
 int n[10],i;
 printf("Enter the 10 no ");
 for(i=0;i<10;i++)
 {
  scanf("%d",&n[i]);
 }
   printf("The even nos: ");
  for(i=0;i<10;i++)
  {
   if(n[i]%2==0)
   {  
    printf("%d,",n[i]);
   }
         }
   printf("\nThe odd nos : ");
   for(i=0;i<10;i++)
   {
   if(n[i]%2!=0)
    { //o[i]=n[i];
   printf("%d,",n[i]);
    }
  
  }

                         
  getch();
}

Program for finding Largest no.

//Program for finding Largest no.
#include<stdio.h>
#include<conio.h>
 main()
{
 int n[15],m,i;
 printf("Enter the 10 no ");
 for(i=0;i<10;i++)
 {
  scanf("%d",&n[i]);
 }
 printf("The entered array is ");
  for(i=0;i<10;i++)
  {printf("   ");
  printf("%d",n[i]);
  }
  m=n[0];
  for(i=0;i<10;i++)
  {
   if(n[i]>m)
   {
    m=n[i];
   }
  }
  printf("\nLargest is %d",m);
    getch();
}

Program for addition of 10 no's.

//Addition of 10 no's.
#include<stdio.h>
#include<conio.h>
 main()
{
 int n[15],o=0,e,i;
    printf("Enter the 10 no ");
 for(i=0;i<5;i++)
 {
  scanf("%d",&n[i]);
 }
    printf("The entered array is ");
     for(i=0;i<5;i++)
  {printf("   ");
         printf("%d",n[i]);
  }
  for(i=0;i<5;i++)
  {
   o=o+n[i];
  }
  printf("Sum =%d",o);
  getch();
}
 

Program to Print fibonacci series.

// The fibonacci series.
#include<stdio.h>
#include<conio.h>
main()
{
      int i,n,f,s,t;
      printf("How many element you want to print:");
      scanf("%d",&n);
      f=0;
      s=1;
      printf("The  fibonacci series up to %d is : %d,%d",n,f,s);
      for(i=0;i<n-2;i++)
      {                
       t=f+s;
       f=s;
       s=t;
       printf(",%d",t);
       }
       getch();
       }
      
     

Saturday, March 10, 2012

Program to print the pyramid of no.

//Program to print the  pyramid of no.
              1
          1  2  3 
       1 2  3  4  5
    1 2 3  4  5  6  7
#include<stdio.h>
#include<conio.h>
main()
{
      int x,y,i,g;
      y=1;
      for(x=3;x>=0;x--)
      {
      for(i=1;i<=x;i++)
       {printf("   ");
       }g=1;
       for(i=0;i<y;i++)
       {printf(" %d",g);g++;
       }
      
       y=y+2;
       printf("\n\n");
       }
       getch();
       }

Program to Print the pyramid.

//Program to Print the pyramid.
       *
     ***
   *****
 *******
#include<stdio.h>
#include<conio.h>
main()
{
      int x,y,i;
      y=1;
      for(x=3;x>=0;x--)
      {
      for(i=1;i<=x;i++)
       {printf(" ");
       }
       for(i=0;i<y;i++)
       {printf("*");
       }
      
       y=y+2;
       printf("\n\n");
       }
       getch();
       }

Program to Print the pyramid.

//Program to Print the pyramid.
             *
         ***
     *****
 *******

#include<stdio.h>
#include<conio.h>
main()
{
      int x,y,i;
      y=1;
      for(x=3;x>=0;x--)
      {
       for(i=1;i<=x;i++)
       {printf("  ");
       }
       for(i=1;i<=y;i++)
       {printf("*");
       }
       y=y+2;
       printf("\n");
       }
       getch();
       }