Hi i am re-studying C.So I just wanted to do a simple calculator program.I am using dev-c++ anyways the code is below please help.

#include <stdio.h>
#include <conio.h>


/*its a simple program that after getting the numbers from the user and  inputs the
operation*/



int main()

{
  
  int i=0;
  int a=0;
  int b=0;
  int s=0;
  char o;
  
  while(i==i){ /*a simple for-ever loop*/
	  printf("Enter the first number");
	  scanf("%d",&a);
	  
	  printf("Enter the second number");
	  scanf("%d",&b);
	  
	  printf("What do you want to do with them?");
	  scanf("%c",o);
	  
	  switch(o)
			{
				case '+': s=a+b;
			    printf("\n The sum is :  %d" ,s);
				scanf("");
				break;
				
				default :
				printf("\n invalid");
				scanf("");
				break;
				}
	  
	  
	  } 
}

Hi i am re-studying C.So I just wanted to do a simple calculator program.I am using dev-c++ anyways the code is below please help.

It's easier to provide answers when you provide questions.

You may want to take a look at a way to Read a Line of Text from the User and a way to Read a Number from the User.

scanf has a lot of issues that trip up beginners.

scanf("%d",&b);
	  
	  printf("What do you want to do with them?");
	  scanf("%c",o);

Like the newline being left in the buffer. Or that a pointer must be passed.

scanf("%c",&o);

sorry man youre right i can't believe it i forgot to write an answer ok i'll look into the links now.And by the by the question was that windows kept giving me an error whe i run the program.But le me try the things you've said.

And It Works Thanks Man....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.