Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed i have this code in c that dose not work

+7 votes
asked Jan 21, 2023 by Parth sharma (200 points)
closed Jan 31, 2023 by Admin
# include<stdio.h>

 int main(){   

 int a;   

 int b;     printf("the value of a\n");

     scanf("%d/n", &a);

      printf( "the value of b \n" );

    scanf("%d\n"& b );   

  printf("the sum of two numbers is %d", a + b);

     return 0;

}
closed with the note: answered

11 Answers

0 votes
answered Jan 31, 2023 by Subash Sharma (140 points)

your code has error while taking input from user.

The proper way of getting input from user is :

printf("Enter value of a : ");

scanf("%d", &a);

printf("Enter value of b  : ");

scanf("%d", &b);

Note: You have used \n  in scanf which is wrong or the error of this code. \n is used for new line .so while storing the value in a and b we don't need new line so it is getting error there.

Hope This is helpful !

Happy Coding

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...