It's a 2 part C programming exam that has to be completed in 24 hours, it involves a short timed quiz for the first part and the second part will be released on 18/08/2020 at 12.01am

1 answer below »
It's a 2 part C programming exam that has to be completed in 24 hours, it involves a short timed quiz for the first part and the second part will be released on 18/08/2020 at 12.01am
Answered Same DayAug 15, 2021

Answer To: It's a 2 part C programming exam that has to be completed in 24 hours, it involves a short timed...

Arun Shankar answered on Aug 19 2021
139 Votes
q1.c
#include
int main()
{
    int size = 0;
    int arr[1000];
    int num;
    while(scanf("%d",&num)!=EOF)
    {
     if(size==0)
     arr[si
ze++] = num;
     else
     {
     if(arr[size-1]!=num)
     arr[size++] = num;
     }
    
    } // end of while
    
    // Now, print
    printf("[");
    int i = 0;
    for(i=0;i    {
     if(i!=size-1)
     printf("%d ",arr[i]);
     else
     printf("%d",arr[i]);
    }
    printf("]\n");
    
    return 0;
}
q4.c
#include
#include
#include
int getDecimal(char c)
{
switch(c)
{
case 'I': return 1;
case 'V': return 5;
case 'X': return 10;
case 'L': return 50;
case 'C': return 100;
case 'D': return 500;
case 'M': return 1000;
default: return -1;
}
}
int main(int argc, char* argv[])
{
int res = 0;
int len = strlen(argv[1]);
for (int i = 0; argv[1][i]!='\0'; i++)
{
int s1 = getDecimal(argv[1][i]);
if (i + 1 < len)
{
int s2 = getDecimal(argv[1][i + 1]);
if (s1 >= s2)
res = res + s1;
else
{
res = res + s2 - s1;
i++;
}
}
else
res = res + s1;
} // end of for loop

printf("%d\n",res);
return 0;
}
q6.c
#include
#include
int getRandomNumber() {
return rand() % 10 + 2;
}
int main(int argc, char* argv[]) {
int a = getRandomNumber();
int b = getRandomNumber();
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here