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.

Programs Questions and Answers



  • 1. Write a program to print next to the last word of a sentence.

    Input : What is your name,   Output : your

  • Answer In: C   C++   JAVA   PHP  
     
    import java.io.*;
    class test
    {
        public static void main(String args[]) throws IOException 
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s;
    String str,str1;
    int c=0;
    s=br.readLine();
    /* With string compariosons there may be an arrayoutofbounds exception rather that statement can be replaced with this */
            while((c<=s.length()))
            {
                /* One Method to find Second last Word */
                
                str=s.substring(0,s.lastIndexOf(" "));
                str1=str.substring(str.lastIndexOf(" "),str.length());     
    c  ;
    if(c==1)
    System.out.print(str1);            
            }
        }
    }
    Tags:

    IBM 

  • 2. Write a program to remove the vowels from the input string.

    Input : What is your name?,   Output : Wht s yr nm?

  • Answer In: C   C++   JAVA   PHP   PYTHON  
     
    <pre>
    <code>def anti_vowel(c):
        newstr = c
        vowels = ('a', 'e', 'i', 'o', 'u')
        for x in c.lower():
            if x in vowels:
                newstr = newstr.replace(x,"")
    </code></pre>
    Tags:

    IBM 

  • 3. Write a program to convert uppercase to lower case and vice versa of a given string or sentence

    Input : WhAT iS YouR nAme?,   Output : wHat Is yOUr NaME?

  • Answer In: C++   JAVA   PHP  
     
    import java.util.*;
    import java.lang.*;
    import java.io.*;


    class LowerToUpper
    {
        public static void main (String[] args)
        {
            int i,len;
            char ch;
            Scanner sc=new Scanner(System.in);
            System.out.println("Enter String: ");
            String str=sc.nextLine();
            len=str.length();
            for(i=0;i<len;i++)
            {
                ch=str.charAt(i);
                if(Character.isUpperCase(ch))
                    System.out.print(Character.toLowerCase(ch));
                else
                    System.out.print(Character.toUpperCase(ch));
            }
        }
    }
    Tags:

    IBM Global Edge 

  • 4. Write a program to reverse the string?

    Input : What is your name?,   Output : name? your is what OR ?eman ruoy si tahw

  • Answer In: C   C++   JAVA   PHP  
     
    <!DOCTYPE html>
    <html>
    <body>
    <?php 
    function Reverse() {
        
    // input string
        
    $str ="what is your name";                                     
        echo  
    "Input string is :" $str."<br/>";
         
    // conversion of string into array
        
    $arr str_split($str); 
        
    // counting lengh of array 
        
    $arrlength=count ($arr); 
        
    // initialising an empty array and its initial index    
        
    $arrc=array(); $j=0;    
       
    // loop for reading the input array    
        
    for( $x$arrlength$x>=0$x--)                                                 
        {
            
    // reversing the array
            
    $arrc[$j]=$arr$x];                                                       
            
    $j++;
        }
           
    // conversion of array into string
           
    $nameimplode ("",$arrc);    
           
    // printing string in reverse order       
           
    echo $name;                                                                        
    }
    Reverse();
    ?>  

    </body>
    </html>
    Tags:

    IBM PEOL 

  • 5. Write a program to print the desired character from a string or search a char in a string.

    Input : What is your name?(searching a),   Output : The Position Of a is 3

  • Answer In: C   C++   JAVA   PHP  
     
    #include <stdio.h>
    #include <string.h>
    #include<iostream>
    using namespace std;
     
    int main()
    {
        char a, word[50];
        int i, freq = 0, flag = 0;
     
        printf("Enter character: ");
        scanf("%c", &a);
        printf("Now enter the word: ");
        scanf("%s", word);
        printf("Positions of '%c' in %s are: ", a, word);
        for (i = 0; i < strlen(word); i++)
        {
            if (word[i] == a)
            {
                flag = 1;
                printf("%d  ", i + 1);
                freq++;
            }
        }
        if (flag)
        {
            printf("\nCharacter '%c' occured for %d times.\n", a, freq);
        }
        else
        {
            printf("None\n");
        }
     
        return 0;
    }
     
    int main()
    {
        char a, word[50];
        int i, freq = 0, flag = 0;
     
        printf("Enter character: ");
        scanf("%c", &a);
        printf("Now enter the word: ");
        scanf("%s", word);
        printf("Positions of '%c' in %s are: ", a, word);
        for (i = 0; i < strlen(word); i++)
        {
            if (word[i] == a)
            {
                flag = 1;
                printf("%d  ", i + 1);
                freq++;
            }
        }
        if (flag)
        {
            printf("\nCharacter '%c' occured for %d times.\n", a, freq);
        }
        else
        {
            printf("None\n");
        }
     
        return 0;
    }
    Tags:

    IBM 

  • 6. Write a program to transform strings of lowercase alphabet characters by replacing each letter
    with the subsequent character in the english alphabet.

    Input : hello,   Output : ifmmp

  • Answer In: JAVA   PHP  
     
    package com.pckg;

    import java.util.Scanner;

    public class SubsequenceCharacter {
        public static void main(String[] args) {
            System.out.println("Enter String  : ");
            Scanner in = new Scanner(System.in);
            String str = in.nextLine();
            String newString = "";
            for (int i = 0; i < str.length(); i++  ) {
                int ascii = (int)str.charAt(i);
                char newChar = (char)(ascii +  1);
                newString = newString   newChar;
            }
            System.out.println("New String : " + newString);
        }
    }
    Tags:

    IBM 

  • 7. Write a program to to count number of vowels and consonants in a string.

    Input : ,   Output :

  • Answer In: C   C++   JAVA   PHP  
     
    import java.io.*;
    class q5vowels
    {
        public static void main(String args[]) throws IOException
        {
            String str;
            int vowels = 0, digits = 0, blanks = 0;
            char ch;

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            System.out.print("Enter a String : ");
            str = br.readLine();

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

                if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || 
                ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
                    vowels++ ;
                else if(Character.isDigit(ch))
                    digits++ ;
                else if(Character.isWhitespace(ch))
                    blanks++ ;
            }

            System.out.println("Vowels : "+ vowels);
            System.out.println("Digits : "+ digits);
            System.out.println("Blanks : "+ blanks);
        }
    }
    Tags:

    IBM 

  • 8. Write a program to Convert a String to Camel Case.
    Hint: In camel case, we capitalise the first letter of each word.

    Input : hello world,   Output : Hello World

  • Answer In: JAVA   PHP  
     
    <!DOCTYPE html>
    <html>
    <body>

    <?php 
    function Camel() {
        
    // input string
        
    $arr ="what is your name";                                         
        echo  
    "Input string is :" $arr."<br/>";
        
    // function to convert in Camel notation
        
    $camel =ucwords ($arr)  ;                                           
        
    // printing string in Camel Notation 
        
    echo $camel;                                                               
    }
     
    // function calling
    Camel() ;                                                      
    ?>  

    </body>
    </html>
    Tags:

    IBM 

  • 9.  Write a program to converting a String to Sentence Case.
    Hint: In sentence case, the first letter of each sentence is capitalized. 

    Input : ,   Output :

  • Answer In: C   C++   JAVA   PHP  
     
    #include<iostream>
    #include<conio.h>
    #include<stdio.h>
    #include<ctype.h>

    void main()
    {
    clrscr();
    int i;
    char a[30];
    cout<<“Enter a string:”;
    gets(a);
    for(i=0;a[i]!=’’;++i)
    {
    if(i==0)
    {
    if(islower(a[i]))
    a[i]=toupper(a[i]);
    }
    else
    {
    if(a[i]!=’ ‘)
    {
    if(isupper(a[i]))
    a[i]=tolower(a[i]);
    }
    else
    {
    i++;
    if(islower(a[i]))
    a[i]=toupper(a[i]);
    }
    }
    }
    cout<<“nnNew string is: “<<a;
    getch();
    }

    Tags:

    IBM 

  • 10. Write a program to convert the String to its toggle form.

    Input : ,   Output :

  • Answer In: C   C++   JAVA   PHP  
     
    import java.util.Scanner;

    public class CaseManipulation {

       public static String toToggleCase(String inputString) {
           String result = "";
           for (int i = 0; i < inputString.length(); i  ) {
               char currentChar = inputString.charAt(i);
               if (Character.isUpperCase(currentChar)) {
                   char currentCharToLowerCase = Character.toLowerCase(currentChar);
                   result = result   currentCharToLowerCase;
               } else {
                   char currentCharToUpperCase = Character.toUpperCase(currentChar);
                   result = result   currentCharToUpperCase;
               }
           }
           return result;
       }

    public static void main(String[] args) {
           Scanner scanner = new Scanner(System.in);
           System.out.print("Enter an input String: ");
           String inputString = scanner.nextLine();
            System.out.println("Toggle Case: "   toToggleCase(inputString));
       }
    }
    Tags:

    IBM PEOL