please help me.. how to write a code of this output??

"Enter range number:"10

1 is an odd number
2 is an even numbers
3 in an odd numbers
4 "
to
10"

"printing all odd numbers:"
1,3,5,7,9
"printing all even numbers:"
2,4,6,8,10
"sum of all odd numbers:25
"sum of all even numbers:30

using a C Programming ARRAY

pleas pleas help.. its my project ..please :(



please help me.. how to write a code of this output?? "Enter range number:"10 1 is a..

Answer / mudita rathore

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,sum=0,sum1=0;
printf("enter the all numbers");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<10;i++)
{
if(a[i]%2==0)
{
printf("even numbers=%d\n",a[i]);
sum=sum+a[i];
printf("sumof even numbers=%d\n",sum);
}
else
{
printf("odd numbers=%d\n",a[i]);
sum1=sum1+a[i];
printf("sum of odd numbers=%d\n",sum1);
}
}
}

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

program in c to print 1 to 100 without using loop

9 Answers   Wipro,


How to print %d in output

6 Answers   Wipro,


Explain what is the benefit of using #define to declare a constant?

0 Answers  


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

0 Answers  


Is the exit() function same as the return statement? Explain.

0 Answers   Agilent, ZS Associates,






x=2,y=6,z=6 x=y==z; printf(%d",x)

13 Answers   Bharat, Cisco, HCL, TCS,


In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT

1 Answers   IBM,


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E &#133;&#133;.. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,&#133;&#133;&#133;&#133;.]. Each Car will load the packet with the same alphabet. So, for example, car &#145;A&#146; will load all the packets with name &#145;A&#146;. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car &#145;B&#146; will come and take all the packets with name &#145;B&#146; from the shelf, then car &#145;C&#146; will come. No matter how deep in the shelf any packet &#145;B&#146; is, all of the &#145;B&#146; packets will be displaced before the &#145;C&#146; car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

0 Answers   Infosys,


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

0 Answers  


What is clrscr in c?

0 Answers  


what is differnence b/w macro & functions

1 Answers  


What is the memory allocated by the following definition ? int (*x)[10];

4 Answers   ADITI, Wipro,


Categories