Here is the accurate code which was executed ,output is in the screeshot shared below please do upvote thank you.
#include<stdio.h>
int calulate(int p,int q)
{
int i,j,isprime,d=0,f=0,k=0,a[1000],b[1000],c[100],res;
//prime factors of p to be stored in array a
for(i=2;i<=p;i++)
{
if(p%i==0)
{
isprime=1;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
isprime=0;
break;
}
}
if(isprime==1){
//if there is a prime factor store it in a
a[d]=i;
d++;
}
}
}
//prime factors of q to be stored in array b
for(i=2;i<=q;i++)
{
if(q%i==0)
{
isprime=1;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
isprime=0;
break;
}
}
if(isprime==1){
//if there is a prime factor store it in b
b[f]=i;
f++;
}
}
}
//to find common elements in array a and b(common prime factors
stored in c)
for(i=0;i<d;i++)
{
for(j=0;j<f;j++)
{
if(a[i]==b[j])
{
c[k]=a[i];
k++;
}
}
}
//to find max and min in array c i.e.,common elements array
int small=c[0];
int large=c[0];
for(i=0;i<k;i++)
{
if(c[i]<small)
small=c[i];
if(c[i]>large)
large=c[i];
}
res=small*large;
return res;
}
int main()
{
//t is no of test cases
int t,p,q,i,j,result;
scanf("%d",&t);
while(t!=0)
{
scanf("%d %d",&p,&q);
result=calulate(p,q);
printf("%d",result);
t--;
}
}
---OUTPUT--
![בס { main.c int Targe=C[]; 62 for(i=0;i<k;i++) 63 64 if(c[i]<small) 65 small=c[i]; 66 if(c[i]>large) 67 large=c[i]; 68 } 69 r](http://img.homeworklib.com/questions/ddadabd0-feb7-11ea-8359-a3d5f7c9e1e7.png?x-oss-process=image/resize,w_560)
Write in C language Identical Prime Factors Today is another bad school day for Bibi. Her...
Mishka is a 16-year-old female, who attends your school. A year ago, Mishka lost both her parents to a murder-suicide (committed by her father) which was hard for her to accept. Mishka was present during the ordeal as she hid behind the sofa as her parents argues. At first, Mishka would tell family members and friends that she would still see her parents and they were not dead. After reality struck, she bargained with God, asking him to return her...
A psychologist wanted to know if students in her class were more likely to cheat if they were low achievers. She divided her 60 students into three groups (low, middle, and high) based on their mean exam score on the previous three tests. She then asked them to rate how likely they were to cheat on an exam if the opportunity presented itself with very limited chance for consequences. The students rated their desire to cheat on a scale ranging...
Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...
i have the case study question with the answers but i need help
to re-write the answers.
please see the attached files
Case Study Analysis (CSF3003) Assessment Description and Requirements CLO1: Case Study 1 Ahmad lef home to study master and PhD in Australia. He has fees for the first semester only. After he arrived to Sydney and settled down, he start looking for a part-time job to save money for the next term. Ahmad has some experience on making...
In Java plz due today Assignment 4 - Email, Shwitter and Inheritance Select one option from below. All (both) options are worth the same number of points. The more advanced option(s) are provided for students who find the basic one too easy and want more of a challenge. OPTION A (Basic): Message, EMail and Tweet Understand the Classes and Problem Every message contains some content ("The British are coming! The British are coming!"). We could enhance this by adding other...
Using the book, write another paragraph or two: write 170
words:
Q: Compare the assumptions of physician-centered and
collaborative communication. How is the caregiver’s role different
in each model? How is the patient’s role different?
Answer: Physical-centered communication involves the specialists
taking control of the conversation. They decide on the topics of
discussion and when to end the process. The patient responds to the
issues raised by the caregiver and acts accordingly. On the other
hand, Collaborative communication involves a...
IN JAVA PLS DUE TODAY Assignment 4 - Email, Shwitter and Inheritance Select one option from below. All (both) options are worth the same number of points. The more advanced option(s) are provided for students who find the basic one too easy and want more of a challenge. OPTION A (Basic): Message, EMail and Tweet Understand the Classes and Problem Every message contains some content ("The British are coming! The British are coming!"). We could enhance this by adding other...
Budgeting for an Academic Department at a State University: Can You Believe the Numbers? INTRODUCTION You are the senior accounting faculty member in the business school and your dean, Dean Weller, is asking for help. She is very discouraged after a midyear budget meeting with the Vice President of Finance. The college's Department of Social Work has a large budget deficit, and because of this the VP is inclined towards closing the department entirely or closing its bachelor's program. The...