Cocubes Coding Quesitons – 6
Ques. 1 Write a program to find out total marks obtained by a student if the student gets 3 marks for the correct answer and -1 for the wrong answer?
This section is new and we are trying to find more questions in this section. Please comment below the questions you got in the exam and we will provide the solutions and add them up here.
Login/Signup to comment
#lets take an array as a input which contain -1 for wrong answer and 3 for correct answer.
s=list(map(int,input().split()))
c=0
for i in s:
if i==3:
c+=3
else:
c-=1
#total marks
print(c)
arr=[1,0,1,1,1,0,0]
n=arr.count(0)
m=arr.count(1)
print(m*3-n)
import java.util.*;
public class markingscheme {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
int arr[]=new int[] {1,0,1,1,1,0,0};
int sum=0;
for(int i=0;i<arr.length;i++)
{
if(arr[i]==1)
sum=sum+3;
else
sum=sum-1;
}
System.out.println("Total Marks Obtained :"+ sum);
}
}
9
import java.util.*;
class rightwrong{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int arr[] = new int[]{1,0,1,1,1,0,0};
int n=arr.length;
int sum=0;
for(int i=0;i<n;i++){
if(arr[i]==1)
sum=sum+3;
else{
sum=sum-1;
}
}
System.out.println(sum);
}
}
lets take an array as a input which contain 0 for wrong ans and 1 for correct ans.
.for ex-a=[0,1,1,1,0]
//1 for corect
//0 for wrong
int count=0;
for(int i=0;i<a.length;i++)
{
if(a[i]==0)
count=count-1;
else
count=count+3;
}
Cocubes