• + 0 comments

    Here is my C assignment :

    #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 a;
        double b;
        char *c= (char*) malloc(1024*sizeof(char));
        scanf("%[^\n]%*c",c);
        a=atoi(c);
        scanf("%[^\n]%*c",c);
        b=atof(c);
        scanf("%[^\n]%*c",c);
        c= (char*) realloc(c, strlen(c)+1);
        printf("%d\n",i+a);
        printf("%-0.1f\n",d+b);
        printf("%s%s",s,c);
        return 0;
    }