+ 2
Why it is not working?
Promblem: https://www.hackerrank.com/challenges/grading/problem code: #include<stdio.h> #include<string.h> int main(){ int a[100]; int b=strlen(a); int c; int d = 8; int e,f; scanf("%d",a); for (f=0;f<b;++f){ if(a[b]>=38){ while(a[f]>c){ c= 5*d; ++d; } e= c-a[f]; if(e<3){ prntf("&d",&c); } if(e=3){ printf("%d",&a[f]); } } else{ printf("33"); } } return 0; }
4 Respuestas
+ 1
Line 18:
if (e < 3)
prntf -> printf
It's recommended that you post code in the Playground and link them here so it could be more readable to the others, thus speeding up the time to get you a proper solution.
+ 3
Hoàng Nguyễn Văn 😅😅thanks for seeing my tons of mistakes.
+ 2
Hoàng Nguyễn Văn
Something is wrong
Input:
4
73
67
38
33
Output:
75
67
40
33
But I'm getting output as 333333
Code: https://code.sololearn.com/c2hKez8V7eVW/#c
Question: https://www.hackerrank.com/challenges/grading/problem
+ 1
Jayakrishna lots of things are wrong. I'm not proficient in C (only know a bit C++) so don't take this as a qualified answer.
Line 5: strlen is a function for string type, not int.
Line 11: If b is supposed to be the array size, a[b] is accessing out of bounds
Line 20: "if (e = 3)" is always true, if you were expecting comparision, use e == 3 instead.
Name variable according to their purposes, don't just bring in the whole alphabet. It's hard to both read and maintain for a developer and his peers.