Computer Science, asked by kamalsuhas, 9 months ago

#include <stdio.h>
int main()
int n, i;
printf("n: ");
scanf("%d", *n);
if(n%2=0)
for(i=0;i<n:i=i+2)
printf("%d ", i);
else
for(i=1;i<n;i=i+2)
printf("%d ",i);
return 0;​
fix errors?

Answers

Answered by tiriancame
1

Answer:

2

Explanation:

sfdfbvsdsvdvdvsdvsvvdvd

Answered by tiger009
0

C Program

Explanation:

The following program are correct.

#include <stdio.h>

//define main method

int main()

{

//declare integer type variables

int n, i;

printf("n: ");

//get input from the user

scanf("%d", &n);

//set if-else statement to print even odd numbers

if(n % 2==0)

{

for(i=0;i<n;i=i+2)

printf("%d ", i);

}

else

{

for(i=1;i<n;i=i+2)

printf("%d ",i);

}

return 0;

}

The following are escription of the error.

  • The first error is the curly braces {} to open or close the function or in an if-else conditional statement, the curly braces {} are not used at a single-line statement only if more than one line inside if-else statement than you have to use braces.
  • The next error in the 'scanf()' predefined function, to get input from the user you have to use the & operator at the place of * operator. In C Programming Language, the address operator should be used to get input.
  • Then, in the for a loop after the if conditional statement there is the colon at the place of the semi-colon.

Learn More:

https://brainly.in/question/610076

Similar questions