1 like 0 dislike
1.1k views

Use the pointers p1, p2, and p3 and complete the following program to read two integers and display the sum of the integers between them. For example, if the user enters 6 and 10, the program should display 24 (7+8+9). The program should force the user to enter numbers less than 100 (<100) or greater than 0 (>0) and the first integer should be less than the second, else display "Invalid value".

Sample Input 1:

6 10

Sample Output 1:

24


Sample Input 2:

10 6

Sample Output 2:

Invalid value

 

[Exercise] Coding (C) - asked in C
ID: 23261 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
0 0
Called for Help

58 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

    int main()

    {

        int num1,num2,i;
* * * ****** ***** * * ** ******* *** * ** sum=0;
* *** * * * ** *** * * * ** ** ** *** ****** * ** %d",&num1,&num2);


* **** *** * * ** ** * ** ** * * * *** * *** * * *** *** *
** * *** * ** * * * * * * ******* **** ** *** * ** * ** * * *** * * ** * **** value");
***** * * ** ** ** ** * * * ** *** * * * * * * if(num2 >=100 || num1>=100)
* * ** * ** * * * **** * ** * **** *** *** *** ** * *** * * * * value");
*** ** ** * * ** ** * *** * * ** * * * **** * ** * if(num1<=0 || num2<=0)
* * * * *** * * * * * *** * * ** **** * * ** ** * **** * * * * value");
** *** * * * ** * **** * * ***** **** ***
*** *** ****** * *** * * * * * * ** * ** * *** * ** * * * * **
** ******** *** ** * *** ** * * * ** * ** ** ** ** * ** * * ** ** * * * ** * * * * *
** *** * *** ** * *** ** * *** * * ** * ***** ** * * ***** ** * * *** *
* *** ** * * ******** * * * ** *** * ** **** ******** ** ***** *** ** ** * ** *** ** * ** * * * * *
** ** * * * * * ***** * * ** ** * * ** * ** *** ** * * * * * * * * **** * *** * * ***** ** * * ** * * * **
** ******* *** ** ** * * *** **** **** ****** ** * ** * **** ** * ** ** **** **** * *
* ** ** *** **** * ** * * ** * * * ******* ***** *** * *** *** ** * * ** * * * * * **
* * * * **** ** ** ** * * **** ** ** * * ****** * ** * ** ** ** ***

    return 0;

    }
answered by (-141 points)
0 like 0 dislike
Hidden content!
#include * * * * * *

#include * ****** **



int main ()

{


**** * * *** * ** ** * * *p1, *p2, *p3, a, b, i;
**** * * ** ** ***** ** sum=0;


* ** * * * * **** * ** ** * * * %d", &a, &b);
* *** ** ** * ** * = &a;
*** * * * * * ***** * * * = &b;


** * * * * ***** * * (a>b || a>100 || a==b || a<0 || b>100 || b<0)
* * * * ** * * * *
*** * ** ******* * ** ** * * * ** ***** **** *** ** ** * ** *** *
* * * ** * * * *** **


*** * ** *** *** *
* *** * * * *** **
* ** **** ** * * ** ** * (i=*p1+1; i<*p2; i++)
* * ** *** * * ** * * * ** * ** **** * *** *
* * ** ****** ** * ** *** * *** * ** * * * * * * * * * ** ** ** += i;
* * ** ** * * * ** * * * * * ** * **


* ** *** **** ** * ** *** * * *** * ** * ** * ** ** * ** * * sum);
* * * * ** ** *** *** ***


* *** * ** *** * *** ** 0;

}
answered by (-48 points)
0 like 0 dislike
Hidden content!
*** *** *** ** * **
*** * MAX 100



int *

{



int *


** i;

for * * **** *
* **** ** * ** ** ** * * **

}



int n1;

int n2;

int *p1;

int *p2;

int *p3;

int * *


* ****** * ** **** **
* * *** ** * * * ** *


* *
** **** **** * * ********** ** * * *** * ** ** ** ** **


** * if * ** * ** * * * *** * *** *** *** ** * * * * ** * * * **
**** ******* ***** **** *** *
* ** * *** *
* * *



