C Language First Speaking

Source: Internet
Author: User

"C Language Basics" after-school assignments
1, (*) calculates the decimal 42 conversion to binary, octal, hexadecimal corresponding value.

<42 Two-stage 100,108-binary 526-0x2>

2 Calculating decimal values for binary 11010110

< decimal 112>

3 Calculating decimal values for octal 075

<61>

4 Calculating the hexadecimal 0xa8 corresponding decimal value <168>

5 Print the following graphic:

#include <stdio.h>

int main (int argc, const char * argv[])

{

printf ("* \ n");

printf ("* * \ n");

printf ("* * * \ n");

}

6 Write a program that requires the user to enter a dollar amount and then show the corresponding amount after increasing the%5 tax rate. The format is as follows: Enter an amount:100.00 with tax added:$105.00

#include <stdio.h>

int main (int argc, const char * argv[]) {

float A, B;

printf ("Enter an amount:");

scanf ("%f", &a);

B=1.05*a;

printf ("With tax added:$%.2f\n", b);

return 0;

}

7 Enter two real numbers a and b from the keyboard, and a percentage of B for output a. Retain 2 digits after the decimal point. For example: Input 1 and 4, output: 25%

#include <stdio.h>

int main (int argc, const char * argv[]) {

float A, B; printf ("Please enter two numbers:");

scanf ("%f%f", &a,&b);

printf ("%.2f\n", A/b);

printf ("Output:%.2f%%", a/b*100);

return 0;

}

8 Write a program that asks the user to enter a dollar amount and then shows how to pay with a minimum of $20, $10, $5 and $1: Enter a dollar Amoun t:93 $ bills:4 $ bills:1 $ bills:0 Bills:3


#include <stdio.h>

int main (int argc, const char * argv[]) {

int a,b,c,d,e;

printf ("Please enter a number:");

scanf ("%d", &a);

B=A/20;

printf ("$ bills:%d\n", b);

C= (A-B*20)/10;

printf ("$ bills:%d\n", c);

D= (A-B*20-C*10)/5;

printf ("$ bills:%d\n", d);

E= (a-b*20-c*10-d*5)/1;

printf ("$ bills:%d\n", e);

return 0;

}

9 Enter two integers, print these two numbers of the and, difference, product, remainder


#include <stdio.h>

int main (int argc, const char * argv[]) {

int A, B;

printf ("Please enter two integers:");

scanf ("%d%d", &a,&b);

printf ("%d\n", a+b);

printf ("%d\n", A-B);

printf ("%d\n", a*b);

printf ("%d\n", A/b);

printf ("%d\n", a%b);

return 0;

}


10 Find the ASCII code table, with%d output characters, and output integers with%c.


#include <stdio.h>

int main (int argc, const char * argv[]) {

char a = ' a ';

printf ("Please enter:");

scanf ("%c", &a);

printf ("%d\n", a);

printf ("%c\n", a);

}

This article is from the "Java Dating-Communication Blog" blog, be sure to keep this source http://zys2007.blog.51cto.com/8207599/1592602

C Language First Speaking

Related Article

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.