紧急求助!我的第一个C语言程序,如何写?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了紧急求助!我的第一个C语言程序,如何写?相关的知识,希望对你有一定的参考价值。

第一个C语言程序。该程序要求用户输入个人信息,然后打印出来一段欢迎的话。程序的运行要求达到如下示例的效果:
Please input your name:
Tom
Please input your class:
F06032032
How many students in your class?
30
Hello, Tom! Welcome to SJTU! You are in class F06032032. You have 29 classmates.

#include <stdio.h>
main()

char name[80],classname[80]; //用class当变量就不兼容C++了
int stu;
puts("Please input your name:");
gets(name);
puts("Please input your class:");
gets(classname);
puts("How many students in your class?");
scanf("%d", &stu);
printf("Hello,%s!", name);
printf("Welcome to SJTU!");
printf("You are in class %s.", classname);
printf("You have %d classmates\\n", stu-1);
return 0;
参考技术A 校友总得帮一下,呵呵!

int main()

char name[50]='\0';
char classes[50]='\0';
int num=0;
printf("Please input your name:\n");
scanf("%s",&name);
printf("Please input your class:\n");
scanf("%s",&classes);
printf("How many students in your class?\n");
scanf("%d",&num);
printf("Hello, %s! Welcome to SJTU! You are in class %s. You have %d classmates.",name,classes,num-1);
return 0;
参考技术B main()

char name[20],class[10];
int stuNum;
printf("Please input your name:\n");
gets(name);
printf("Please input your class:\n");
gets(class);
printf("How many students in your class?\n");
scanf("%d",&stuNum);
printf("Hello, %s! Welcome to SJTU! You are in class %s. You have %d classmates.\n",name,class,stuNum-1);
getch();
参考技术C #include <stdio.h>
main()

char a[10],b[20];
int c;
printf("Please input your name: ");
scanf("%s",a);
printf("Please input your class: ");
scanf("%s",b);
printf("How many students in your class: ");
scanf("%d",&c);
printf("Hello, %s! Welcome to SJTU! You are in class %s. You have %d classmates\n",a,b,c-1);
参考技术D main()
char a,b,
int c;
a=scanf("Please input your name:=%s",&a);
b=scanf("Please input your class:=%s",&b);
c=scanf("How many students in your class? :=%d",&c);
printf("Please input your name:=%s\n,
Please input your class:=%s\n,
How many students in your class? :=%d\n",a,b,c);
第5个回答  2006-09-20 随便一本C语言的书就有了

紧急求助,关于In-house testing method

参考技术A 您好,很高兴为您解答。

In-house testing method

中文解释:室内测试方法

如若满意,请点击右侧【采纳答案】,如若还有问题,请点击【追问】

希望我的回答对您有所帮助,望采纳!

~ O(∩_∩)O~本回答被提问者和网友采纳

以上是关于紧急求助!我的第一个C语言程序,如何写?的主要内容,如果未能解决你的问题,请参考以下文章

紧急求助,请问如何在android 系统中通过ndk内嵌c版bullet物理引擎???主要是如何编译bullet源代码?...

C语言编程,求助!

(紧急求助)请问PB中如何实现单据的审核,单据的状态有未审核以及审核两种状态,谢谢

紧急求助!ARM-GCC对于函数指针调用的编译有错误?已经找到原因

求助一道抽签程序

求助:c语言中的三角形问题。。