What's new

Reviewer FREE CHEGG, SCRIBD, STUDOC, AND BARTLEBY THREAD UNLOCK (CLOSED)

Status
Not open for further replies.
1619779250276.png

pasensya poooo talagaaaaaa
 

Attachments

#include <stdio.h>

int main()
{
int n,m ,sm=0,w;
printf("Enter Beginning Number:");
scanf("%d",&n);
printf("Enter Ending Number:");
scanf("%d",&m);
w=n;
//checking weather the n is equal to m
if(n==m)
{
//printing required output
printf("Error in input.Beginning and Ending numbers are the same.");

}
//checking weather n is greater than m
else if (n>m)
{
//printing required output
printf("Error in input. Beginning number is larger than the Ending number");
}
//if none of condition is true
else
{
//looping through all element fromn to m
while(w<=m)
{
//checking weather the element is odd
if (w%2!=0)
{
//if odd then add it to sm
sm=sm+w;
}
//increment w by 1
w++;
}
//printing result
printf("The sum of all odd numbers from %d to %d is %d",n,m,sm);

}

return 0;
}
 
Thank you! Wala po kasing binigay na example si Mam. I have the same answer po but different lang po ang structure and statement kaya po nag-eerror ang program.
 
Status
Not open for further replies.
Back
Top