# TCS NQT Previous Year Solve | Slot 2 (IV) | Codewindow.in

## Programing Logic

``````//Q1.
public class Main
{

public static void main(String arge[])
{
System.out.println("ab\raba\r");
}
}``````

``````//Q8.
struct emp{
int emp_id;
struct temp *next;

};
while(temp->next!= NULL){
printf("%d", temp -> emp_id);
temp = temp -> next;
}``````

``````//Q9.
class Main{
private int SUM;
public static void main(String args[])
{
Main main = new Main();
}
public void Main(int a, int b){
a = 10;
b = 10;
SUM = a + b;
System.out.println(SUM);
}
}``````
``````//Q10.
#include<stdio.h>
void main(){
int count = 11;
for(int i;i <= count; i++){
pritnf("Time Complexity!!");
}
}``````

## Coding

``````//solution for Q1 in C++
#include <iostream>
using namespace std;

int main() {
int n, k, j, m, p;
cin >> n >> k >> j >> m >> p;
int ans 0;
if(k<0 || n<0 || k<0 || m<0 || p<0)
{
cout << "INVALID INPUT";
return 0;
}
ans = ans + (m/k);
ans = ans + (p/j);
cout << n - ans;
return 0;
}
``````
``````//Q2. Solution in C++
#include <bits/stdc++.h>
#define ll long long;
using namespace std;

int main() {
string par;
cin>>par;
string x;
cin >> x;
if(x == "N"){
cout << "TOTAL MEMBERS:1\n";
cout << "COMMISSION DETAILS\n";
cout << par << ":250 INR\n";
}
else{
string child;
cin >> child;
vector<string>v;
string temp = "";
for(int i = 0l i < child.length(); i++){
if(child[i] == ','){
v.push_back(temp);
temp = "";
}
else if(child[i] != ' ')
temp +=  child[i];
}
v.push_back(temp);
cout << "TOTAL MEMBERS:" << v.size() + 1 << "\n";
cout << "COMMISION DETAILS\n";
cout << par << ":" << v.size()*500 << " INR\n";
for(auto a : v){
cout << a << ":" << "250 INR\n";
}

}
return 0;
}
``````