Third time job

Source: Internet
Author: User
Tags uppercase letter

1. Character JudgmentEnter a character to determine if it is lowercase letter output its corresponding uppercase letter, if it is uppercase letters output its corresponding lowercase, if the digital output number itself, if it is a space, output "space", if not the case, output "other".
#include <stdio.h>intMain () {Charx; scanf ("%c",&x); if(x>='a'&&x<='Z') {x=x- +; printf ("%c", x); }    Else if(x>='A'&&x<='Z') {x=x+ +; printf ("%c", x); }    Else if(x>='0'&&x<='9') {printf ("%c", x); }    Else if(x=' ') {printf ("Space"); }    Else{printf (" Other"); }return 0;}

2. Age issuesEnter a student's birthday (year: Month: Day), and enter the current date (year: Month: Day) to calculate the actual age of the students (years old)
#include <stdio.h>intMain () {inta,b,c,d,e,f,g; printf ("Please enter the student's birthday"); scanf ("%d%d%d",&a,&b,&c); printf ("Please enter today's date"); scanf ("%d%d%d",&d,&e,&f); if((b==e&&c<=f) | | b<e) {g=d-A; printf ("%d", G); }    Else if(b==e&&c>f) {g=d-a-1; printf ("%d", G); }    Else{g=d-a-1; printf ("%d", G); }    return 0;}

3. Judging the type of triangleenter three integers to determine the type of triangle (equilateral triangle, isosceles triangle, isosceles right triangle, right triangle, general triangles, and non-triangles)

#include <stdio.h>intMain () {intA,b,c; printf ("Please enter a three integer"); scanf ("%d%d%d",&a,&b,&c); if(a+b<c| | A-b>c) {printf ("Non-triangular"); }    Else if(a==b&&b==c&&a==c) {printf ("equilateral triangle"); }    Else if((a==b&&a*a+b*b==c*c) | | (a==c&&a*a+c*c==b*b) | | c==b&&c*c+b*b==a*a) {printf ("isosceles Right Triangle"); }    Else if((a==b&&a*a+b*b!=c*c) | | (a==c&&a*a+c*c!=b*b) | | c==b&&c*c+b*b!=a*a) {printf ("isosceles Triangle"); }    Else if((a*a+b*b==c*c) | | (a*a+c*c==b*b) | | c*c+b*b==a*a) {printf ("Right Triangle"); }    Else{printf ("General Triangles"); }return 0;} 

4. See commodity guessing price games

#include <stdio.h>#include<stdlib.h>#include<time.h>intMain () {intb; printf ("Please enter an integer"); scanf ("%d",&a);    Srand (Time (NULL)); b=rand ()% -+1; if(a>b) {printf ("you guessed the price was too big."); }    Else if(a<b) {printf ("you guessed the price was too small."); }    Else{printf ("you guessed right."); } printf ("This number is%d .", B); return 0;}

Experiment Summary:

Characters with single quotation marks;

Symbolic constants with Char;

Note the difference between%d and%c

Summary of Knowledge points:

The assignment is = and equals = = =

If after without semicolons

Third time job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.