第一篇:大連東軟信息學(xué)院大一上 電子工程 c語言-作業(yè).doc第一次,第二周
4.Create a program that uses escape sequence “ to print favorite quote.#include
main()
{
clrscr();
printf(“”Just do myself.“");
}
5.Create a program that uses escape sequence to print the following structure c:cygwinhomeadministrator.#include
main()
{
clrscr();
printf(”C:cygwinhomeadministrator“);
}
6.Create a program that uses escape sequence to print the following directory structure c:cygwinhomeadministrator.#include
main()
{
clrscr();
printf(”ttt*nnntt*tt*nnnt*tttt*nnn*tttttt*nnnt*tttt*nnntt*tt*nnnttt*“);
}
7.Create a calendar program using the current month.#include
main()
{
clrscr();
printf(”SuntMontTuetWedtThutFritSatn“);
printf(”1t2t3t4t5t6t7n“);
printf(”8t9t10t11t12t13t14n“);
printf(”15t16t17t18t19t20t21n“);
printf(”22t23t24t25t26t27t28n“);
printf(”29t30");
}
第二篇:大連東軟信息學(xué)院C語言指針練習(xí)2016.docx
一、Make a choice 1.For the same data type pointer variable, which operator can notused in C program.A.+
B.-
C.=
D.== 2.when0<=i<10, for the following statements, which reference is wrong to reference array elements.int a[]={1,2,3,4,5,6,7,8,9,0}, *p, i;p=a;A.*(a+i)
B.a[p-a]
C.p+i
D.*(&a[i])3.when0<=i<10, for the following statements, which reference is wrong to reference the address of array elements.int a[]={1,2,3,4,5,6,7,8,9,0}, *p,i;
p=a;
A.&(a+1)
B.a++
C.&p
D.&p[i] 4.What is the result for the following program? #include
p=a;
*(p+3)+=2;printf(“%d,%dn”,*p,*(p+3));}
A.0,5
B.1,5
C.0,6
D.1,6 5.what is the result for the following program? #include
A.輸出項(xiàng)不合法
B.6
C.8
D.12 6.For the following statements, what’s the value of(p1-p2)? int a[10], *p1, *p2;p1=a;p2=&a[5];
A.5
B.6
C.10
D.沒有指針與指針的減法
7.for this function prototype: void adder(int *ptr,int b);if there are two integers: int op1=2;int op2=4;which statement of function call is right?
A:adder(*op1,op2);B:adder(op1,op2);C:adder(&op1,op2);D:adder(&op1,&op2);8.What does the following program outputs to screen_____ voidToSrn(int *);main(){ int a=8;int *ptr=&a;ToSrn(ptr);} voidToSrn(int *ptr){ printf(“%p”,&a);} A:compile error,can not be run B:8 C:16 D:address of a 9.Assuming int *p,a=4;p=&a;which of the following statements is all means address A:a,p+1 B:&a,*p C:&a,p D:*a,p 10.Assuming inta[10],*p;which one is right A:*p=&a[0];B:*p=a;C:p=a[0];D:p=&a[0];11.Assuming :int a[10],*p=a;which one is the address of a[9] A:a[0]+9 B:&(p+9)C:*(p+9)D:a+9 12.Assuming:
char s1[]=“Hello”,s2[10],*s3=“HelloWorld”,*s4;which one of the following statements is correct? A:strcpy(s1[0],“Morning”);B:s2=“Morning”;C:strcpy(s3,“Morning”);D:strcpy(s4,“Morning”);13.For the following statements,after execution the statement a=p+2;what’s the value of a[0]? float a[3]={1.2,45.6,-23.0};float *p=a;
A.1.2
B.45.6
C.-23.0
D.語句有錯(cuò)
14.What format speci?ers(in order)should be used in the printf()statement in thefollowing program? Note that in the program the correct format speci?ers have beenreplaced by Z.#include
二、Fill the blank.1.the result of printf(“%sd”,“ab