kpl2tilwani91
BAN USER#include<stdio.h>
main()
{
int a[10],i,j,sum,count=0;
printf("enter the sum you want to check : \n");
scanf("%d",&sum);
printf("enter the element of array : \n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if((i!=j) && (a[i] + a[j] == sum))
count++;
}
}
if(count>0)
printf("True\n");
else
printf("False\n");
}
put the main code into the function and call that function using arguments.
- kpl2tilwani91 July 09, 2013#include<stdio.h>
main()
{
int a[10],i,j,k,sum;
printf("enter the sum : \n");
scanf("%d",&sum);
printf("Enter the elements of array : \n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
for(k=0;k<10;k++)
{
if((i!=j) && (i!=k) && (j!=k) && (a[i]+a[j]+a[k] == sum))
printf("%d\t%d\t%d\n",i,j,k);
}
}
}
}
bool isBST(struct node* root)
{
static struct node *prev = NULL;
// traverse the tree in inorder fashion and keep track of prev node
if (root)
{
if (!isBST(root->left))
return false;
// Allows only distinct valued nodes
if (prev != NULL && root->data <= prev->data)
return false;
prev = root;
return isBST(root->right);
}
return true;
}
create the function and put that code into it .. !!!
- kpl2tilwani91 July 09, 2013Thanking You