Recent Articles

Logic - How to check if a character is a vowel in a given String?
6 days ago

Let us say we are given a string and asked to print the vowels in the string. Vowels can be in upper case AEIOU or in lower case aeiou. Here instead of comparing all 10 values (5 in upper case and 5 in lower case), we convert the character to be compared to lower case and do the comparison. So we define a method isVowel to check if a given character is a vowel or not.

Let us explore the solutions in various programming languages.

Solution in C Programming Language:

#include<stdio.h>

int isVowel(char ch){
   ch = tolower(ch);
   return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}

int main()
{
   char str[1001];
   scanf("%s",str);
   for(int index=0; str[index] != '\0'; index++){
        if(isVowel(str[index])){
            printf("%c",str[index]);
        }
   }
}

Solution in Java Programming Language:

import java.util.*;

public class Hello {

    private static boolean isVowel(char ch) {
        ch = Character.toLowerCase(ch);
        return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
    }

    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        for (char ch : str.toCharArray()) {
            if (isVowel(ch)) {
                System.out.print(ch);
            }
        }

    }

}

Solution in Python Programming Language:

def isVowel(ch):
    ch = ch.lower()
    return ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u'
    

inputstr=input().strip();
for ch in inputstr:
    if isVowel(ch):
        print(ch, end='')

Solution in C++ Programming Language:

int isVowel(char ch)
{
    ch = tolower(ch);
    return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}

int main()
{
    char str[1001];
    cin >> str;
    for(char *ptr = str; *ptr; ptr++)
    {
        if(isVowel(*ptr))
        {
            cout << *ptr;
        }
    }
    return 0;
}

 

View

How to scan (accept) a single character in Java?
1 month ago

There is NO method as nextChar() in java.util.Scanner class in Java. We need to use the next() method to read a single character as a string and then use charAt(0) to get the first character of that string.

Scanner scanner = new Scanner(System.in);
String str = scanner.next();
char ch = str.charAt(0);

or

Scanner scanner = new Scanner(System.in);
char ch = scanner.next().charAt(0);

The below program accepts a character and prints the same character as the output.

import java.util.*;

public class Hello {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char ch = scanner.next().charAt(0);
        System.out.println(ch);
    }

}

Note: Here we are reading the single character as a string and getting the first character using charAt(0) from that string.

View

How to get a space separated String as input in C
1 month ago

Accepting space separated String value in C Programming Language:

In C, using %s in scanf accepts a string value only till the first non-white space character. For example, the below program will print only One when One Two Three is given as input.

#include <stdio.h>

int main()
{
    char inputStringValue[101];
    scanf("%s",inputStringValue);
    printf("%s",inputStringValue);
}

So to accept a string with space we can use the following approaches.

Approach 1:
Use fgets to accept the input string value (which has one or more spaces in it).
This program will print One Two Three when One Two Three is given as input.

#include <stdio.h>

int main()
{
    char inputStringValue[101];
    fgets(inputStringValue,100,stdin);
    printf("%s",inputStringValue);
}

 

Approach 2:
Use ^\n to instruct the scanf to read till a new line character is encountered in the input value.

#include <stdio.h>

int main()
{
    char inputStringValue[101];
    scanf("%[^\n]",inputStringValue);
    printf("%s",inputStringValue);
}

 

View

KickStart - SkillRack initiative for students to learn programming
1 month ago

The portal http://kickstart.skillrack.com/ is an initiative from SkillRack for students who wish to learn programming. Over 1000+ programs will be published. No login or payment is required.

SOLUTION is provided for all programs in any one of the programming languages - C, Java or Python 3.x

Visit http://kickstart.skillrack.com/

 

View

C/Java PROGRAMMING KICKSTART in Bengaluru (Bangalore)
3 months ago

SkillRack.com is an online platform to learn from programming basics to enhance your skills till competitive programming.

SkillRack is arranging a free half day orientation session for the 2018 batch students who are not yet placed. The session will consist of the following.

- 10 programming concepts and solving related programs asked in major IT companies hands-on (You will solve the programs using www.skillrack.com) and SkillRack mentors will assist you.

When is this session happening?
- The session will be happening on 11th October 2018 from 10:00 am to 12:30 noon at our Bengaluru office address mentioned below.

Address

What is the cost involved?
- The orientation session is free and you need not pay for it.

Why is the session free (as every one has a business motive)?
- We are doing it free as a promotional activity

What's the count of participants allowed?
- Only 30 are allowed in a session. Hence please register at this Google Form link entering your email and phone number. We will email and confirm the approval of your registration.

The Google Form link is  https://goo.gl/forms/tzrvQmJNqrWiyIPE2

What should you bring?
- Bring your own laptop or two can share one laptop (if your friend has one)
- You must your mobile HOTSPOT to connect to internet and solve the programs using www.skillrack.com

View

TCS NINJA Test Pattern 2018-2019 Batch
5 months ago

TCS Ninja test pattern for 2019 Batch students to be conducted in September 2018

