Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

Programs Questions and Answers



    Question :: 341
    Write a program to remove duplicates from a given string

    Input : qqq44inttttervvviiewwww


    Output : q4intervw

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C  
     
    #include <stdio.h>
    #include <string.h>
    int main()
    {
        char str[] = "qqq44inttttervvviieewwww......commm";
        removeDuplicate(str);
        printf("%s",str);
        return 0;
    }
    void removeDuplicate (char *str)
    {
        char hash[256] = {0};
        int x=0, y = 0;
        char temp;
        while (*(str+y) != '\0')
        {
            temp = *(str+y);
            if (hash[temp] == 0)
            {
                hash[temp]=1;
                *(str+x) = *(str+y);
                x++;
            }
            y++;
        }
        *(str+x)='\0';
    }

    Tags:No Tags on this question yet!

    Question :: 342
    Write an efficient program to remove characters from the first string which are present in the second string

    Input : str1 = q4interview.com mask = iewc


    Output : q4ntrv.om

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C  
     
    #include <stdio.h>
    char *removeChar(char *str, char *mask);
    int main()
    {
    char str[] = "q4interview.com";
    char *mask = "iewc";
    char *output = removeChar(str, mask);
    printf("%s",output);
    }

    char *removeChar(char *str, char *mask)
    {
        char arr[256] = {0}, temp;
        int i = 0,j=0, k=0;
        while (*(mask+i))
        {
            arr[mask[i]]++;
            i++;
        }
        while (*(str+k))
        {
            temp = *(str+k);
            if (arr[temp] == 0)
            {
                *(str+j) = *(str+k);
                j++;
            }
            k++;
        }
        *(str+j)='\0';
        return str;
    }

    Tags:No Tags on this question yet!

    Question :: 343
    Write an efficient program to toggle all the bits of a number except k-th bit.

    Input : n = 4294967295, k = 0


    Output : 1

    View Answer |  Bitwise Operator |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C  
     
    #include <stdio.h>
    int main()
    {
    unsigned int n = 4294967295, k = 0;
    printf("%d",~(n^(1<<0)));
    }

    Tags:No Tags on this question yet!

    Question :: 344
    Write an efficient program to set the rightmost unset bit.

    Input : 10


    Output : 11

    View Answer |  Bitwise Operator |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C  
     
    #include <stdio.h>
    
    int main()
    {
    int z = 21;
    setUnsitBit(z);
    }

    void setUnsitBit(int y)
    {
    int p=y,x = 0;

    if (y == 0)
    return;
    if ((y&(y+1)) == 0)
    return;

    while (p > 0)
    {
    if (((y>>x) & 1) == 0)
    break;
    x++;
    p = p/2;
    }
    printf("%d",(y |=1<<x));
    }

    Tags:No Tags on this question yet!

    Question :: 345
    Write an efficient program to toggle the bits in the given range

    Input : Number n = 17 range l = 2, r = 5


    Output : 23

    View Answer |  Bitwise Operator |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience, Fresher
    Answer In: C  
     
    #include <stdio.h>
    
    int main()
    {
    int z = 50;
    setUnsitBit(z, 2,4);
    }

    void setUnsitBit(int y,int l, int m)
    {
        int i;
       i=(l>m)?m-1:l-1;
       m = (m>l) ?m:l;
    for (;i <=m;i++)
    y^=(1<<i);

    printf ("%d",y);
    }

    Tags:No Tags on this question yet!

    Question :: 346
    Find all the Word Greater or equals to 3 characters and for Every Character Write The ASCII of First and Last alphabet . Total it and Check Whether the Number is Prime or not. Example : ASCII of R : 82 ASCII of M : 77 ASCII of B : 66 ASCII of y : 121 Sum up All these and check Wether its Prime or Not ?

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: JAVA  
     
    import java.util.Scanner;
    

    class dd
    {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String sentence = sc.nextLine();
            String arr[]=sentence.split(" ");
            int j;
            for(j=0;j<arr.length;j++)
            {
                if(arr[j].length()>=3)
                {
                    int first_letter=(int)arr[j].charAt(0);
                    int last_letter=(int)arr[j].charAt(arr[j].length()-1);
                    System.out.println(first_letter+last_letter);
                    int num=first_letter+last_letter;
                    boolean flag = false;
            for(int i = 2; i <= num/2; i++)
            {
                if(num % i == 0)
                {
                    flag = true;
                    break;
                }
            }

            if (!flag)
                System.out.println("It is a prime number.");
            else
                System.out.println("It is not a prime number.");
                }
            }
            sc.close();
        }
    }

    Tags:No Tags on this question yet!

    Question :: 347
    WAP to Input a String either in C/JAVA . Find all the Words Less than 3 Characters. Example : Input : Ram is a Boy The Words Less than 3 Characters: is a The Word Greater or equals to 4 characters: Ram and Boy

    Input : Ram is a Boy


    Output : The Words Less than 3 Characters: is a The Word Greater or equals to 4 characters: Ram and Boy

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C  
     
    #include<stdio.h>
    
    #include<string.h>
    int main()
    {
        int i,j,k=0,count=0,len;
        char str[1000];
        gets(str);
        len = strlen(str);
        for(i=0;i<len;i++)
        {
            if(str[i]==' ')
            {
                j=i-1;
                if(j-k<2)
                {
                    while(k <= j)
                    {
                        printf("%c",str[k]);
                        k++;
                    }
                    printf("\n");
                }
                k = i+1;
            }
            if(i==len-1)
            {
                if(k-i<2)
                while(k <= i)
                {
                        printf("%c",str[k]);
                        k++;
                }
            }
        }
        return 0;
    }

    Tags:No Tags on this question yet!

    Question :: 348
    WAP in C/JAVA taking Input from a File and Counting the Number os Spaces , Capital Letters, Small Letters , Vowels , Special Characters etc.

    Input : NA


    Output : NA

    Answer In: JAVA  
     
    import java.io.*; 
    
    public class Count{ 



        static void countCharacterType(String str) 

        { 

         

            int vowels = 0, consonant = 0, specialChar = 0,  

                digit = 0; 

          

          

            for (int i = 0; i < str.length(); i++) { 

                 char ch = str.charAt(i); 

          

                if ( (ch >= 'a' && ch <= 'z') ||  

                    (ch >= 'A' && ch <= 'Z') ) { 

          

                    ch = Character.toLowerCase(ch);; 

          

                    if (ch == 'a' || ch == 'e' || ch == 'i' || 

                        ch == 'o' || ch == 'u') 

                        vowels++; 

                    else

                        consonant++; 

                } 

                else if (ch >= '0' && ch <= '9') 

                    digit++; 

                else

                    specialChar++; 

            } 

              

            System.out.println("Vowels: " + vowels); 

            System.out.println("Consonant: " + consonant); 

            System.out.println("Digit: " + digit); 

            System.out.println("Special Character: " + specialChar); 

        } 



        static public void main (String[] args) 

        { 

            String str = "Mynameis@45; 

              

            countCharacterType(str); 

        } 
    }

    Tags:No Tags on this question yet!