I have an array of 100 elements, each of which is a random
integer. I want to know which of the elements:
a) are multiples of 2
b) are multiples of 2 AND 5
c) have a remainder of 3 when divided by 7
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
void main()
{
int num[100],n,i;
clrscr();
printf("\nEnter the number of elements ");
scanf("%d",&n);
printf("\nEnter the number ");
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for(i=0;i<n;i++)
{
if(num[i]%2==0)
{
printf("\nThe Number %d is multiple of 2 ",num[i]);
}
if((num[i]%2==0)&&(num[i]%5==0))
{
printf("\nThe Nubmer %d is the multiple of both 2 and 5
",num[i]);
}
if(num[i]%7==3)
{
printf("\nThe number %d has remainder 7 ",num[i]);
}
}
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Can include files be nested? How many levels deep can include files be nested?
What is a good data structure to use for storing lines of text?
How can I ensure that integer arithmetic doesnt overflow?
What is typedef struct in c?
What is meant by recursion?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
What is the advantage of a random access file?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What is operator precedence?
Is main an identifier in c?
Differentiate abs() function from fabs() function.
Should I learn data structures in c or python?
using for loop sum 2 number of any 4 digit number in c language
What does volatile do?
What are pointers in C? Give an example where to illustrate their significance.