MCQ - Section 1:
Session 1: Contains 20 questions related to Quantitative Aptitude, Reasoning (Duration 40 minutes). (This session will not be there for students who have got 75% in 10th, 12th and in their college. This is applicable only students from accredited colleges)
Session 2: Contains 10 questions related to English Verbal Reasoning and Proficiency (Duration 10 minutes).
Session 3: Contains 10 questions related to C programming proficiency (Duration 20 minutes)

Programming - Section 2:
Contains 1 Programming Challenge to be solved in 20 minutes.

LOG into www.SkillRack.com to take TCS NInja tests.

View

Medals - When Gold, Silver and Bronze are awarded?
8 months ago

Bronze medals are awarded when the following tasks are fulfilled.
- 1 medal for solving a Daily Challenge
- 1 medal for scoring 40% or above in any MCQ Aptitude Test
- 2 medals for scoring 60% or above in any MCQ Aptitude Test
- 1 medal for posting approved solution in Discussion Forum
- 1 medal for posting approved Interview Experience in Discussion Forum
- 1 medal for posting approved On Campus Event in Discussion Forum
- 1 medal for solving a challenge in Programming Test
- 2 medals for completing a unit in Programming Course (Like C, Java & Python)
- 5 medals for completing a programming track (Set of 10 problems)
- 2 medals for completing a unit in Aptitude Course
- 1 medal for solving exactly one challenge in CPL Programming Test


Silver medals are awarded when the following tasks are fulfilled.
- 1 medal for solving exactly two challenges in CPL Programming Test


Gold medals are awarded when the following tasks are fulfilled.
- 1 medal for solving all three challenges in CPL Programming Test

 

More tasks will be added when new features are introduced or based on the feedback from users.

View

Reverse a String in Java
8 months ago

In this program we will reverse an input String and print the reversed String.

We will use StringBuilder to achieve the reversal.

import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        
        //We will reverse the String using StringBuilder.
        StringBuilder sb=new StringBuilder(input);
       
        //Now reverse the input value and print 
        System.out.println(sb.reverse().toString());
       
    }
}

 

View

Program to print Fibonacci series in Java
8 months ago

In this article we will look at a Java program that will print Fibonacci series upto a certain number of terms using recursion.

The number of terms is passed as input.

import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int termsCount = sc.nextInt();
        int sum = 1, curr = 1;
        System.out.println(curr);
        fibonacci(curr, sum, termsCount);
    }

    private static void fibonacci(int curr, int sum, int remainingTerms) {
        if (remainingTerms != 1) {
            System.out.print(sum);
            fibonacci(sum, curr + sum, remainingTerms - 1);
        }
    }
}

 

View

INFOSYS Test Pattern 2019 Batch - LATEST
8 months ago

INFOSYS Campus Hiring TEST Pattern (The campus hiring online test pattern has not been changed for the past 4 years. The latest Infosys pattern for 2018 - 2019 graduation batch is given below.

Test Duration: 95 minutes
Total Questions: 65
Sectional Cut-Off: Yes it is present
Negative Marking: No (There is no negative marking for all the three sections)

3 Sections in the test are
Section 1: Quantitative/CryptArithmetic/Analytical Puzzles: 10 questions in 35 minutes
Section 2: Logical/Analytical Reasoning : 15 questions in 25 minutes
Section 3: Verbal :  40 questions in 35 minutes.

But Infosys changes the question by preparing different question sets for each event. So while you will get the similar pattern of questions, it is difficult to get the exact questions repeated.

Section 1 Quantitative/CryptArithmetic/Analytical Puzzles Topics:
 - Time Speed & Distance
 - Crypt Arithmetic
 - Percentages
 - Profit & Loss
 - Mensuration/Geometry
 - Permutation & Combination
 - One analytical puzzle where data is given and 3-4 questions are asked based on the given data.

Observation: 5-6 questions will be easy to solve. Remaining questions will be time consuming - particularly crypt arithmetic and the analytical puzzle questions.
 
Section 2 Logical/Analytical Reasoning Topics:
 - Data Interpretation / Logical Puzzle
 - Logically Following Options/ Syllogism questions modified in a different manner
 - Data Suffiency
 
Observation: Easiest section to solve if you have practised similar type of questions earlier.
 
Section 3 Verbal Topics:
 - Reading Comprehension
 - Theme Detection (Inference from a passage)
 - Sentence Correction / Improvement
 - Sentence Completion (Fill in the blanks type)
 - Remaining questions from a variety of topics like One word substitution, Synonyms and Antonyms etc but the above 4 are asked often.

Observation:
The verbal section contains lengthy paragraphs for Reading Comprehension and is time consuming. The time to be spent on a single question (40 to be answered in 35 minutes) is a mere 52 seconds. Also the theme detection questions consists of paragraphs which take time to read. So one must be grazing fast through the paragraphs and answer really quick (Must not spend more time on a single question as time management is important in Verbal section)

To practice INFOSYS pattern MOCK TESTS, please log into www.SkillRack.com

 

View