Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a program to enter 10 numbers using keyboard and put them in an array. Now generate another array of
same size from the array created in the first step by satisfying the following conditions:
• If the number is prime then write ‘P’ to the same location of the second array
• If the number is divisible by 5 then write ‘F’
• If the number is divisible by 3 then write ‘T’
• If number is an Even number and neither divisible by 3 or 5 then write ‘E’
• If number is an Odd number and a non-prime number write ‘N’ Consider the

following example:
A =
12 11 19 49 27 30 35 39 7 61
B =
T P P N T F F T P P

What I have tried:

#include <stdio.h>

int main()
{
    int a[10],l,f=0;
    printf("enter the 10 numbers\n");
    for(int i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
       
    }
     printf("\n");
char b[10];    //character array  is declared to store characters such as N,P,E,T
    for(int i=0;i<10;i++)
    {
        l=a[i];f=0;
        for(int k=2;k
Posted
Updated 17-Nov-20 3:19am
v3
Comments
Richard Deeming 17-Nov-20 4:50am    
Nobody here is going to do your homework for you. If you seriously don't know where to start, then talk to your teacher.

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Try harder (you tried nothing).
Your hardest task is the primality test, luckily you may find many many resources on the web (see, for instance, the dedicated Wikipedia page: Primality test - Wikipedia[^]).
 
Share this answer
 
Comments
virat bansal 17-Nov-20 5:45am    
atleast give an idea how to write
CPallini 17-Nov-20 6:02am    
You are on the right track. Just complete the code. If you are stuck, ask the specific quesiton.
C#
int main()
{
    int a[10],l,f=0;
    printf("enter the 10 numbers\n");
    for(int i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
       
    }
     printf("\n");
char b[10];    //character array  is declared to store characters such as N,P,E,T
    for(int i=0;i<10;i++)
    {
        l=a[i];f=0;
        for(int k=2;k
 
Share this answer
 
v3
Comments
Patrice T 17-Nov-20 7:23am    
This is not a solution, code is corrupted.
PIEBALDconsult 17-Nov-20 9:17am    
Please don't try to answer your own question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900