Computer Science, asked by shameelaashraf, 6 months ago

pls answer this question
this is class 8 python conditonal statement worksheet
whoever answer this question I will mark them as the BRAINLIEST if it is correct only
all the 6 questions have to be answered​

Attachments:

Answers

Answered by Unni007
4

Question-1

#include<stdio.h>

int main()

{

int a ;

 

//input age

printf("Enter the age of the person: ");

scanf("%d",&a);

//check voting eligibility

if (a>=18)

{

 printf("Eigibal for voting");

}

else

{

 printf("Not eligibal for voting\n");

}  

return 0;

}

_________________________

Question-2

#include <stdio.h>

int main() {

   int num;

   printf("Enter an integer: ");

   scanf("%d", &num);

   // True if num is perfectly divisible by 2

   if(num % 2 == 0)

       printf("%d is even.", num);

   else

       printf("%d is odd.", num);

   

   return 0;

}

_________________________

Question-3

I forgotten it sorry..

_________________________

Question-4

#include <stdio.h>

int main() {

   char c;

   int lowercase_vowel, uppercase_vowel;

   printf("Enter an alphabet: ");

   scanf("%c", &c);

   // evaluates to 1 if variable c is a lowercase vowel

   lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

   // evaluates to 1 if variable c is a uppercase vowel

   uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

   // evaluates to 1 (true) if c is a vowel

   if (lowercase_vowel || uppercase_vowel)

       printf("%c is a vowel.", c);

   else

       printf("%c is a consonant.", c);

   return 0;

}

_________________________

Question-5

1. Start

2. Read the three numbers to be compared, as A, B and C.

3. Check if A is greater than B.

 3.1 If true, then check if A is greater than C.

   3.1.1 If true, print 'A' as the greatest number.

   3.1.2 If false, print 'C' as the greatest number.

 3.2 If false, then check if B is greater than C.

   3.1.1 If true, print 'B' as the greatest number.

   3.1.2 If false, print 'C' as the greatest number.

4. End

_________________________

Question-6

sub1=int(input("Enter marks of the first subject: "))

sub2=int(input("Enter marks of the second subject: "))

sub3=int(input("Enter marks of the third subject: "))

sub4=int(input("Enter marks of the fourth subject: "))

sub5=int(input("Enter marks of the fifth subject: "))

avg=(sub1+sub2+sub3+sub4+sub4)/5

if(avg>=90):

   print("Grade: A")

elif(avg>=75):

   print("Grade: B")

elif(avg>=60):

   print("Grade: C")

elif(avg>=50):

   print("Grade: D")

elif(avg>=33):

   print("Grade: E")

elif(avg<33):

Similar questions