Third time job

Source: Internet
Author: User
Tags uppercase letter

1. Character judge input a character, judge if it is lowercase letter output its corresponding uppercase letter, if it is uppercase letters output its corresponding lowercase, if it is the digital output number itself, if it is a space, output "space", if not the case, output "other".


#include <stdio.h>intMain () {CharC; printf ("Please enter a character:"); scanf ("%c",&c); if(c>='a'&&c<='Z') {C=c- +; printf ("%c\n", c); } Else if(c>='A'&&c<='Z') {C=c+ +; printf ("%c\n", c); } Else if(c>='0'&&c<='9') {printf ("%c\n",&B); } Else if(c=' ') {printf ("space\n"); } Else{printf ("other\n"); } return 0;}

* Mastering and familiarity with input and output formats using character data
2. Age issues
Enter a student's birthday (year: Month: Day), and enter the current date (year: Month: Day) to calculate the actual age (years) of the birth.
#include <stdio.h>intMain () {inta,b,c,d,e,f,g; printf ("Please enter your birthday."); scanf ("%d%d%d",&a,&b,&c); printf ("Please enter today's date"); scanf ("%d%d%d",&d,&e,&f); if(a==d) {printf ("you're 0 years old ."); }    Else if(a<d) {if(b<e) {g=d-A; printf ("you're%d years old .", G); }        Else if(b>e) {g=d-a-1; printf ("you're%d years old .", G); }        Else         {            if(c<=f) {g=d-A; printf ("you're%d years old .", G); }            Else{g=d-a-1; printf ("you're%d years old .", G); }        }    }    Else{printf ("Input Error"); }    return 0;}



The nested format of the *if else statement is used with the attention of the indented format, the curly braces are easy to throw away or cannot match the other half of the corresponding, it is best to first write the first layer and then write the nested content.


3. Judging the type of triangle
Enter 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,d,e,f,g; printf ("Please enter your birthday."); scanf ("%d%d%d",&a,&b,&c); printf ("Please enter today's date"); scanf ("%d%d%d",&d,&e,&f); if(a==d) {printf ("you're 0 years old ."); }    Else if(a<d) {if(b<e) {g=d-A; printf ("you're%d years old .", G); }        Else if(b>e) {g=d-a-1; printf ("you're%d years old .", G); }        Else         {            if(c<=f) {g=d-A; printf ("you're%d years old .", G); }            Else{g=d-a-1; printf ("you're%d years old .", G); }        }    }    Else{printf ("Input Error"); }    return 0;}

* Note the difference "" "" "" 4. Look at the commodity guess the price small game
#include <stdlib.h>#include<stdio.h>#include<time.h>intMain () {intb; printf ("Please guess the price of this product in 1-100 rooms"); scanf ("%d",&a);    Srand (Time (NULL)); b=rand ()% -+1; if(a==b) {printf ("the merchandise belongs to you."); }    Else if(a<b) {printf ("it's too small."); }    Else{printf ("it's too big."); }    return 0;}








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: info-contact@alibabacloud.com 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.