#Basic
Problem:-
Tags:-
#basic #basicspoj
#spoj #spojsolution #codechef #hackerrank #codingsolution #googledeveloper #microsoftdeveloper #tcsdeveloper #solution #clanguage #java #cpp #coding #japandeveloper #usadeveloper #indiandeveloper #usa #japan #india #deveper #programer #coder
Problem:-
Input
Given a positive integer 0 < x < 50.
Output
Print one word: Wo...ow (letter o must be repeted x times).
Example 1:-
Input: 1 Output: Wow
Example 2
Input: 7 Output: Wooooooow
Solution:-
Solution by using C language:-
#include<stdio.h>
int main()
{
int x,n;
scanf("%i",&n);
printf("W");
for(x=1;x<=n;x++)
{
printf("o",x);
}
printf("w");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int i,n;
cin >> n;
cout << "W";
for(i = 1; i <= n; i++)
{
cout << "o", i;
}
cout << "w";
return 0;
}
Solution by using JAVA language:-
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int x,n;
Scanner num = new Scanner(System.in);
n = num.nextInt();
System.out.print("W");
for(x = 1; x <= n; x++){
System.out.print("o");
}
System.out.print("w");
}
}
int main()
{
int x,n;
scanf("%i",&n);
printf("W");
for(x=1;x<=n;x++)
{
printf("o",x);
}
printf("w");
return 0;
}
Solution by using CPP language:-
#include <iostream>
using namespace std;
int main()
{
int i,n;
cin >> n;
cout << "W";
for(i = 1; i <= n; i++)
{
cout << "o", i;
}
cout << "w";
return 0;
}
Solution by using JAVA language:-
import java.util.*;
public class Main
{
public static void main(String[] args)
{
int x,n;
Scanner num = new Scanner(System.in);
n = num.nextInt();
System.out.print("W");
for(x = 1; x <= n; x++){
System.out.print("o");
}
System.out.print("w");
}
}
Tags:-
#basic #basicspoj
#spoj #spojsolution #codechef #hackerrank #codingsolution #googledeveloper #microsoftdeveloper #tcsdeveloper #solution #clanguage #java #cpp #coding #japandeveloper #usadeveloper #indiandeveloper #usa #japan #india #deveper #programer #coder
Comments
Post a Comment