where is the probem?

+1 vote
asked May 27 by Nahla Abou Chakra (130 points)
int t[50];
   int i,n;
   int v,index=0;
   do {
       printf("enter n:");
       scanf("%d",&n);
   }while(n<=0||n>50);
   
    printf("reading value of t:\n");
   for(i=0;i<n;i++)
     {  printf("enter t[%d]:",i);
       scanf("%d",&t[i]);
     }
     printf("enter a value v:\n");
     scanf("%d",&v);
     
   for(i=0;i<n;i++)  
    {
        if(t[i]==v)
         index++;
     
    }
printf("number of occurence %d=%d\n",v,index);

3 Answers

0 votes
answered May 27 by shyam (570 points)

Wrap your code inside,

#include<stdio.h>

int main(){

    //Your code goes here

    return 0;

}

0 votes
answered May 27 by LiOS (3,660 points)
Not seeing any problems? Your code below doesn't have any headers called or main declared if that's the problem?

Below is code with header and main declared, which is working successfully after tests:

#include <stdio.h>

int main(){
    
    int t[50];
    int i, n;
    int v, index = 0;
   
    do{
        printf("enter n:");
        scanf("%d",&n);
        
    }
    while (n<=0 || n>50);
    
    printf("reading value of t:\n");
   
    for(i=0;i<n;i++){  
        printf("enter t[%d]:",i);
        scanf("%d",&t[i]);
     }
     
    printf("enter a value v:\n");
    scanf("%d",&v);
     
    for(i=0;i<n;i++){
        
        if(t[i]==v)
        index++;
    }
    
    printf("number of occurence %d = %d\n", v, index);

    return 0;
}
0 votes
answered 6 days ago by DevYadav2308 (190 points)
#include <stdio.h>

#include <conio.h>

int main() {

int t[50];
   int i,n;
   int v,index=0;
   do {
       printf("enter n:");
       scanf("%d",&n);
   }while(n<=0||n>50);
   
    printf("reading value of t:\n");
   for(i=0;i<n;i++)
     {  printf("enter t[%d]:",i);
       scanf("%d",&t[i]);
     }
     printf("enter a value v:\n");
     scanf("%d",&v);
     
   for(i=0;i<n;i++)  
    {
        if(t[i]==v)
         index++;
     
    }
printf("number of occurence %d=%d\n",v,index);

int t[50];
   int i,n;
   int v,index=0;
   do {
       printf("enter n:");
       scanf("%d",&n);
   }while(n<=0||n>50);
   
    printf("reading value of t:\n");
   for(i=0;i<n;i++)
     {  printf("enter t[%d]:",i);
       scanf("%d",&t[i]);
     }
     printf("enter a value v:\n");
     scanf("%d",&v);
     
   for(i=0;i<n;i++)  
    {
        if(t[i]==v)
         index++;
     
    }
printf("number of occurence %d=%d\n",v,index);

return 0;

}

// Here is your correct code
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...