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!
* * * ** * ***
* MAX 100



int ****

{


* **



int i;

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

}



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!
* ********* *



int main(void){
** *** * **** * ** i, p1, p2, sum=0, *ptr, size;


* * ** * *** * *** ** * **** ** %d", &p1, &p2);
****** * ** ** ***** * = p2-p1-1;
* * * * ** * *** ** * numbers[size];


* **** * ** ** *** ***** ** *** && p1>0 && p2>0 ***** * * p1<=100 ***** * * p2<=100){


* ** * * * * * * * * * *** * * i<size; i++){
* ** ** * ***** * * * **** *** *** **** * * ** * * ** * ** * * * ** ** = p1+i+1;
** * * ***** **** *** ** * * * ** * ** * * ** ** *


*** * *** * ** *** *** * ** *** ** * ** ** = numbers;


**** * * * * * **** ** **** ** * **** *** (i = 0; i < size; i++) {
* ** * * ** ** ** ** *** * * * *** * * ***** *** * = sum + *ptr;
* ** * * * ** ** *** ********* * ***** **** *** *** ******* **
** * * ** ** * * * * * ** ** ** * * ** *
**** * * *** * *** * * ** **** *** ******** ** ** * ** sum);
** * * *** * ******
* *** * * * * **
*** * ****** ** * * ** ** **** * ** * * * * ** value");






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

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

int main()

{
*** ** * * * ** ** ** * x, *p1=&x;
* * * * * *** *** * * * y, *p2=&y;
* ** ** ** *** ** * sum=0, *p3=&sum;
**** ** * ** * * ** ** ** * i;


*** ***** *** * * * ** ** * *** %d", &x, &y);
* **** ****** (x<=0 || x>=100)
* * *** **** * ** *
** ** * *** * * ** * ** * **** * * * ** * * * * * * * value");
**** ** * ***** ** ** * * * ***** * ** * *** * 0;
**** * * * *** ** * **
******** **** ** **** (y<=0 || y>=100)
* *** * * ** ********* **
** * ** * ******* * *** * **** * * ** ** * * **** value");
**** * *** ** * * **** * *** * *** *** * * * 0;
* * *** * * ** *
* ** *** * *** **** ** ** * * (y<=x)
** * * ** * *********
****** * ****** * * * * *** * ** *** * * * * ***** * ** * value");
* ** * * * * ***** * * * * * *** *** ** ** * ** 0;
*** * * * ** *** ** * * **** *** *


* ** * ***** ** * * * * * ** i<y; i++)
* ** ** ** * ** ** * * *
******* * ** ** * * * *** * * * *** ***** * * **
* * * * *** * * ** * **
* ** ** ***** ** ***** ** ** * * ** *p3);
** * * ** * * **** ** 0;

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

int main()

{
* * *** * * * * * * x, *p1=&x;
*** ** * ** * ** ** * * * * y, *p2=&y;
* *** * * * ******** *** sum=0, *p3=&sum;
* * * ** ******** * * i;


* *** *** * *** **** * * * * *** *** %d", &x, &y);
**** * ** ** *** * (x<=0 || x>=100)

    {
* * * * * ** * ****** * **** * ** **** * * * **
** * ** * * **** * ***** * *** ** *** ** 0;
* ** * * * **
***** **** * ******* ** (y<=0 || y>=100)
* ** * ** **** **** ****
*** **** * ** *** * ** *** * ** * ** * ** * * ** ** * *
** ** * **** ** * **** * * *** * ** ** * ***** * 0;
** ****** * * *** *
*** * * * * *** ** * * * ** (y<=x)
* ** ** * ************ * * *
** * * **** ** ** ** * *** ** *** * ****** ** * * *
* ** * ***** *** * * ** * ** * * ** * 0;
*** * * ** * ** ***


* * ** * * **** * * * * *** i<y; i++)
* *** * **** * *** * ***
** * ** *** * *** ** * ******* * * * * * ** * * *
* ** * * * ***
*** * ** * * *** *** * ** ** **** *p3);
*** ***** *** 0;

}



