Home > Blockchain >  for following c code i getting error for loop : expected expression before ')' token
for following c code i getting error for loop : expected expression before ')' token

Time:12-11

below C program run in online complier if it is helpful for solving error message Thanks for answering question in advance!!

#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main(){
    int arr[10],i,j,n;
    printf("Enter the size of array");
    scanf("%d",&n);
  
for(i=0,i<n,i  ){
   printf("Enter the elements in array:");
    scanf("%d",&arr[i]);  
}
for(j=0,j<n,j  ){
    printf("%d\t",a[i]);
}
return 0 ;
}

I want to create an array of n size(n is input from the user) and store elements in the array and display array, but I am getting an error message in for loop: expected expression before ')' token because of that I cannot move further.

CodePudding user response:

#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main(){
    int arr[10],i,j,n;
    printf("Enter the size of array");
    scanf("%d",&n);
  
for(i=0,i<n,i  ){
   printf("Enter the elements in array:");
    scanf("%d",&arr[i]);  
}
for(j=0,j<n,j  ){
    printf("%d\t",a[i]);
}
return 0 ;
}
  • Related