If no. of Binary digits is greater than the number itself

 import java.util.Scanner;

public class Check{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.print("Enter the Number: ");
int n = sc.nextInt();
for (int i = 2; i<= n;i++){
String bin = load_binary(i);
if (n == bin.length()){
System.out.println(bin);
}
}
}
public static String load_binary(int i){
int n = i;
int bin = 0;
while (n > 0){
bin = (bin*10)+n%2;
n/=2;
}
String bin2 = Integer.toString(bin);
return bin2;
}
}

Comments

  1. #include
    void push(int* stack,int* top,int size, int element){
    if (*(stack+*top) == size){
    printf("Stack Overflow!");
    }
    *(stack + *(top)) = element;
    }
    int main(){
    char Q[20], stack[20];
    char precedence[][] = {{'*','/'},{'+','-'}};
    printf("Enter the expression: ");
    scanf("%s",Q);
    /*
    *check for opening bracket
    *When operator encountered then pop the stack until opening bracket is encounterd
    **if that operator has high precedence than the encountered one then pop the stack one and append on the p
    *if ')' is encountered then pop the stack until closing bracket is encounterd.*/
    char P[20];
    for (int i = 0; i < 20; i++){

    }

    }

    ReplyDelete
  2. https://stackoverflow.com/questions/9709209/html-select-only-one-checkbox-in-a-group

    ReplyDelete
  3. Welcome to the Chat Everyone !!!

    ReplyDelete
  4. HAM ISSE USE KARKE BAAT KARENGE

    ReplyDelete
  5. HEY..........WHATS UP

    ReplyDelete
  6. AGENT 10 HERE .....EVERYONE ENTER TO THIS BLOGSPOT RIGHT NOW

    ReplyDelete
  7. #include
    #include
    struct node{
    int data;
    struct node* next;
    }*head,*node1,*node2,*tail;
    void insert(struct node* nd,struct node* ndNxt){
    printf("Enter the data for the node: ");
    int element;
    scanf("%d",&element);
    nd->data = element;
    nd->next = ndNxt;
    }
    int main(){
    printf("***Welcome to linked Lists***");
    int ch;
    printf("\nEnter 1 to insert: ");
    scanf("%d",&ch);
    switch(ch){
    case 1:
    head = (struct node *)malloc(sizeof(struct node));
    node1 = (struct node *)malloc(sizeof(struct node));
    node2 = (struct node *)malloc(sizeof(struct node));
    tail = (struct node *)malloc(sizeof(struct node));
    insert(head, node1);
    insert(node1, node2);
    insert(node2, tail);
    printf("Enter the tail data: ");
    scanf("%d",&tail->data);
    tail->next=NULL;
    printf("\nhead = %d",head->data);
    printf("\nnode1 = %d",head->next->data);
    printf("\nnode2 = %d",head->next->next->data);
    printf("\ntail = %d",head->next->next->next->data);
    break;

    }
    }

    ReplyDelete
  8. https://gist.github.com/a6a4c4bc737be4a03742f3ce39e4c65d.git

    ReplyDelete

Post a Comment