India Languages, asked by priyangachandra, 1 year ago

Write a 'C' program to arrange the even digits first and odd digits second of the given number vice versa without using array

Answers

Answered by Silverbird
0
is the answer carry or it maybe wrong
Answered by codiepienagoya
0

Following are the C program to calculate even and odd numbers:

#include <stdio.h>//defining a header file

int main()//defining main method

{

int i,n;//defining integer variables  

printf("Enter the last number where you end numbers: ");//print message

scanf("%d",&n);//input value

printf("Even number: ");//print meassge

for(i=1;i<=n;i++)//defining loop for print even values

{

   if(i%2==0)//defining if block to check even number condition  

   {

      printf("%d\n",i);//print even number

   }

}

printf("odd number: ");//print meassge

for(i=0;i<n;i++)//defining loop to print odd number  

{

   if(i%2!=0)//defining if block to check odd number condition

   {

      printf("%d\n",i);//print odd number

   }

}

   return 0;

}

Output:

please find the attachment.

Explanation:

  • In the above-given code inside the main method two integer variable "i and n" is declared, in which "i" variable used in a loop to print values, and "n" variable is used for input the last number.
  • In the next step, two for loop is declared, in which the first loop is used to print even numbers and the second loop is used to print odd numbers.

Learn more:

  • The Output of the code: https://brainly.in/question/5321421
Attachments:
Similar questions