Showing posts with label programs. Show all posts
Showing posts with label programs. Show all posts

Thursday, September 27, 2012

Doubly Linked Lists Implementation using oops of c plus plus | Data Structure

Doubly Linked Lists Implementation using oops of c plus plus | Data Structure

Doubly Linked Lists Implementation using oops of c plus plus | Data Structure
By Sanjay Sinalkar
Write a program in c++ using object oriented concept to create Double Linklist which having following functionality 

1)Insert element at Begin
2)Insert element at given position
3)Insert element at End
4)Delete element from Begin
5)Delete element From End
6)Delete element from Given position
 7) Show all element Inserted in Display function()
Program should validate given position before calling given position operation such as Insert or Delete

Sunday, September 2, 2012

Program to find Vowel in given Character in C Program

Program to find Vowel in given Character in C Program


This is program to check given character is under vowel character or not using simple if condition.

/* Program For Detecting Vowel*/
#include<stdio.h>

int main()
{
char a;
printf("\nEnter character\n");
scanf("%c",&a);
if(a=='a'|| a=='e'|| a=='i'|| a=='o'|| a=='u' || a=='A'|| a=='E'|| a=='I'|| a=='O'|| a=='U')
{
  printf("\nThis Alphabet Is Vowel....!\n");
}
else
{ printf("\nThis is Not a Vowel..!\n");
}
return 0;


}

Reverse Number Logic in C program

Reverse Number Logic in C program

This is program for reversing digit of given number by simple logic. Program use While loop for repetitive process.

/* Program For Reverse a Number*/
#include<stdio.h>
#include<math.h>

int main()
{
int no,rem;
printf("\nEnter no\n");
scanf("%d",&no);
int bs=no;
int sum=0;
while(no)
{
rem=no%10;
sum=sum*10+rem;
no=no/10;
}

printf("Reverse Of  %d is \t :%d\n",bs,sum);
return 0;


}



Prime number Logic to check it in C program

Prime number Logic to check it in C program

This program use to check given number is Prime no or not. As prime number not divisible by any number except by itself and one.


/* Program For Prime No*/
#include<stdio.h>

int main()
{
int no,i=2;
printf("\nEnter no\n");
scanf("%d",&no);
int a=1;
while(i<=no/2)
{
if(no%i==0)
  a=0;
i++;
}
if(a==1)
 printf("No %d is Prime No...!\n",no);
else
 printf("No %d is Not a Prime No....!\n",no);
return 0;


}


Check Palindrome Number from given Input Integer C program

Check Palindrome Number from given Input Integer C program

This program use to check given input integer is palindrome or not. Simple just reversing and storing digit to sum then compare it with back one!


/* Program For To Palindrome No. */
#include<stdio.h>
#include<math.h>

int main()
{
int no,rem;
printf("\nEnter no\n");
scanf("%d",&no);
int bs=no;
int sum=0;
while(no)
{
rem=no%10;
sum=sum*10+rem;
no=no/10;
}

if(bs==sum)
 printf("No  %d is Palindrome No.\n",bs);
else
 printf("\nNo %d is not a Palindrome.....!\n",bs);
return 0;


}

Find Maximum Number in array in C program

Find Maximum Number in array in C program


This program to find the maximum number in 1 Dimensional array. Accept number then compare it with previous maximum if true then replace it with new one as simple as that

/* Program to Find Maximum No in array */
#include<stdio.h>

int main()
{
int a[100],n,i,max=0;
printf("enter the no.:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("enter the value of %d no.:",i);
scanf("%d",&a[i]);
if(max<a[i])
max=a[i];
}
printf("\nThe max is %d\n",max);
return 0;
}


Program to Find Leap year in C Program

Program to Find Leap year in C Program


The program for find out the given year under leap year are or not. Leap year logic is simple as the year which divisible by 400 or divisible by 4 and not by 100 .

/* Program For Finding Leap Year*/
#include<stdio.h>

int main()
{
int yr;
printf("\nEnter year\n");
scanf("%d",&yr);
if( (yr%4==0 && yr%100!=0) || yr%400==0)
{
  printf("\n%d is Leap year!\n",yr);
}
else
{ printf("\n%d is Not a Leap year..!\n",yr);
}
return 0;


}

Factorial of a Number Using While loop in C program

Factorial of a Number Using While loop in C program

This is program to find out factorial of a number using simple while loop. this logic use to create a function like fact to find out any factorial of number /Integer.

/* Program For Factorial Of a No.*/
#include<stdio.h>

