Twosum what is the problem in my code?


  • 0
    B

    //what's problem in my code?
    #include<stdio.h>
    #include<conio.h>
    int main(){
    int i,nums[100],t,arrsize,j,k;

    printf("NOW ENTER YOUR ARRAYSIZE:..");
    scanf("%d",&arrsize);
    printf("NOW ENTER THE ELEMENT OF ARRAY:..");
    for(i=0;i<arrsize;i++){
    scanf("%d",&nums[i]);
    }
     printf("ENTER THE TARGET:");
    scanf("%d",&t);
    for(j=0;j<arrsize;j++){
        for(k=0;k<arrsize;k++){
            if(nums[j]+nums[k]==t){
                printf("%d %d\n",j,k);
                break;
            }
        }
    }
    

    return 0;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.