Design a program using an array that lists even numbers and
odd numbers separately from the 12 numbers supplied by a user.
Answer Posted / belsia
#include<stdio.h>
#include<conio.h>
void main()
{
int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter 12 numbers\n");
for(i=0;i<12;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<12;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The even numbers are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}
| Is This Answer Correct ? | 66 Yes | 21 No |
Post New Answer View All Answers
What is meant by errors and debugging?
Do you know the difference between malloc() and calloc() function?
What is the difference between text files and binary files?
What is sizeof int?
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
What is the difference between the expression “++a” and “a++”?
What does 1f stand for?
Is it possible to initialize a variable at the time it was declared?
What does == mean in texting?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
What are types of structure?
What is difference between structure and union with example?
What is the scope of local variable in c?
What is identifier in c?
How do you list a file’s date and time?