Domanda di colloquio di Nagarro

Write a program to convert a string written as JAVA variable to C++ variable and vice-versa. Input : this_is_a_variable Output: thisIsAVariable

Risposte di colloquio

Anonimo

16 gen 2022

new_s = "" i = 0 while i < len(s): if s[i] == "_": new_s = new_s + (s[i] + s[i + 1]).replace(s[i] + s[i + 1], s[i + 1].upper()) i = i + 2 else: new_s = new_s + s[i] i = i + 1 print(new_s)

6

Anonimo

19 mag 2021

String s = "thisIsAVariable"; //INPUT char ch[] = s.toCharArray(); // 1st approach String str = ""; for (int i = 0; i < ch.length; i++) { if (Character.isUpperCase(ch[i])) { str += "_"; str += ch[i]; } else str += ch[i]; } System.out.println(str.toLowerCase()); //O/P: this_is_a_variable

35

Anonimo

21 ott 2019

String Manipulation

37

Anonimo

19 mag 2021

String result=""; String input = "this_is_a_variable"; char c[] = input.toCharArray(); for(int i=0;i

28