Quick actions

cmd+k|ctrl+k

Navigation

Languages

p, q, r, s from the user

Snippet info

Language

C

Visibility

public

Author

krishnakanth

Created

2023-01-19T15:30:51.018652Z

Updated

2023-01-19T15:30:51.018652Z

// Write a C program that accepts 4 integers p, q, r, s from the user
// where q, r and s are positive and p is even.
// If q is greater than r and
// s is greater than p and
// if the sum of r and s is greater than the sum of p and q
//  print "Correct values", otherwise print "Wrong values".*/
#include <stdio.h>
int main() {
int p, q, r, s;
 printf("\nInput the first integer p: ");
 scanf("%d", &p);
 printf("\nInput the second integer q: ");
 scanf("%d", &q);
 printf("\nInput the third integer r: ");
 scanf("%d", &r);
 printf("\nInput the fourth integer s: ");
 scanf("%d", &s);
if((q > r) && (s > p) && ((r+s) > (p+q)) && (r > 0) && (s > 0) && (p%2 == 0))
{
printf("\nCorrect values\n");
}
else {
printf("\nWrong values\n");
}
return 0;
}
INFO