Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

tell me the coding of this question

0 votes
asked Nov 20, 2017 by Fizza Sajjad (300 points)
Q1: Write a function called Sum_even which takes as input two integers N and M entered by the user from keyboard , and returns to the main function the summation of even numbers from N to M. (note: N and M included if were even numbers) .?

Q2: Write a function called Is_Capital that has one parameter and receives a character and returns true if the character received is a capital letter, and false otherwise. Then write a main function that calls the  Is_Capital  function to test its correctness.(you may solve it without using if-else statement).?

1 Answer

+1 vote
answered Nov 28, 2017 by Sathyamshu (260 points)
1.

int sum_even(int n, int m)

{

int temp,i,sum=0;

if(n>m)

{

temp=n;

n=m;

m=temp;

}

if(n%2==0)

{

for(i=n; i<=m; i=i+2)

{

sum=sum+i;

}

}

else

{

for(i=n+1; i<=m; i=i+2)

{

sum=sum+i;

}

}

return sum;

}

2.

Are u suggesting that u may use if-else condition? ........or else Are u insisting us not to use if-else condition?.....

The word "may" in ur sentence gets a doubt that whether we should use if-else or not
commented Dec 5, 2017 by Akshat Dodwad (230 points)
Good answer but u should have wriiten it in indented manner for proper understanding
commented Dec 8, 2017 by Zia Saleem (100 points)
you don't need if/else. just check if its even, if its not, add 1 to it and use the same loop
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...