Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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

0 votes
asked Nov 22, 2019 by anonymous

 

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

 

 

6 Answers

+1 vote
answered Nov 26, 2019 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, 2019 by rohan ag (1,310 points)
–1 vote
answered Nov 27, 2019 by bhoomi2000 (780 points)
0 votes
answered Nov 27, 2019 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, 2019 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, 2019 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.
...