Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

#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 ;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading