My issue
include <stdio.h>
include <string.h>
int main(void) {
int t,n,i;
char s[n];
scanf(“%d”,&t);
while(t–){
scanf(“%d”,&n);
scanf(“%s”,s);
for(i=0; i<n; i+=2){
if((s[i]==‘0’) && (s[i+1]==‘0’)){
printf(“A”);
}
if((s[i]==‘0’) && (s[i+1]==‘1’)){
printf(“T”);
}
if((s[i]==‘1’) && (s[i+1]==‘0’)){
printf(“C”);
}
if((s[i]==‘1’) && (s[i+1]==‘1’)){
printf(“G”);
}
}
printf("\n");
}
return 0;
}
I have return this code which is correct , but it is displaying as run time error, how to resolve this?
My code
#include <stdio.h>
#include <string.h>
int main(void) {
int t,n,i;
char s[n];
scanf("%d",&t);
while(t--){
scanf("%d",&n);
scanf("%s",s);
for(i=0; i<n; i+=2){
if((s[i]=='0') && (s[i+1]=='0')){
printf("A");
}
if((s[i]=='0') && (s[i+1]=='1')){
printf("T");
}
if((s[i]=='1') && (s[i+1]=='0')){
printf("C");
}
if((s[i]=='1') && (s[i+1]=='1')){
printf("G");
}
}
printf("\n");
}
return 0;
}
Learning course: Strings using C
Problem Link: CodeChef: Practical coding for everyone