for (p3 = ** p3 **** p2; ***

{


* * * * ** ** *** ** **** *** * * * **** *** * * += *p3;

}
* * ***
* ** * ***** **
*** * ***** * * * *




* 0;

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include ** * ** **

#include * ***



int main ()

{


* * ** * * *** * * * *p1, *p2, *p3, a, b, i;
*** ** * * * * ** * * * sum=0;


** *** * ** * ******** * * ****** ** %d", &a, &b);
** ***** **** * * * * ** = &a;
** * * **** ** * * * = &b;


* * * **** ** * ** * * (a>b || a>100 || a==b || a<0)
* ** *** * *
*** *** * * * * ***** ***** *** * * *** **** **** * *** ** * value");
* * * ** *** ** **
** ** *** **** * ****** *
***** * *** *** * *
* ****** **** ** * ** * *** **** ** (i=*p1+1; i<*p2; i++)
****** ** *** ***** * ** * * * * **** * *
* * *** ********** * *** ** *** * ** * * * * * ** **** * * * * ** += i;
* *** *** * * * **** ** **** * * * ** *


* ** ** ** ** ** * ***** * * ** * ** ** ** * ** ** **** sum);
* ** * ** ***


* ** ** * *** ** ***** * 0;

}
answered by (-48 points)
0 like 0 dislike
Hidden content!
* * * * ** * *
* MAX 100



int

{



int ***


*** i;

for **** * ***
**** **** *** **** ****** * * *

}



int n1;

int n2;

int *p1;

int *p2;

int *p3;

int * **


* *** * * **** * **** **
*** ** * ** ** ** * **


** * ***
* ** * * * * **** * * *** ** *


* if * * ** ** * **** * *** ** ** * * ** * *
* * ****** *** ***
*** ****
* * *



