Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Thursday, December 31, 2020

Basic Data Types | HackerRank | Solution | C++



Problem : https://www.hackerrank.com/challenges/c-tutorial-basic-data-types/problem

Solution : 

#include <iostream>

#include <cstdio>
using namespace std;

int main() {
    // Complete the code.
    int a;
    float b;
    char c;
    double d;
    long l;
    scanf("%d %ld %c %f %lf",&a ,&l,&c,&b,&d);
    printf("%d\n%ld\n%c\n%0.3f\n%.9lf",a,l,c,b,d);
    return 0;
}

Input and Output | Hackrrank | C++ | Solution



Problem : https://www.hackerrank.com/challenges/cpp-input-and-output/problem

Solution : #include <cmath>

#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int a , b , c;
    cin>>a>>b>>c;
    int sum = 0;
    sum = a + b + c;
    cout<<sum;
    return 0;
}