SynCfusion Interview Question for Applications Developers


Team: 1
Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
3
of 3 vote

#include<stdio.h>
int main()
{

int i=0,j;
char a[] = "elephants";
i= (sizeof(a)-1);
if( (i % 3) != 0)
{
printf("%s \n",a);
return 0;
}
for(j=2;j<i;j=j+3)
printf("%c ",a[j]);

printf("\n");

return 0;
}

- Avi October 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/* Note: GCC Compiler (32 Bit Linux Platform). */

#include<stdio.h>
#include<string.h>
int main()
{
char str[50];
int i=2;
gets(str);
if( strlen(str) % 3 == 0)
{
for( ; i < strlen(str) ; i+=3)
{
printf("%c",str[i]);
}
}
else
printf("%d",strlen(str));
return 0;
}

- Paras Patel October 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void funny(String str){
		if(str.length()%3==0){
			only3(str);
		} else {
			System.out.println(str);
		}
		
	}
	
	public static void only3(String str){
		for(int i = 0; i<str.length(); i++){
			if((i+1)%3==0)
				System.out.print(str.charAt(i));				
		}
			
	}

- Mexican October 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

///// modifications
// 1.> Have to print in multiples of 3 only when string length is greater or equal than 3
// only3 i should increase by 3 each time and no if condition required in only3

public static void funny(String str){
int length=str.length();
if(length >= 3 &&.length%3==0){ // String should be greater or equal than 3 //characters
only3(str);
} else {
System.out.println(str);
}

}

public static void only3(String str){
for(int i = 2; i<str.length(); i=i+3){ // need to print in case multiple of 3 from 3rd //character, no need of having if else condition

System.out.print(str.charAt(i));
}

}

- Avinash October 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static inline bool
divisible_by_three
( unsigned value )
{
	return 0 == value % 3;
}

void
threeLength
( char * string, char * buffer )
{
	if( nullptr == string || nullptr == buffer){
		throw std::invalid_argument("Neither argument can be null");
	}

	unsigned length = strlen( string );

	if( !divisible_by_three(length) ){
		sprintf(buffer, "%s", string);
	}
	else {
		int j = 0;
		for( int i = 2; i < length; i += 3){
			buffer[j++] = string[i];
		}
		buffer[j] = '\0';
	}
}

int 
main
( int argc, char ** argv )
{
	char buffer[50];
        threeLength("elephants", buffer);
        std::cout << buffer << std::endl;
}

- Anonymous November 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Without the cost of finding length. You can continue to find the 3rd character in the string and find the next character and find the current character + 3...all in one iteration.
If next character is null...then the length is multiples of 3...print collected characters
If current char + 3 exists contine
If next char is not null, but current + 3is null then it is not multiple of 3... break and print entire string.

- Chakrapani kotipalli November 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Java :
If string length is not a multiple of given number(c=3), return string as is
otherwise, step through string starting at index c-1, incrementing index by c and
get character at those indices and construct a return value.

public String printPositional(String str, int c) {
		if (str.length() % c != 0)
			return str;
		StringBuilder sb = new StringBuilder();
		for(int i=c-1;i<str.length();i+=c){
			sb.append(str.charAt(i));
		}
		return sb.toString();
	}

- neojava January 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.*;
public class str {
public static void main(String args[])throws IOException
{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the string");
String nu=br.readLine();
int ch=nu.length();

for(int i=0;i<ch;i++){
System.out.print(nu.charAt(i));
}
for(int k=2;k<ch;)
{
char ab=nu.charAt(k);
System.out.print(ab);
k=k+3;
}
}
}

- Anonymous February 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Don't get complicated its just a simple.

using System;
using System.Linq;

namespace SyncTest
{
class Program
{
static void Main(string[] args)
{

string input;


input = Console.ReadLine();

if(input.Length%3==0)
{
Console.WriteLine(" Enter an input string : ");
Console.WriteLine(input);
}


else
{
int j;
for( j=0; j<input.Length; j++)
{
Console.WriteLine(input.ElementAtOrDefault(j + 2));
j=j + 2;

}


}

Console.ReadKey();
}
}
}

- Aravind July 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Linq;

namespace SyncTest
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string input;
            

            input = Console.ReadLine();

            if(input.Length%3==0)
            {
                Console.WriteLine(" Enter an input string  : ");
                Console.WriteLine(input);
            }


            else
            {
                int j;
                for( j=0; j<input.Length; j++)
                {
                    Console.WriteLine(input.ElementAtOrDefault(j + 2));
                    j=j + 2;

                }

              
            }

            Console.ReadKey();
        }
    }
}

- Aravind A July 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
int a,i;
char c[8]="elephants";
printf("the sentance");
scanf("%s /n",c);
a=sizeof(c);
for(i=2;i<=a;i=i+3)
printf("%c",c[i]);
}

- jack polt March 11, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Program
{
static void Main(string[] args)
{
string s = "Elephants";
char[] sen = s.ToCharArray(); // converting string into char array
int num = 3;
int l = sen.Length; // l contains the length of sen
if(l%2!=0)
{
for(int i=num-1;i<sen.Length;i=i+3)
{
Console.Write(sen[i]);
}
}
Console.ReadLine();

}
}

- MathiVanan November 29, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Program
    {
        static void Main(string[] args)
        {
            string s = "Elephants";
            char[] sen = s.ToCharArray();
            int num = 3;
            int l = sen.Length;
            if(l%2!=0)
            {
                for(int i=num-1;i<sen.Length;i=i+3)
                {
                    Console.Write(sen[i]);
                }
            }
            Console.ReadLine();

        }
    }

- MathiVanan November 29, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class StringMultiple {

public static void main(String[] args) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the String");
String str=br.readLine();
int a=str.length();
System.out.println(a);
if(a%3==0)
{
char[] strArray=str.toCharArray();
for(int i=2;i<a;)
{
System.out.println(strArray[i]);
i=i+3;
}
}
else
{
System.out.println(str);
}
}
}

- Jayaraman Ayyanar December 04, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class StringMultiple {

public static void main(String[] args) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the String");
String str=br.readLine();
int a=str.length();
System.out.println(a);
if(a%3==0)
{
char[] strArray=str.toCharArray();
for(int i=2;i<a;)
{
System.out.println(strArray[i]);
i=i+3;
}
}
else
{
System.out.println(str);
}
}
}

- Jayaraman December 04, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Str=input ("enter the string");
If(len(str)%3==0):
Result=Str[::3]
Print(Result.lower())
else:
print(Str)

- Anonymous November 21, 2023 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More