S1-Assignment-2 (Automata Fix) - Attempt Review

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Dashboard / My courses /

TT-101 /
Module - I /
S1-Assignment-2 (Automata Fix)

Started on Tuesday, 27 July 2021, 8:19 AM


State Finished
Completed on Tuesday, 27 July 2021, 8:34 AM
Time taken 15 mins 32 secs
Grade 10.00 out of 10.00 (100%)
Question 1

Correct

Mark 2.00 out of 2.00

Write a C program to check whether the attendance is PRESENT  using simple if statement?
For example:

Input Result

P
Present

Answer: (penalty regime: 0, 0, 0, 0, 0, 0, 0. %)

Reset answer

Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

char value;

scanf("%c",&value);

if(value=='P')

printf("Present");

return 0;

Input Expected Got

 P Present Present 

 A 

Passed all tests!  

Question author's solution (C):


Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

char value;

scanf("%c",&value);

if(value=='P')

printf("Present");

return 0;

Correct
Marks for this submission: 2.00/2.00.
Question 2

Correct

Mark 2.00 out of 2.00

Write a C program to read a, b value and find the greatest value using  if-else

For example:

Input Result

1 2
B is greatest.

5 4 A is greatest.

Answer: (penalty regime: 0, 0, 0, 0, 0, 0, 0. %)

Reset answer

Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


{

int a,b;

scanf("%d%d", &a,&b);

if(a>b)

printf("A is greatest.");

else

printf("B is greatest.");

return 0;

Input Expected Got

 1 2 B is greatest. B is greatest. 

 5 4 A is greatest. A is greatest. 

Passed all tests!  

Question author's solution (C):


Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include <stdio.h>

int main()

int a,b;

scanf("%d%d", &a,&b);

if(a>b)

printf("A is greatest.");

else

printf("B is greatest.");

Correct
Marks for this submission: 2.00/2.00.
Question 3

Correct

Mark 2.00 out of 2.00

Write a C program to check whether the given number is  even number and it is less than 10 or not using nested if.

For example:

Input Result

15 The number is NOT an even number

10 The number is even

The number is less than or equal to 10

Answer: (penalty regime: 0, 0, 0, 0, 0, 0, 0. %)

Reset answer

Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include <stdio.h>

int main()

int num;

scanf("%d",&num);

if (num%2==0)

printf("The number is even\n");

if (num<=10)

printf("The number is less than or equal to 10\n");

else

printf("The number greater than 10\n");

Input Expected Got

 15 The number is NOT an even number The number is NOT an even number 

 10 The number is even


The number is even

The number is less than or equal to 10 The number is less than or equal to 10

 8 The number is even


The number is even

The number is less than or equal to 10 The number is less than or equal to 10

Passed all tests!  

Question author's solution (C):


Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


{

printf("The number is even\n");

if (num<=10)

printf("The number is less than or equal to 10\n");

else

printf("The number greater than 10\n");

else

printf("The number is NOT an even number\n");

return 0;

Correct
Marks for this submission: 2.00/2.00.
Question 4

Correct

Mark 2.00 out of 2.00

Write a program in C to read any digit(1-9), display in the word.


For example:

Input Result

12 invalid number.

9
Nine.

Answer: (penalty regime: 0, 0, 0, 0, 0, 0, 0. %)

Reset answer

Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

int num;

scanf("%d",&num);

if (num==0)

printf("Zero\n");

else if(num==1)

printf("one\n");

else if(num==2)

printf("Two\n");

Input Expected Got

 12 invalid number. invalid number. 

 9 Nine. Nine. 

Passed all tests!  

Question author's solution (C):


Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

int num;

scanf("%d",&num);

if (num==0)

printf("Zero\n");

else if(num==1)

printf("one\n");

else if(num==2)

printf("Two\n");

Correct
Marks for this submission: 2.00/2.00.
Question 5

Correct

Mark 2.00 out of 2.00

Write a C Program to print digits into words using the switch statement(1- ONE, 5-FIVE)

For example:

Input Result

0 ZERO

4
FOUR

Answer: (penalty regime: 0, 0, 0, 0, 0, 0, 0. %)

Reset answer

Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

int choice;

scanf("%d",&choice);

switch (choice)

case 0: printf("ZERO");

break;

case 1: printf("ONE");

break;

case 2: printf("TWO");

break;

case 3: printf("THREE");

break;

case 4: printf("FOUR");

Input Expected Got

 0 ZERO ZERO 

 4 FOUR FOUR 

 7 ... Plz Enter 0 to 5 Numbers Only... ... Plz Enter 0 to 5 Numbers Only... 

Passed all tests!  

Question author's solution (C):


Ace editor not ready. Perhaps reload page?

Falling back to raw text area.


#include<stdio.h>

int main()

int choice;

scanf("%d",&choice);

switch (choice)

case 0: printf("ZERO");

break;

case 1: printf("ONE");

break;

case 2: printf("TWO");

break;

case 3: printf("THREE");

break;

case 4: printf("FOUR");

Correct
Marks for this submission: 2.00/2.00.

← S1-Assignment-2 (Automata Coding)

Jump to...

Operators & Expressions →

You might also like