Wednesday 8 March 2017

HackerRank Day 1 Data Types 30 Day Solution In C (Concatenation)

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int i = 4;
    double d = 4.0;
    char s[] = "HackerRank ";
    int j;
    double dd;
    char str[100],*p,a[100];
    scanf("%d",&j);
    scanf("%lf",&dd);
    scanf(" %[^\n]",str);
    p=strcpy(a,s);
    // Read and save an integer, double, and String to your variables.
    printf("%d\n",i+j);
    // Print the sum of both integer variables on a new line.
    printf("%.1lf\n",d+dd);
    // Print the sum of the double variables on a new line.
    p=strcat(a,str);
    printf("%s\n",p);
    // Concatenate and print the String variables on a new line
    // The 's' variable above should be printed first.
   
return 0;
}


1 comment:

  1. // The 's' variable above should be printed first...this line confused pls share

    ReplyDelete