invalid_value()

{
** ** **** ** * ** * ** * ** * value");

}
answered by (-368 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 * * * ** ** * * * ** *** ** ** * * ** *** ** * *
* * * ** *** *
**** * **
** *** ***


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

{


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

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




* * 0;

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

int Paaa(int b, int c){
** * ** ** *** * * * i;
*** * ** ***** * *** * * a[2]={b, c};
**** ** ****** *** * * * *** i<2; i++){
* ** ** ** * ** * * *** ** ***** *** ** *** ** * ****** ** * * **
**** *** * **** ** ***** * ** ***** * * * *** ** * ** 0;

    }
* * * * * *** * * ** 1;

}



int main(void){
** * ** ********* * A, B, result=0;
* * ** * *** *** *** * ** * **** %d", &A, &B);
* ** ****** *** *** ****** * *** && Paaa(A, B)==1){
* * **** **** * * * * **** * ** * **
** * * *** ** * ** ** * ** ** ** * * * **
****** * * * * * * ** * ****** *** *** ** ** *** * *** ** **** * **
*** * ** ** * * * *********** **** * ** ** * *** * ** * * *
*** ****** * * ** **** ** *** ** * **
* * ***** *** ** * ** * ** **** ** **** ** * *** ** * result);

    }
* *** * * *** * * **
***** ** * ** * * *** * * * **** * * * * * ** ** value");


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

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



int main(void)

{
** ** ***** * *** ** * * f,l,i,total=0;
* * * *** * ** * * * *** ** * *** * * *


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

    {
* * ***** *** ** * * * * * ** * * * *
** * * ***** * * *


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

    {
***** ** * ** * *** ** *** *** ** * * ** **** value");
***** * * ** ** **** *
** * * * * * * ** *
* **** * * * * ** ** ***
* * ** ** *** ***** ** ** * ** **** * ** ** *** **
* * ** ************

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

#include ** ** *** *



int main(){
* ** ** *** * * ** * i,a,b,sum=0;
****** * * * * ** ** * * ***** * * * ****** ** **** *
*** **** * * ** ** ** (a>b || a>100 || a<=0 || b>100 || b<=0){
** * * **** *** * **** *** * *** *** *** * ** * * * value");
*** * ** * ** * * **
**** ** *** * * * * ** * * {
* * * * *** **** ***
**** * **** ** *** * *** * **
* ** **** **** * ** * * * *
* * ****** ** ** * **   
* ****** **** * * *** * *** ****** ***** *** ***

}
** * * ** * *
* ** ** * **** **
* ** ** ** * ** * * 0 ;  

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
* *** * *** * *
*** * * **** **



int calint(int ,int);



int main(){
* * * **** * * p1,p2;
** * * ** ** * temp;
**** ** **** **** *
** *** *** ** * *** *** * ***** * ** **** * * * ***
* **** * * *** * ** count = p2 - p1;
* **** **** * * * ** || p1>100 || p2<0 || p2>100 || count <=1){
*** * ***** ****** ** * * * * * * * ******* * * ** ** value");
** * * **** ** *** * * * * *** ** *** * 0;
* * ** * *
* * * * * * * * * * = calint(p1,p2);
** ***** *** ** *** * * * ** * *
** * *** ** ** * *** * 0;

}



int calint(int p1,int p2){
**** *** * * * * i;
* * * *** ** * ** * * * ** temp = 0;
* * ******* *** ****** * a = p1+1;
* * * * ***** * *** * *** ** *** *
* ** ** ** **** * ** * ** * * * * * *** * = temp + i;
*** * ** * **** ** *
** ** * *
**** * **** * ****** * *** temp;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
** ** ** ** * ** *





int main()

{



int n1, n2;

int i;

int **



scanf * * * ****** * * ****
* ** *** * * **** * *


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

else *** *** * * ** ** * * * * * ** * ** * * * ** * ***

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

}


*** ** **** *

}




** 0;

}
answered by (-34 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.120
©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