Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

where is the probem?

0 votes
asked May 27, 2020 by Nahla Abou Chakra (120 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, 2020 by shyam (570 points)

Wrap your code inside,

#include<stdio.h>

int main(){

    //Your code goes here

    return 0;

}

0 votes
answered May 27, 2020 by LiOS (6,420 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 Jun 26, 2020 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.
...