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...

  Take Quiz (Monsoon) Beta Version !!
  Do You have Qs. in your Mind ??? Ask it as Qs. or MCQs or create it as polling Live Now !!

Programs Questions and Answers



    1 / 348

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

    Input : What is your name


    Output : your

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Experience
    Answer In: C   C++   JAVA   PHP   PYTHON  
     
    <p>import java.io.BufferedReader;<br />
    import java.io.IOException;<br />
    import java.io.InputStreamReader;</p>

    <p>public class StringWordIBM <br />
    {</p>

    <p>  Â  public static void main(String[] args) throws IOException <br />
      Â  {<br />
      Â  Â  Â  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));<br />
      Â  Â  Â  String str;<br />
      Â  Â  Â  System.out.println("Enter the String : ");<br />
      Â  Â  Â  str=br.readLine();<br />
      Â  Â  Â  System.out.println(str);<br />
      Â  Â  Â  String s[] = str.split(" ");<br />
      Â  Â  Â  System.out.println("Splitted string : ");<br />
      Â  Â  Â  for(int i=0;i<s.length;i  )<br />
      Â  Â  Â  {<br />
      Â  Â  Â  Â  Â  System.out.println(s[i]);<br />
      Â  Â  Â  Â  Â Â <br />
      Â  Â  Â  }<br />
      Â  Â  Â  System.out.println("Second Last word of String is : " s[s.length-2]);<br />
      Â  }<br />
      Â Â <br />
    }</p>

    Tags:IBM TCS

    2 / 348

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

    Input : What is your name?


    Output : Wht s yr nm?

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    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 / 348

    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?

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C++   JAVA   PHP   PYTHON  
     
    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));
            }
        }
    }

    4 / 348

    Write a program to reverse the string?

    Input : What is your name?


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

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP   PYTHON  
     
    <!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 / 348

    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

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP   PYTHON  
     
    #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 / 348

    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

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: JAVA   PHP   PYTHON  
     
    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 / 348

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

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP   PYTHON  
     
    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 / 348

    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

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: JAVA   PHP   PYTHON  
     
    <!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 / 348

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

    Input : NA


    Output : NA

    View Answer |  Basics |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    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 / 348

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

    Input : NA


    Output : NA

    View Answer |  Strings |  Discuss in Forum | Add to Reading List To Reading List | Asked In |  Fresher
    Answer In: C   C++   JAVA   PHP   PYTHON  
     
    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