[ create a new paste ] login | about

Link: http://codepad.org/PCGY7JUX    [ raw code | output | fork | 1 comment ]

C, pasted on Sep 14:
#include<stdio.h>
#include<conio.h>
#include<string.h>
char hoten [30];
int toan;
int van;
float DiemTrungBinh;

void Nhap()
{
	fflush(stdin);
	printf("\nNhap ho ten: ");
	gets(hoten);

	printf("\nNhap toan: ");
	scanf("%d", &toan);

	printf("\nNhap van: ");
	scanf("%d", &van);
}

void XuLy()
{
	DiemTrungBinh = (toan + van) / 2.0;
}

void Xuat()
{
	printf("\nHo ten: %s", hoten);
	printf("\nToan: %d", toan);
	printf("\nVan: %d", van);
	printf("\nDiem Trung Binh: %f", DiemTrungBinh);
}
int main()
{
	Nhap();
	XuLy();
	Xuat();

	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by Dgls yesterday
#include<iostream>
using namespace std;
struct hs{
char ten[30];
float toan, van;
};
void nhap(hs &x){
cout<<"Nhap ten hoc sinh: ";
fflush(stdin); gets(x.ten);
cout<<"Diem Toan:" ; cin>>x.toan;
if (x.toan<0||x.toan>10){
cout<<"Diem toan nhap sai, nhap lai: "; cin>>x.toan;
}
cout<<"Diem Van: "; cin>>x.van;
if (x.van<0||x.van>10){
cout<<"Diem van nhap sai, nhap lai: "; cin>>x.van;
}
}
float diemtb(hs x){
return (x.toan+x.van)/2;
}
main(){
hs x;
nhap(x);
cout<<"Diem trung binh la: "<<diemtb(x)<<endl;
}
reply