more of this stuffs shabbir but i really do need codes in c programming to try my hands on it please i really need it badly

0

0

got a little problem here, it doesnt end when i input "n" where it asks me wanna countinues or not

0

0

if(choice=='y'||choice=='Y')

//main();

something wrong in "main(); ",could you tell me how to modify it?thank you !!

0

if(choice=='y'||choice=='a')

//main()

change your second option ..y=a.

then try it .

0

"if(choice=='y'||choice=='a') main();",

as far as i concerned, the "main()" can not use again in one programme,

0

At last i find a new solution solve my problem which i proposed yesterday,using the "goto";code is as follows:

Code:

#include<stdio.h> float add(float,float); float sub(float,float); float product(float,float); float divide(float,float); int main(int argc, char *argv[]) { float n1,n2; char sym,choice; printf("This Program is a program for calculator\n\n"); start_again: scanf("%f%c%f",&n1,&sym,&n2); if(sym=='+') printf("\n%f",add(n1,n2)); if(sym=='-') printf("\n%f",sub(n1,n2)); if(sym=='*') printf("\n%f",product(n1,n2)); if(sym=='/') printf("%f",divide(n1,n2)); printf("\nDo you wish to continue[y/n]"); scanf("%s",&choice); if(choice=='y'||choice=='Y') goto start_again; system("PAUSE"); return 0; } float add(float m1,float m2) { return(m1+m2);} float sub(float m1,float m2) { return(m1-m2);} float product(float m1,float m2) { return(m1*m2);} float divide(float m1,float m2) { return(m1/m2);}

*Last edited by shabbir; 3Oct2010 at 15:54.. Reason: Code blocks*

0

i add some functioins and program a new code that based on codezone as follows:

welcome to give some advice!!

Code:

#include<stdio.h> float add(float,float); float sub(float,float); float product(float,float); float divide(float,float); int main(int argc, char *argv[]) { float n1,n2; char sym,choice; printf("This Program is a program for calculator\n"); printf("Please input two numbers like this:4+5 or 4*5\n"); start_again: scanf("%f%c%f",&n1,&sym,&n2); if(sym=='+') printf("\n%f",add(n1,n2)); if(sym=='-') printf("\n%f",sub(n1,n2)); if(sym=='*') printf("\n%f",product(n1,n2)); if(sym=='/') printf("%f",divide(n1,n2)); printf("\nDo you wish to continue[y/n]\n"); input: scanf("%s",&choice); if(choice=='n'||choice=='N') { printf("Good Luck!!ByeBye!~\n"); goto end; } else if(choice=='y'||choice=='Y') { printf("Please Contiue:\n"); goto start_again; } else if(choice!='n'||choice!='N'||choice!='y'||choice!='Y') { printf("Wrong code!\n"); printf("Input again:\n"); goto input; } end: system("PAUSE"); return 0; } float add(float m1,float m2) { return(m1+m2);} float sub(float m1,float m2) { return(m1-m2);} float product(float m1,float m2) { return(m1*m2);} float divide(float m1,float m2) { return(m1/m2);}

*Last edited by shabbir; 3Oct2010 at 18:57.. Reason: Code blocks*

0

Ok its alright

0