Answer:
#include <iostream>
using namespace std;
int main()
{
int arr[]={3,-9,9,33,-4,-5, 100,4,-23};
int pos;
int n=sizeof(arr)/sizeof(arr[0]);
for(int i=0;i<n;i++){
if(arr[i]>=0){
pos++;
}
}
cout<<"Number of positive integers is "<<pos<<endl;
return 0;
}
Explanation:
create the main function in the c++ programming and declare the array with the element. Then, store the size of array by using the formula:
int n=sizeof(arr)/sizeof(arr[0]);
after that, take a for loop for traversing the array and then check condition for positive element using if statement,
condition is array element greater than or equal to zero.
if condition true then increment the count by 1.
this process happen until the condition true
and finally print the count.
Answer:
phones = {'John': '1234567', 'Julie' : '7777777'}
Explanation:
In the code given in the question phones dictionary contains contains two keys John and Julie and have the values '5555555' and '7777777' respectively. Now in the code the key John in the dictionary phones is assigned the value '1234567' .So the value corresponding to the key John becomes '1234567'.
Answer:
Check the explanation
Explanation:
#define _MULTI_THREADED
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#define THREADS 2
int i=1,j,k,l;
int argcG;
char *argvG[1000];
void *threadfunc(void *parm)
{
int *num;
num=(int*)parm;
while(1)
{
if(i>=argcG)
break;
if(*num ==1)
if(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u')
{
printf("%s\n",argvG[i]);
i++;
continue;
}
if(*num ==2)
if(!(argvG[i][0]=='a' ||argvG[i][0]=='2'||argvG[i][0]=='i' ||argvG[i][0]=='o' ||argvG[i][0]=='u'))
{
printf("%s\n",argvG[i]);
i++;
continue;
}
sched_yield();
}
return NULL;
}
int main(int argc, char *argv[])
{
pthread_t threadid[THREADS];
int rc=0;
int loop=0;
int arr[2]={1,2};
argcG=argc;
for(rc=0;rc<argc;rc++)
argvG[rc]=argv[rc];
printf("Creating %d threads\n", THREADS);
for (loop=0; loop<THREADS; ++loop) {
rc =pthread_create(&threadid[loop], NULL, threadfunc,&arr[loop]);
}
for (loop=0; loop<THREADS; ++loop) {
rc = pthread_join(threadid[loop], NULL);
}
printf("Main completed\n");
return 0;
}
The below attached image is a sample output
Answer:
Yes, it is correct. God is great. He gives pain but gives the ointment as well to get rid of it. God gives tougher challenges, but God also gives the guts to tackle them and win them. The story of adaptation, ad predator also goes like this. God gives spines to sea urchins to survive, and it gives the birds stronger beaks to break shells. Similarly, he gives programmers awesome brains to solve the toughest problems.
Explanation:
Please check the answer.
What are ur possible answers