for (p3 = * * p3 * p2; **

{


* * * * * * * * ** **** ** * ** **** * **** *** += *p3;

}
*** * *
*************** * * *
* * *** * * **** **




* 0;

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

    int main()

    {

        int num1,num2,i;
* * ***** * ** ** * ****** * * * **** * * sum=0;
** * *** ***** * ** * * * *** ** * ** ** %d",&num1,&num2);


* **** *** * **** * * ** * * * ******* ******* ** **
* ** *** * ** ** * * * * * **** * * **** ** * * * * * * ** ** *** * *** value");
* *** * * * * * * ** * ** ** * *** * ** if(num2>= 100 && num1>=100)
* ** ** ** *** *** * * * * ** ** * ** ** *** *** *** *** * **** * * *** ** value");
* * ** *** * *** * * ** * * * * **** * * * if(num1<=0 && num2<=0)
** * ** * ** ** * * * *** *** * ** * * * ** ** ****** * * * *** * ** * * ** * * ** value");
***** * *** * * * * ***** ** ** *** * *
** ****** * *** * * **** * *** * * ** * * **** * ******** ** ***
* * * ** * *** ** ** ** ***** * * * * * ** * *** * * * * * ****** *** *** * * ** *** * *** * * **
** *** ******* ********* ** * ** **** ***** * *** ** ** * * **** *** *** * **
** *** ** ** ** *** * ** *** * ***** **** ** * *** ** * *** * * * * * ** ***** ***** * * ** ** * *** * ** **** ** **
* *** ** * *** * * * * * *** * * * * * ** * * ** ** * * * ** ** *** * *** * * * **** * **** *
*** * * * ** * * * ** * * * ***** * ** * * *** * * * ***** * **** ** **
**** * * ***** *** ** * * ** * ** * *** * * * * ** * * * * * * ***** * * * * * * * ** * **** * ** *
* ** ** ******** **** *** ** * * * ***** ** * ***** * ***

    return 0;

    }
answered by (-141 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

    int main()

    {

        int num1,num2,i;
*** * * *** ** * * * ***** *** * * sum=0;
** * * *** * **** ** ** * ** ** * ** * * ** %d",&num1,&num2);


** * * * ** * * ****** * * ** ** * *** * * * * * * *
** * * * ** * * ***** ** ** *** **** *** * * ** * ** * ** **** * *** value");
* ** * * ** *** * ***** * * ******** **** * *** * if(num2>= 100 && num1>=100)
* ** ***** * * * * ** * * ** * * * *** * * * ** * * ***** * *** * ** ** *** * ** ** * * value");
* * ** ** **** ** * * *** ** ***** ** * ** * *** ** *** if(num1<=0 && num2<=0)
**** * **** *** * * * * * * *** * * * **** *** ** * ** * ****** ** * ** * **** value");
** * * ** * *** * ** * * ***** * ** * *
** ** * * * ** * * * * ** * ** ** ** **** * * *
*** * ** *** *** ** ** ** ** *** ** ****** * *** ** *** * *** * * *** * ******* **** * ** * * ** ** * * * **
** ** * * * * * * * ** ** *** * * * * **** ** * ****** *** * *** ** * *** ** **
* * ** **** * * * *** * * * ** **** * * ** * * ** * *** *** * **** ** * * ** * * * * ** ** ** * ** * ****
* *** * * * *** * * * * **** *** * *** ** ** ** *** ****** *** * ** ** ** * * * ** * * *** * ** * * * * ********
*** * *** *** * * * * * ** *** * * * *********** * * * *** ** * ** * ** * *
* ** * ** * * * ** * ** * ** * * * ** **** * **** * *** * * **** * * ** * * * ** * * * *
****** *** * ****** * * * * * * ** * ** * * ** * *** *

    return 0;

    }
answered by (-141 points)
0 like 0 dislike
Hidden content!
** ***** * **
** ** MAX 100


* * ***

{



int ***



int i;
* **** **
** * * * * * **** **

}



int n1;

int n2;

int *p1;

int *p2;

int *p3;

int **


* * * * **** * * * * * *****
** * *** * ** ******* *


** * * ***
* ** ** * * ** ** * * * * ** ** * * * * *


** if ** * * *** ** ** ** ** ** * *** ** * * * ** * * * *
** ** * *** **** * ** **
** ** ***
*******


* (p3 = * ** p3 * ** p2; ***

{


* * * * * ** * ** ** * ** ** ***** **** **** += *p3;

}
**
* *** * * * ****
***** ** ****** * ***** * *




*** *** 0;

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
** ** * *********
* MAX 100



int **

{



int * *


** i;

for * ** * *******
**** ******* *** **** * *****

}



int n1;

int n2;

int ***

int *p2;

int *p3;

int * *


* * *** * ** * ***
* * * * *** * * *


*** * * **
* * ** * ** * ** * * ** ** ** **** **** * * *


* * if ***** ** ** ** * * ** *** ** **** ** ** * **** ** * *
******** ** * *** ** *** * *
* ** **
* *** *



for (p3 = *** p3 ** ** p2; ** *

{


*** **** ******* * * * *** * ** **** ** * ** * += *p3;

}
***
** ** **** *** *
* * ** *** ** * ** ** *




** 0;

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include * ** *

#include ** * ** *



int main ()

{


*** ** *** * ** ** ***** * *p1, *p2, *p3, a, b, i;
****** * * * * ** * * sum=0;


** ****** * * * * ** * %d", &a, &b);
* ** * * ** * * *** * = &a;
*** * * * * * * * * ** = &b;


* ** ** * ***** ** *** * * * (a>b || a>100 || a==b)
* ** *** ** ** **** ** *** *
* *** ** * * ** ****** ** ** * ****** ** ** * value");
* *** ** ***** *
** * * ** ** * ** ** **
*** * * *** *** * ***
** * * * * * ** **** ** *** ** * ** ** * (i=*p1+1; i<*p2; i++)
* ** ** ***** ** ** * * **** * * **** *
*** * * * ** * * * * *** * **** **** ******* ** **** *** * **** += i;
** ** * ** ********** * * * ****** *** ** * **


* *** * * * * ** * * * ** * ****** ** * ** * * ** **** sum);
* * * * ** ******


*** ** ** * * ***** ** * 0;

}
answered by (-48 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.255.2
©2016-2024

Related questions

0 like 0 dislike
87 answers
[Exercise] Coding (C) - asked Mar 2, 2017 in C
ID: 22313 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
0 like 0 dislike
52 answers
[Exercise] Coding (C) - asked Feb 23, 2017 in C
ID: 22017 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
12,783 questions
183,443 answers
172,219 comments
4,824 users