a simple if statement to output the award of athletes in a competition

0 votes
asked Nov 22 by anonymous

 

rank award
11000,00
2500,000
3250,000
any other0

 

 

6 Answers

+1 vote
answered Nov 26 by anonymous
#include<stdio.h>

void main()

{int a;

printf("enter the rank");

scanf("%d",&a);

if(a==1)

printf("10,00,000");

else if(a==2)

printf("5,00,000");

else if(a==3)

printf("2,50,000");

else

printf("0");

}
–1 vote
answered Nov 27 by (1,180 points)
–1 vote
answered Nov 27 by (510 points)
0 votes
answered Nov 27 by anonymous
#include <stdio.h>
#include <string.h>
int main()
{
    const char* a[] = {"1000,00", "500,000", "250,000"};
    int r;
    printf("enter the rank");
    scanf("%d", &r);
    char s[10] ;
    strcpy (s, (r < 4 && r>0)? a[r-1] : "0");
    
    printf("will get %s", s);
    return 0;
}
0 votes
answered Nov 28 by anonymous
rank= float(input("Enter a number: "))
if rank==1:

  award=100000
  print(award)

elif rank==2:

  award=500000
  print(award)

elif rank==3:

  award=250000

  print(award)

else:

  print(0)
0 votes
answered Nov 29 by Noam0509
in Java:

import java.util.Scanner; //import Scanner
public class Main{ //create class
public static void main(String[] args) { //create public main method

int award; //the award int
Scanner sc = new Scanner(System.in); //creating the scanner
System.out.println("Pls enter you rank: "); //telling him to enter the rank
int rank = sc.nextInt(); //Creating the rank int and the user input

if(rank == 1){ //the first if
award = 1000000; // setting the award to 1,000,000
}

else if(rank == 2){ //second if

award = 500000;  //setting -award to be 500,000
}

else if(rank == 3){ //3 if
award = 250000; //setting award to be 250,000
}

else{ //the last else here goes everyone whos not from the first 3
award = 0; // setting thier award to be 0
}

System.out.println("this is your award: " + award);//printing the result
}
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...