Please helf with my C coding - TechRepublic
General discussion
February 29, 2012 at 08:57 AM
avmakamu

Please helf with my C coding

by avmakamu . Updated 14 years, 3 months ago

Please check my c coding I don???t know what seem to be the problem I get the zero total always I run this program, please bare with me I???m still a beginner.
below is my program.

#include
#include

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

char Stname[50],Stsurname[50],Fullname[100];
int test1,test2,test3,test4,test5;
float total;
double Finalmark;
int k,i,j;

k = 0;
k = 0;
j = 0;

printf(“Please Enter Your Name:\n”);
scanf(“%s”,&Stname);

printf(“Please Enter Your SurName:\n”);
scanf(“%s”,&Stsurname);

for(k = 0;k <= 4;k++) { if(k == 0){ printf("Please Enter Test1:\n"); scanf("%d",&test1); //total = total + test1; k++; } if(k == 1){ printf("Please Enter Test2:\n"); scanf("%d",&test2); // total = total + test2; k++; } if(k == 2){ printf("Please Enter Test3:\n"); scanf("%d",&test3); //total = total + test3; k++; } if(k == 3){ printf("Please Enter Test4:\n"); scanf("%d",&test4); // total = total + test4; k++; } if(k == 4){ printf("Please Enter Test5:\n"); scanf("%d",&test5); //total = total + test5; k++; } k++; // total == total; } total = test1 + test2 + test3 + test4 + test5; Finalmark == ((total/500)*100); printf("Your Full Name is:%s%5s\n",Stname,Stsurname); printf("Your total is:%d\n",total); printf("Your Full Marks is:%d\n",Finalmark); system("PAUSE"); return 0; }

This discussion is locked

All Comments