int main()
{
int no,temp=1;
printf("\nEnter no\n");
scanf("%d",&no);

int fact=1;
while(1)
{
if(temp>no)
 break;
fact=fact*temp;
temp++;
}

printf("Factorial of No    %d \t is :%d\n",no,fact);
return 0;


}



Decimal to Binary Conversion Logic in C program

Decimal to Binary Conversion Logic in C program

This is program which is gives you output as Binary of any Integer. Program Store the binary output as Integer just for reference. We can use it further where required. Decimal to binary needs Math.h Library file to use power function.



/* Program For Decimal to Binary Conversions*/
#include<stdio.h>
#include<math.h>

int main()
{
int no,rem;
printf("\nEnter no\n");
scanf("%d",&no);
int bs=no;
int sum=0;
int pw=0;
while(no)
{
rem=no%2;
sum=sum+rem*(pow(10,pw));
no=no/2;
pw++;

}

printf("Decimal to Binary  of this no  %d \t :%d\n",bs,sum);
return 0;


}


Calculator Operation Using Switch Case C program

Calculator Operation Using Switch Case C program

This program specially for Calculator Operation Using Switch Case C program which can do Addition,Subtractions,Multiplication,Division mathematical operations. It also has Menu to do Such Options in Simple Formats

/* Program For Addition,Subtraction,Division,Multiplication*/
#include<stdio.h>

int main()
{
int a,b,c;

while(1)
{
printf("\n****Choose The Following Options****\n");
printf("-Press 1 for Additions\n");
printf("-Press 2 for Subtractions\n");
printf("-Press 3 for Multiplication\n");
printf("-Press 4 for Divisions\n");
printf("-Press 5 for Exit\n");
scanf("%d",&c);
if(c==5)
 break;
printf("Please Enter two nos:");
scanf("%d %d",&a,&b);
switch(c)
{
case 1:printf("\nAdditions is:\t%d",a+b);
 break;
case 2:printf("\nSubtractions is:\t%d",a-b);
 break;
case 3:printf("\nMultiplication is:\t%d",a*b);
 break;
case 4:printf("\nDivision is:\t%d",a/b);
 break;
default:printf("\n Invalid Choice....!\n");
 continue;
}
}

return 0;


}



Addition of Digits of Given No C Program

Addition of Digits of Given No C Program


This program specially for separating the digits from given more than 2 digit no and add it together . This logic mainly useful at the time of reversing the digit of given no.

/* Program For Adding digits of No*/
#include<stdio.h>

int main()
{
int no,temp;
printf("\nEnter no\n");
scanf("%d",&no);
int bs=no;
int count=;
while(no)
{
temp =no%10;
sum=sum+temp;
no=no/10;

}

printf("Sum of digit  of this no  %d \t :%d\n",bs,sum);
return 0;

}

Check Armstrong Number from given Input Integer C program

Check Armstrong Number from given Input Integer C program

This program is to check given input integer is Armstrong Number or Not such that sum of qube of each digit is equal to that no.

/* Program to check  Armstrong No*/
#include<stdio.h>
#include<math.h>

int main()
{
int no,rem;
printf("\nEnter no\n");
scanf("%d",&no);
int bs=no;
int sum=0;
while(no)
{
rem=no%10;
sum=sum+(pow(rem,3));
no=no/10;


}
if(bs==sum)
 printf("The No %d is Armstrongs No.....!!!\n",bs);
else
 printf("The No %d  is not a Armstrongs NO....!!\n",bs);
return 0;

}


Addition of Two Dimensional Matrix in C program

 Addition of Two Dimensional Matrix in C program


The following program is the example of 2 Dimensional Array for adding it and save it to 3rd Array.

/* Program to Addition of two Matrix */

#include<stdio.h>
void printarry(int ap[2][2]);

int main()
{
int n,i,j;
int a[2][2],b[2][2],c[2][2];
printf("Enter The A matrix");
for(i=0;i<2;i++)
{
 for(j=0;j<2;j++)
{
 scanf("%d",&a[i][j]);
}
}

printf("Enter the B Matrix");
for(i=0;i<2;i++)
{
 for(j=0;j<2;j++)
{
 scanf("%d",&b[i][j]);
}
}

for(i=0;i<2;i++)
{
 for(j=0;j<2;j++)
{
 c[i][j]=a[i][j]+b[i][j];
}
}
printf("\nMatrix A:\n");
printarry(a);
printf("\nMatrix B:\n");
printarry(b);
printf("Addition of Matrix is:\n");
printarry(c);
return 0;
}

void printarry(int ap[2][2])
{
int m,n;
for(m=0;m<2;m++)
{
 for(n=0;n<2;n++)
{
 printf("%d ",ap[m][n]);
}printf("\n");
}
}