Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scanf("%d %d",&a,&b);
- //set the content from A[a] to A[b] as '0' without looping
- #include <iostream>
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a[10]; // Array of 10 elements with val of 0;
- memset(a,0,sizeof(a));
- // Sets all array elements to 0
- memset(a+2,-1,sizeof(int)*5);
- // Sets value of array elements from 2 to 6 index equals to -1
- for(int i=0;i<10;i++)
- cout<<a[i]<<" ";
- cout<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement