Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. scanf("%d %d",&a,&b);
  2. //set the content from A[a] to A[b] as '0' without looping
  3.  
  4. #include <iostream>
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7. int main()
  8. {
  9. int a[10]; // Array of 10 elements with val of 0;
  10. memset(a,0,sizeof(a));
  11. // Sets all array elements to 0
  12.  
  13. memset(a+2,-1,sizeof(int)*5);
  14. // Sets value of array elements from 2 to 6 index equals to -1
  15.  
  16. for(int i=0;i<10;i++)
  17. cout<<a[i]<<" ";
  18. cout<<endl;
  19.  
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement