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



I have an array of 100 elements, each of which is a random integer. I want to know which of the el..

Answer / 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

More C Interview Questions

what is the difference between char * const and const char *?

2 Answers   TCS,


15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to?

1 Answers  


Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed.

2 Answers   Scientific Atlanta, Wipro,


What is #define size in c?

0 Answers  


How many levels deep can include files be nested?

0 Answers  






What are structural members?

0 Answers  


what is the difference between const volatile int i & volatile const int j;

2 Answers   HCL,


Define macros.

0 Answers   Tech Mahindra,


How can I do graphics in c?

0 Answers  


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

0 Answers  


What are the various topologies? Which one is the most secure?

2 Answers  


Should I learn c before c++?

0 Answers  


Categories